@@ -516,32 +516,30 @@ bool handle_events(SDL_Renderer* renderer, SDL_Event* event)
516516 {
517517 return false;
518518 }
519- #ifndef __SYMBIAN32__
520- case SDL_EVENT_JOYSTICK_ADDED :
519+ case SDL_EVENT_GAMEPAD_ADDED :
521520 {
522- const SDL_JoystickID which = event -> jdevice .which ;
523- SDL_Joystick * joystick = SDL_OpenJoystick (which );
524- if (!joystick )
521+ const SDL_JoystickID which = event -> gdevice .which ;
522+ SDL_Gamepad * gamepad = SDL_OpenGamepad (which );
523+ if (!gamepad )
525524 {
526- SDL_Log ("Joystick #%u could not be opened: %s" , ( unsigned int ) which , SDL_GetError ());
525+ SDL_Log ("Joystick #%" SDL_PRIu32 " could not be opened: %s" , which , SDL_GetError ());
527526 }
528527 else
529528 {
530- SDL_Log ("Joystick #%u connected: %s" , ( unsigned int ) which , SDL_GetJoystickName ( joystick ));
529+ SDL_Log ("Joystick #%" SDL_PRIu32 " connected: %s" , which , SDL_GetGamepadName ( gamepad ));
531530 }
532531 return true;
533532 }
534- case SDL_EVENT_JOYSTICK_REMOVED :
533+ case SDL_EVENT_GAMEPAD_REMOVED :
535534 {
536- const SDL_JoystickID which = event -> jdevice .which ;
537- SDL_Joystick * joystick = SDL_GetJoystickFromID (which );
538- if (joystick )
535+ const SDL_JoystickID which = event -> gdevice .which ;
536+ SDL_Gamepad * gamepad = SDL_GetGamepadFromID (which );
537+ if (gamepad )
539538 {
540- SDL_CloseJoystick ( joystick ); /* the joystick was unplugged. */
539+ SDL_CloseGamepad ( gamepad ); /* the joystick was unplugged. */
541540 }
542541 return true;
543542 }
544- #endif
545543 case SDL_EVENT_KEY_DOWN :
546544 {
547545 if (state == STATE_MENU )
@@ -593,34 +591,33 @@ bool handle_events(SDL_Renderer* renderer, SDL_Event* event)
593591 }
594592 break ;
595593 }
596- #ifndef __SYMBIAN32__
597- case SDL_EVENT_JOYSTICK_BUTTON_DOWN :
594+ case SDL_EVENT_GAMEPAD_BUTTON_DOWN :
598595 {
599- const SDL_JoystickID which = event -> jbutton .which ;
600- SDL_Log ("Joystick #%u button %d -> %s" , ( unsigned int ) which , ( int ) event -> jbutton .button , event -> jbutton .down ? "PRESSED" : "RELEASED" );
596+ const SDL_JoystickID which = event -> gbutton .which ;
597+ SDL_Log ("Gamepad #%" SDL_PRIu32 " button %s -> %s" , which , SDL_GetGamepadStringForButton ( event -> gbutton .button ) , event -> gbutton .down ? "PRESSED" : "RELEASED" );
601598
602599 if (state == STATE_MENU )
603600 {
604- switch (event -> jbutton .button )
601+ switch (event -> gbutton .button )
605602 {
606- case 4 :
603+ case SDL_GAMEPAD_BUTTON_DPAD_LEFT :
607604 select_prev_cartridge (renderer );
608605 render_cartridge (renderer );
609606 return true;
610- case 5 :
607+ case SDL_GAMEPAD_BUTTON_DPAD_RIGHT :
611608 select_next_cartridge (renderer );
612609 render_cartridge (renderer );
613610 return true;
614- case 0 :
611+ case SDL_GAMEPAD_BUTTON_EAST : // TODO: A / Circle
615612 run_cartridge (renderer );
616613 return true;
617614 }
618615 }
619616 else if (state == STATE_EMULATOR )
620617 {
621- switch (event -> jbutton .button )
618+ switch (event -> gbutton .button )
622619 {
623- case 1 :
620+ case SDL_GAMEPAD_BUTTON_SOUTH : // TODO: B / Cross
624621 destroy_vm ();
625622 init_vm (renderer );
626623 reset_memory ();
@@ -630,7 +627,6 @@ bool handle_events(SDL_Renderer* renderer, SDL_Event* event)
630627 }
631628 break ;
632629 }
633- #endif
634630 }
635631 return true;
636632}
0 commit comments