Browse Source

joystick set up

main
h3ndrik 13 years ago
parent
commit
cea708e024
  1. BIN
      sdljpd
  2. 14
      sdljpd.c
  3. 15
      sdljpd.c~

BIN
sdljpd

Binary file not shown.

14
sdljpd.c

@ -110,6 +110,8 @@ SDL_Color color={255,125,0};
TTF_Font *font; TTF_Font *font;
SDL_Joystick *joystick;
/** \brief Hier Raeumen wir nach Programablauf auf. /** \brief Hier Raeumen wir nach Programablauf auf.
* *
* \param returnCode Der Zurueckzugebende Return Code * \param returnCode Der Zurueckzugebende Return Code
@ -122,6 +124,8 @@ void Quit( int returnCode )
Mix_FreeMusic(music); Mix_FreeMusic(music);
music = NULL; music = NULL;
SDL_JoystickClose(joystick);
SDL_FreeSurface(panel); SDL_FreeSurface(panel);
SDL_FreeSurface(text); SDL_FreeSurface(text);
SDL_FreeSurface(afr); SDL_FreeSurface(afr);
@ -627,7 +631,7 @@ int main( int argc, char **argv )
/* sprintf(wmcapt,"glpong - %s vs ", player_a );*/ /* sprintf(wmcapt,"glpong - %s vs ", player_a );*/
/* initialize SDL */ /* initialize SDL */
if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ) if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0 )
{ {
fprintf( stderr, "Video initialization failed: %s\n", fprintf( stderr, "Video initialization failed: %s\n",
SDL_GetError( ) ); SDL_GetError( ) );
@ -653,6 +657,14 @@ int main( int argc, char **argv )
Quit( 1 ); Quit( 1 );
} }
if(joystick = SDL_JoystickOpen (0) == NULL) {
printf("Unable to open joystick!\n");
exit(1);
}
SDL_JoystickEventState ( SDL_QUERY );
SDL_WM_SetCaption(wmcapt, NULL); SDL_WM_SetCaption(wmcapt, NULL);
/*SDL_WM_SetIcon(SDL_LoadBMP("glpong.bmp"),NULL);*/ /*SDL_WM_SetIcon(SDL_LoadBMP("glpong.bmp"),NULL);*/

15
sdljpd.c~

@ -110,6 +110,8 @@ SDL_Color color={255,125,0};
TTF_Font *font; TTF_Font *font;
SDL_Joystick *joystick;
/** \brief Hier Raeumen wir nach Programablauf auf. /** \brief Hier Raeumen wir nach Programablauf auf.
* *
* \param returnCode Der Zurueckzugebende Return Code * \param returnCode Der Zurueckzugebende Return Code
@ -122,6 +124,8 @@ void Quit( int returnCode )
Mix_FreeMusic(music); Mix_FreeMusic(music);
music = NULL; music = NULL;
SDL_JoystickClose(joystick);
SDL_FreeSurface(panel); SDL_FreeSurface(panel);
SDL_FreeSurface(text); SDL_FreeSurface(text);
SDL_FreeSurface(afr); SDL_FreeSurface(afr);
@ -627,7 +631,7 @@ int main( int argc, char **argv )
/* sprintf(wmcapt,"glpong - %s vs ", player_a );*/ /* sprintf(wmcapt,"glpong - %s vs ", player_a );*/
/* initialize SDL */ /* initialize SDL */
if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ) if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0 )
{ {
fprintf( stderr, "Video initialization failed: %s\n", fprintf( stderr, "Video initialization failed: %s\n",
SDL_GetError( ) ); SDL_GetError( ) );
@ -653,6 +657,15 @@ int main( int argc, char **argv )
Quit( 1 ); Quit( 1 );
} }
if(joystick = SDL_JoystickOpen (0) == NULL) {
printf("Unable to open joystick!\n");
exit(1);
}
/*
//SDL_JoystickEventState (SDL_ENABLE);
// this will alter the behaviour of the event queue of the sdl system
SDL_JoystickEventState ( SDL_QUERY );
*/
SDL_WM_SetCaption(wmcapt, NULL); SDL_WM_SetCaption(wmcapt, NULL);
/*SDL_WM_SetIcon(SDL_LoadBMP("glpong.bmp"),NULL);*/ /*SDL_WM_SetIcon(SDL_LoadBMP("glpong.bmp"),NULL);*/

Loading…
Cancel
Save