#if defined(TARGET_SDL)
#if defined(TARGET_SDL2)
+ case SDL_CONTROLLERBUTTONDOWN:
+ case SDL_CONTROLLERBUTTONUP:
+ HandleSpecialGameControllerButtons(event);
+ /* FALL THROUGH */
case SDL_CONTROLLERDEVICEADDED:
case SDL_CONTROLLERDEVICEREMOVED:
case SDL_CONTROLLERAXISMOTION:
- case SDL_CONTROLLERBUTTONDOWN:
- case SDL_CONTROLLERBUTTONUP:
#endif
case SDL_JOYAXISMOTION:
case SDL_JOYBUTTONDOWN:
ClearPlayerAction();
break;
+#if defined(TARGET_SDL2)
+ case SDL_CONTROLLERBUTTONUP:
+ ClearPlayerAction();
+ break;
+#endif
+
default:
HandleOtherEvents(&event);
break;
key_joystick_mapping = 0;
break;
+#if defined(TARGET_SDL2)
+ case SDL_CONTROLLERBUTTONUP:
+ key_joystick_mapping = 0;
+ break;
+#endif
+
case EVENT_MAPNOTIFY:
window_unmapped = FALSE;
break;
return;
}
+ if (tape.recording && tape.pausing)
+ {
+ if (joystick & JOY_ACTION)
+ TapeTogglePause(TAPE_TOGGLE_MANUAL);
+ }
+
break;
default:
break;
}
}
+
+void HandleSpecialGameControllerButtons(Event *event)
+{
+#if defined(TARGET_SDL2)
+ switch (event->type)
+ {
+ case SDL_CONTROLLERBUTTONDOWN:
+ if (event->cbutton.button == SDL_CONTROLLER_BUTTON_START)
+ HandleKey(KSYM_space, KEY_PRESSED);
+ else if (event->cbutton.button == SDL_CONTROLLER_BUTTON_BACK)
+ HandleKey(KSYM_Escape, KEY_PRESSED);
+
+ break;
+
+ case SDL_CONTROLLERBUTTONUP:
+ if (event->cbutton.button == SDL_CONTROLLER_BUTTON_START)
+ HandleKey(KSYM_space, KEY_RELEASED);
+ else if (event->cbutton.button == SDL_CONTROLLER_BUTTON_BACK)
+ HandleKey(KSYM_Escape, KEY_RELEASED);
+
+ break;
+ }
+#endif
+}
ClearPlayerAction();
break;
+#if defined(TARGET_SDL2)
+ case SDL_CONTROLLERBUTTONDOWN:
+ switch (event.cbutton.button)
+ {
+ case SDL_CONTROLLER_BUTTON_A:
+ case SDL_CONTROLLER_BUTTON_X:
+ case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
+ result = 1;
+ break;
+
+ case SDL_CONTROLLER_BUTTON_B:
+ case SDL_CONTROLLER_BUTTON_Y:
+ case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER:
+ case SDL_CONTROLLER_BUTTON_BACK:
+ result = 0;
+ break;
+ }
+
+ if (req_state & REQ_PLAYER)
+ result = 0;
+
+ break;
+
+ case SDL_CONTROLLERBUTTONUP:
+ ClearPlayerAction();
+ break;
+#endif
+
default:
HandleOtherEvents(&event);
break;