diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2014-04-08 02:33:19 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2014-04-08 02:33:19 +0000 |
| commit | c875a3566e340e366553beb2dcd6b2bcf4d5ab18 (patch) | |
| tree | 97dcfbe538af5f282135a27cf889ed32b1d9d54d /plugins/dfinput/pad.c | |
| parent | 0d4ea9238b154a30e8713c7d00d7b6d1b0050d5c (diff) | |
| download | pcsxr-c875a3566e340e366553beb2dcd6b2bcf4d5ab18.tar.gz | |
DFInput: Implement SDL2 GameController support.
This change allows the user to use SDL2’s GameController API instead of the Joystick API.
The Game Controller API maps the buttons similar to an Xbox 360 controller, so some tricky mapping needed to be done.
Note that it currently only supports OS X.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@89828 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins/dfinput/pad.c')
| -rwxr-xr-x | plugins/dfinput/pad.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c index c0f72657..ba4ec0ab 100755 --- a/plugins/dfinput/pad.c +++ b/plugins/dfinput/pad.c @@ -25,6 +25,27 @@ #if SDL_VERSION_ATLEAST(2,0,0) int has_haptic; + +SDL_GameControllerButton controllerMap[] = { + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_DPAD_UP, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + SDL_CONTROLLER_BUTTON_INVALID, //SDL2 doesn't map the bumpers to buttons, but axies + SDL_CONTROLLER_BUTTON_INVALID, //The bumpers are analogous to L2 and R2 + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_B, + SDL_CONTROLLER_BUTTON_A, + SDL_CONTROLLER_BUTTON_X, + + SDL_CONTROLLER_BUTTON_GUIDE +}; #endif static void (*gpuVisualVibration)(uint32_t, uint32_t) = NULL; @@ -100,6 +121,8 @@ long PADopen(unsigned long *Disp) { } #if SDL_VERSION_ATLEAST(2,0,0) + SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER); + has_haptic = 0; if (SDL_InitSubSystem(SDL_INIT_HAPTIC) == 0) has_haptic = 1; @@ -135,14 +158,16 @@ long PADclose(void) { DestroySDLJoy(); DestroyKeyboard(); #if SDL_VERSION_ATLEAST(2,0,0) - if (SDL_WasInit(SDL_INIT_EVERYTHING & ~(SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK))) { + if (SDL_WasInit(SDL_INIT_EVERYTHING & ~(SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER))) { SDL_QuitSubSystem(SDL_INIT_HAPTIC); SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - } else -#endif + SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); + } else { +#else if (SDL_WasInit(SDL_INIT_EVERYTHING & ~SDL_INIT_JOYSTICK)) { SDL_QuitSubSystem(SDL_INIT_JOYSTICK); } else { +#endif SDL_Quit(); } } |
