PageRenderTime 79ms CodeModel.GetById 64ms app.highlight 1ms RepoModel.GetById 13ms app.codeStats 0ms

/src/Core/Joystick.xs

http://github.com/PerlGameDev/SDL
Unknown | 138 lines | 118 code | 20 blank | 0 comment | 0 complexity | 90437afc14b6864926bad02fcdcef73b MD5 | raw file
  1#include "EXTERN.h"
  2#include "perl.h"
  3#include "XSUB.h"
  4#include "ppport.h"
  5
  6#ifndef aTHX_
  7#define aTHX_
  8#endif
  9
 10#include <SDL.h>
 11
 12MODULE = SDL::Joystick 	PACKAGE = SDL::Joystick    PREFIX = joystick_
 13
 14SDL_Joystick *
 15joystick_new (CLASS, index ) 
 16	char* CLASS
 17	int index
 18	CODE:
 19		RETVAL = SDL_JoystickOpen(index);
 20	OUTPUT:
 21		RETVAL
 22
 23
 24int
 25joystick_num_joysticks ()
 26	CODE:
 27		RETVAL = SDL_NumJoysticks();
 28	OUTPUT:
 29		RETVAL
 30
 31char *
 32joystick_name ( index )
 33	int index
 34	CODE:
 35		RETVAL = (char*)SDL_JoystickName(index);
 36	OUTPUT:
 37		RETVAL
 38
 39int
 40joystick_opened ( index )
 41	int index
 42	CODE:
 43		RETVAL = SDL_JoystickOpened(index);
 44	OUTPUT:
 45		RETVAL
 46
 47int
 48joystick_index ( joystick )
 49	SDL_Joystick *joystick
 50	CODE:
 51		RETVAL = SDL_JoystickIndex(joystick);
 52	OUTPUT:
 53		RETVAL
 54
 55int
 56joystick_num_axes ( joystick )
 57	SDL_Joystick *joystick
 58	CODE:
 59		RETVAL = SDL_JoystickNumAxes(joystick);
 60	OUTPUT:
 61		RETVAL
 62
 63int
 64joystick_num_balls ( joystick )
 65	SDL_Joystick *joystick
 66	CODE:
 67		RETVAL = SDL_JoystickNumBalls(joystick);
 68	OUTPUT:
 69		RETVAL
 70
 71int
 72joystick_num_hats ( joystick )
 73	SDL_Joystick *joystick
 74	CODE:
 75		RETVAL = SDL_JoystickNumHats(joystick);
 76	OUTPUT:
 77		RETVAL
 78
 79int
 80joystick_num_buttons ( joystick )
 81	SDL_Joystick *joystick
 82	CODE:
 83		RETVAL = SDL_JoystickNumButtons(joystick);
 84	OUTPUT:
 85		RETVAL
 86
 87void
 88joystick_update ()
 89	CODE:
 90		SDL_JoystickUpdate();
 91
 92Sint16
 93joystick_get_axis ( joystick, axis )
 94	SDL_Joystick *joystick
 95	int axis
 96	CODE:
 97		RETVAL = SDL_JoystickGetAxis(joystick,axis);
 98	OUTPUT:
 99		RETVAL
100
101Uint8
102joystick_get_hat ( joystick, hat )
103	SDL_Joystick *joystick
104	int hat 
105	CODE:
106		RETVAL = SDL_JoystickGetHat(joystick,hat);
107	OUTPUT:
108		RETVAL
109
110Uint8
111joystick_get_button ( joystick, button)
112	SDL_Joystick *joystick
113	int button 
114	CODE:
115		RETVAL = SDL_JoystickGetButton(joystick,button);
116	OUTPUT:
117		RETVAL
118
119AV *
120joystick_get_ball ( joystick, ball )
121	SDL_Joystick *joystick
122	int ball 
123	CODE:
124		int success,dx,dy;
125		success = SDL_JoystickGetBall(joystick,ball,&dx,&dy);
126		RETVAL = (AV*)sv_2mortal((SV*)newAV());
127		av_push(RETVAL,newSViv(success));
128		av_push(RETVAL,newSViv(dx));
129		av_push(RETVAL,newSViv(dy));
130	OUTPUT:
131		RETVAL	
132
133void
134joystick_DESTROY ( joystick )
135	SDL_Joystick *joystick
136	CODE:
137		SDL_JoystickClose(joystick);
138