From 15082ba4ab18a07044018adbdc06dd7a734280da Mon Sep 17 00:00:00 2001 From: Joshua Kraemer Date: Sun, 15 Sep 2019 20:29:45 +0200 Subject: [PATCH] dosbox: patch to support full mapping of joysticks --- .../patches/fully-mappable-joystick.patch | 125 ++++++++++++++++++ srcpkgs/dosbox/template | 2 +- 2 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/dosbox/patches/fully-mappable-joystick.patch diff --git a/srcpkgs/dosbox/patches/fully-mappable-joystick.patch b/srcpkgs/dosbox/patches/fully-mappable-joystick.patch new file mode 100644 index 00000000000..ae4e40e3daa --- /dev/null +++ b/srcpkgs/dosbox/patches/fully-mappable-joystick.patch @@ -0,0 +1,125 @@ +This patch by cfoesch allows mapping of up to 8 axes and 2 hat switches. +The emulated joystick remains unchanged. +Discussion: https://www.vogons.org/viewtopic.php?t=27452 + +--- src/gui/sdl_mapper.cpp 2010-10-30 05:10:05.000000000 -0600 ++++ src/gui/sdl_mapper.cpp 2011-02-14 09:29:43.251163300 -0700 +@@ -68,6 +68,8 @@ + #define MAXACTIVE 16 + #define MAXBUTTON 32 + #define MAXBUTTON_CAP 16 ++#define MAXAXIS 8 ++#define MAXHAT 2 + + class CEvent; + class CHandlerEvent; +@@ -521,10 +523,11 @@ + }; + + #define MAX_VJOY_BUTTONS 8 ++#define MAX_VJOY_AXES 8 + + static struct { + bool button_pressed[MAX_VJOY_BUTTONS]; +- Bit16s axis_pos[8]; ++ Bit16s axis_pos[MAX_VJOY_AXES]; + bool hat_pressed[16]; + } virtual_joysticks[2]; + +@@ -615,8 +618,8 @@ + if (_dummy) return; + + // initialize binding lists and position data +- pos_axis_lists=new CBindList[4]; +- neg_axis_lists=new CBindList[4]; ++ pos_axis_lists=new CBindList[MAXAXIS]; ++ neg_axis_lists=new CBindList[MAXAXIS]; + button_lists=new CBindList[MAXBUTTON]; + hat_lists=new CBindList[4]; + Bitu i; +@@ -625,7 +628,7 @@ + old_button_state[i]=0; + } + for(i=0;i<16;i++) old_hat_state[i]=0; +- for (i=0; i<4; i++) { ++ for (i=0; i MAXAXIS) axes = MAXAXIS; ++ axes_cap=emulated_axes; ++ if (axes_cap>axes) axes_cap=axes; ++ + hats=SDL_JoystickNumHats(sdl_joystick); ++ if (hats > MAXHAT) hats = MAXHAT; ++ hats_cap=emulated_hats; ++ if (hats_cap>hats) hats_cap=hats; ++ ++ buttons=SDL_JoystickNumButtons(sdl_joystick); + button_wrap=buttons; + button_cap=buttons; + if (button_wrapping_enabled) { +@@ -652,10 +663,7 @@ + if (buttons>MAXBUTTON_CAP) button_cap = MAXBUTTON_CAP; + } + if (button_wrap > MAXBUTTON) button_wrap = MAXBUTTON; +- axes_cap=emulated_axes; +- if (axes_cap>axes) axes_cap=axes; +- hats_cap=emulated_hats; +- if (hats_cap>hats) hats_cap=hats; ++ + LOG_MSG("Using joystick %s with %d axes, %d buttons and %d hat(s)",SDL_JoystickName(stick),axes,buttons,hats); + } + ~CStickBindGroup() { +@@ -688,7 +696,7 @@ + if (event->type==SDL_JOYAXISMOTION) { + if (event->jaxis.which!=stick) return 0; + #if defined (REDUCE_JOYSTICK_POLLING) +- if (event->jaxis.axis>=emulated_axes) return 0; ++ if (event->jaxis.axis>=axes) return 0; + #endif + if (abs(event->jaxis.value)<25000) return 0; + return CreateAxisBind(event->jaxis.axis,event->jaxis.value>0); +@@ -780,7 +788,7 @@ + } + } + +- for (i=0; i1) { +@@ -812,7 +820,7 @@ + } + } + +- for (i=0; i