1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
From: Richard Goedeken <Richard@fascinationsoftware.com>
Date: Wed, 3 Jun 2015 22:52:45 -0700
Subject: fix joystick-mapped Core events under SDL2
Origin: upstream, https://github.com/mupen64plus/mupen64plus-core/commit/31a41822c452fcceb644c165055d84166a448d4e.patch
---
src/main/eventloop.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/main/eventloop.c b/src/main/eventloop.c
index f98d97d..934a807 100644
--- a/src/main/eventloop.c
+++ b/src/main/eventloop.c
@@ -57,6 +57,8 @@
#define SDL_SetEventFilter(func, data) SDL_SetEventFilter(func)
#define event_sdl_filter(userdata, event) event_sdl_filter(const event)
+#else
+ SDL_JoystickID l_iJoyInstanceID[10];
#endif
#define M64P_CORE_PROTOTYPES 1
@@ -161,6 +163,9 @@ static int MatchJoyCommand(const SDL_Event *event, eJoyCommand cmd)
return 0;
if (sscanf(event_str, "J%dA%d%c", &dev_number, &input_number, &axis_direction) != 3)
return 0;
+#if SDL_VERSION_ATLEAST(2,0,0)
+ dev_number = l_iJoyInstanceID[dev_number];
+#endif
if (dev_number != event->jaxis.which || input_number != event->jaxis.axis)
return 0;
if (axis_direction == '+')
@@ -199,6 +204,9 @@ static int MatchJoyCommand(const SDL_Event *event, eJoyCommand cmd)
return 0;
if (sscanf(event_str, "J%dH%dV%d", &dev_number, &input_number, &input_value) != 3)
return 0;
+#if SDL_VERSION_ATLEAST(2,0,0)
+ dev_number = l_iJoyInstanceID[dev_number];
+#endif
if (dev_number != event->jhat.which || input_number != event->jhat.hat)
return 0;
if ((event->jhat.value & input_value) == input_value && JoyCmdActive[cmd] == 0)
@@ -219,6 +227,9 @@ static int MatchJoyCommand(const SDL_Event *event, eJoyCommand cmd)
return 0;
if (sscanf(event_str, "J%dB%d", &dev_number, &input_number) != 2)
return 0;
+#if SDL_VERSION_ATLEAST(2,0,0)
+ dev_number = l_iJoyInstanceID[dev_number];
+#endif
if (dev_number != event->jbutton.which || input_number != event->jbutton.button)
return 0;
if (event->type == SDL_JOYBUTTONDOWN && JoyCmdActive[cmd] == 0)
@@ -368,7 +379,8 @@ void event_initialize(void)
if (!SDL_WasInit(SDL_INIT_JOYSTICK))
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
#if SDL_VERSION_ATLEAST(2,0,0)
- SDL_JoystickOpen(device);
+ SDL_Joystick *thisJoy = SDL_JoystickOpen(device);
+ l_iJoyInstanceID[device] = SDL_JoystickInstanceID(thisJoy);
#else
if (!SDL_JoystickOpened(device))
SDL_JoystickOpen(device);
|