Skip to content

Commit

Permalink
Added Joystick XS, Added surface tests. Need a joystick to test the r…
Browse files Browse the repository at this point in the history
…est so leaving them as TODO
  • Loading branch information
Kartik Thakore committed Nov 17, 2009
1 parent d70f48a commit f104313
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 244 deletions.
7 changes: 7 additions & 0 deletions Build.PL
Expand Up @@ -161,6 +161,13 @@ my %subsystems =
},
libraries => [qw( SDL )],
},
Joystick => {
file => {
from => 'src/Core/Joystick.xs',
to => 'lib/SDL/Joystick.xs',
},
libraries => [qw( SDL )],
},

TTF_Font => {
file => {
Expand Down
9 changes: 9 additions & 0 deletions lib/SDL/Joystick.pm
@@ -0,0 +1,9 @@
package SDL::Joystick;
use strict;
use warnings;
require Exporter;
require DynaLoader;
our @ISA = qw(Exporter DynaLoader);
bootstrap SDL::Joystick;

1;
138 changes: 138 additions & 0 deletions src/Core/Joystick.xs
@@ -0,0 +1,138 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#ifndef aTHX_
#define aTHX_
#endif

#include <SDL.h>

MODULE = SDL::Joystick PACKAGE = SDL::Joystick PREFIX = joystick_

SDL_Joystick *
joystick_new (CLASS, index )
char* CLASS
int index
CODE:
RETVAL = SDL_JoystickOpen(index);
OUTPUT:
RETVAL


int
joystick_num_joysticks ()
CODE:
RETVAL = SDL_NumJoysticks();
OUTPUT:
RETVAL

char *
joystick_name ( index )
int index
CODE:
RETVAL = (char*)SDL_JoystickName(index);
OUTPUT:
RETVAL

int
joystick_opened ( index )
int index
CODE:
RETVAL = SDL_JoystickOpened(index);
OUTPUT:
RETVAL

int
joystick_index ( joystick )
SDL_Joystick *joystick
CODE:
RETVAL = SDL_JoystickIndex(joystick);
OUTPUT:
RETVAL

int
joystick_num_axes ( joystick )
SDL_Joystick *joystick
CODE:
RETVAL = SDL_JoystickNumAxes(joystick);
OUTPUT:
RETVAL

int
joystick_num_balls ( joystick )
SDL_Joystick *joystick
CODE:
RETVAL = SDL_JoystickNumBalls(joystick);
OUTPUT:
RETVAL

int
joystick_num_hats ( joystick )
SDL_Joystick *joystick
CODE:
RETVAL = SDL_JoystickNumHats(joystick);
OUTPUT:
RETVAL

int
joystick_num_buttons ( joystick )
SDL_Joystick *joystick
CODE:
RETVAL = SDL_JoystickNumButtons(joystick);
OUTPUT:
RETVAL

void
joystick_update ()
CODE:
SDL_JoystickUpdate();

Sint16
joystick_get_axis ( joystick, axis )
SDL_Joystick *joystick
int axis
CODE:
RETVAL = SDL_JoystickGetAxis(joystick,axis);
OUTPUT:
RETVAL

Uint8
joystick_get_hat ( joystick, hat )
SDL_Joystick *joystick
int hat
CODE:
RETVAL = SDL_JoystickGetHat(joystick,hat);
OUTPUT:
RETVAL

Uint8
joystick_get_button ( joystick, button)
SDL_Joystick *joystick
int button
CODE:
RETVAL = SDL_JoystickGetButton(joystick,button);
OUTPUT:
RETVAL

AV *
joystick_get_ball ( joystick, ball )
SDL_Joystick *joystick
int ball
CODE:
int success,dx,dy;
success = SDL_JoystickGetBall(joystick,ball,&dx,&dy);
RETVAL = newAV();
RETVAL = sv_2mortal((SV*)RETVAL);
av_push(RETVAL,newSViv(success));
av_push(RETVAL,newSViv(dx));
av_push(RETVAL,newSViv(dy));
OUTPUT:
RETVAL

void
joystick_DESTROY ( joystick )
SDL_Joystick *joystick
CODE:
SDL_JoystickClose(joystick);

227 changes: 0 additions & 227 deletions src/SDL.xs
Expand Up @@ -1182,233 +1182,6 @@ BigEndian ()
OUTPUT:
RETVAL

int
NumJoysticks ()
CODE:
RETVAL = SDL_NumJoysticks();
OUTPUT:
RETVAL

char *
JoystickName ( index )
int index
CODE:
RETVAL = (char*)SDL_JoystickName(index);
OUTPUT:
RETVAL

SDL_Joystick *
JoystickOpen ( index )
int index
CODE:
RETVAL = SDL_JoystickOpen(index);
OUTPUT:
RETVAL

int
JoystickOpened ( index )
int index
CODE:
RETVAL = SDL_JoystickOpened(index);
OUTPUT:
RETVAL

int
JoystickIndex ( joystick )
SDL_Joystick *joystick
CODE:
RETVAL = SDL_JoystickIndex(joystick);
OUTPUT:
RETVAL

int
JoystickNumAxes ( joystick )
SDL_Joystick *joystick
CODE:
RETVAL = SDL_JoystickNumAxes(joystick);
OUTPUT:
RETVAL

int
JoystickNumBalls ( joystick )
SDL_Joystick *joystick
CODE:
RETVAL = SDL_JoystickNumBalls(joystick);
OUTPUT:
RETVAL

int
JoystickNumHats ( joystick )
SDL_Joystick *joystick
CODE:
RETVAL = SDL_JoystickNumHats(joystick);
OUTPUT:
RETVAL

int
JoystickNumButtons ( joystick )
SDL_Joystick *joystick
CODE:
RETVAL = SDL_JoystickNumButtons(joystick);
OUTPUT:
RETVAL

void
JoystickUpdate ()
CODE:
SDL_JoystickUpdate();

Sint16
JoystickGetAxis ( joystick, axis )
SDL_Joystick *joystick
int axis
CODE:
RETVAL = SDL_JoystickGetAxis(joystick,axis);
OUTPUT:
RETVAL

Uint8
JoystickGetHat ( joystick, hat )
SDL_Joystick *joystick
int hat
CODE:
RETVAL = SDL_JoystickGetHat(joystick,hat);
OUTPUT:
RETVAL

Uint8
JoystickGetButton ( joystick, button)
SDL_Joystick *joystick
int button
CODE:
RETVAL = SDL_JoystickGetButton(joystick,button);
OUTPUT:
RETVAL

AV *
JoystickGetBall ( joystick, ball )
SDL_Joystick *joystick
int ball
CODE:
int success,dx,dy;
success = SDL_JoystickGetBall(joystick,ball,&dx,&dy);
RETVAL = newAV();
av_push(RETVAL,newSViv(success));
av_push(RETVAL,newSViv(dx));
av_push(RETVAL,newSViv(dy));
OUTPUT:
RETVAL

void
JoystickClose ( joystick )
SDL_Joystick *joystick
CODE:
SDL_JoystickClose(joystick);

Sint16
JoyAxisEventWhich ( e )
SDL_Event *e
CODE:
RETVAL = e->jaxis.which;
OUTPUT:
RETVAL

Uint8
JoyAxisEventAxis ( e )
SDL_Event *e
CODE:
RETVAL = e->jaxis.axis;
OUTPUT:
RETVAL

Sint16
JoyAxisEventValue ( e )
SDL_Event *e
CODE:
RETVAL = e->jaxis.value;
OUTPUT:
RETVAL

Uint8
JoyButtonEventWhich ( e )
SDL_Event *e
CODE:
RETVAL = e->jbutton.which;
OUTPUT:
RETVAL

Uint8
JoyButtonEventButton ( e )
SDL_Event *e
CODE:
RETVAL = e->jbutton.button;
OUTPUT:
RETVAL

Uint8
JoyButtonEventState ( e )
SDL_Event *e
CODE:
RETVAL = e->jbutton.state;
OUTPUT:
RETVAL

Uint8
JoyHatEventWhich ( e )
SDL_Event *e
CODE:
RETVAL = e->jhat.which;
OUTPUT:
RETVAL

Uint8
JoyHatEventHat ( e )
SDL_Event *e
CODE:
RETVAL = e->jhat.hat;
OUTPUT:
RETVAL

Uint8
JoyHatEventValue ( e )
SDL_Event *e
CODE:
RETVAL = e->jhat.value;
OUTPUT:
RETVAL

Uint8
JoyBallEventWhich ( e )
SDL_Event *e
CODE:
RETVAL = e->jball.which;
OUTPUT:
RETVAL

Uint8
JoyBallEventBall ( e )
SDL_Event *e
CODE:
RETVAL = e->jball.ball;
OUTPUT:
RETVAL

Sint16
JoyBallEventXrel ( e )
SDL_Event *e
CODE:
RETVAL = e->jball.xrel;
OUTPUT:
RETVAL

Sint16
JoyBallEventYrel ( e )
SDL_Event *e
CODE:
RETVAL = e->jball.yrel;
OUTPUT:
RETVAL

#ifdef HAVE_SDL_NET

int
Expand Down

0 comments on commit f104313

Please sign in to comment.