diff --git a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp index 142ba1a1..86e0de37 100644 --- a/src/gui/sdl_mapper.cpp +++ b/src/gui/sdl_mapper.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: sdl_mapper.cpp,v 1.35 2007-06-14 18:47:27 qbix79 Exp $ */ +/* $Id: sdl_mapper.cpp,v 1.36 2007-07-05 17:49:40 qbix79 Exp $ */ #include #include @@ -64,6 +64,8 @@ enum BC_Types { #define MAXSTICKS 8 #define MAXACTIVE 16 +#define MAXBUTTON 32 +#define MAXBUTTON_CAP 16 class CEvent; class CHandlerEvent; @@ -600,23 +602,25 @@ public: if (_dummy) { sdl_joystick=NULL; axes=0; buttons=0; hats=0; - button_wrap=16; + button_wrap=0; + button_cap=0; axes_cap=0; hats_cap=0; return; } // initialize emulated joystick state emulated_axes=2; emulated_buttons=2; + emulated_hats=0; pos_axis_lists=new CBindList[4]; neg_axis_lists=new CBindList[4]; - button_lists=new CBindList[16]; + button_lists=new CBindList[MAXBUTTON]; hat_lists=new CBindList[4]; Bitu i; - for (i=0; i<16; i++) { + for (i=0; i16) button_wrap=16; - LOG_MSG("Using joystick %s with %d axes and %d buttons",SDL_JoystickName(stick),axes,buttons); + button_cap=buttons; + if (button_wrapping_enabled) { + button_wrap=emulated_buttons; + 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>axes) hats_cap=hats; + LOG_MSG("Using joystick %s with %d axes, %d buttons and %d hat(s)",SDL_JoystickName(stick),axes,buttons,hats); } ~CStickBindGroup() { SDL_JoystickClose(sdl_joystick); @@ -724,9 +737,9 @@ public: /* query SDL joystick and activate bindings */ ActivateJoystickBoundEvents(); - bool button_pressed[16]; + bool button_pressed[MAXBUTTON]; Bitu i; - for (i=0; i<16; i++) button_pressed[i]=false; + for (i=0; i1) { @@ -795,7 +808,7 @@ public: } } - for (i=0; iaxes) axes_cap=axes; + hats_cap=emulated_hats; + if (hats_cap>axes) hats_cap=hats; + JOYSTICK_Enable(1,true); } @@ -907,9 +927,9 @@ public: /* query SDL joystick and activate bindings */ ActivateJoystickBoundEvents(); - bool button_pressed[16]; + bool button_pressed[MAXBUTTON]; Bitu i; - for (i=0; i<16; i++) button_pressed[i]=false; + for (i=0; iaxes) axes_cap=axes; + hats_cap=emulated_hats; + if (hats_cap>axes) hats_cap=hats; + JOYSTICK_Enable(1,true); JOYSTICK_Move_Y(1,1.0); } @@ -980,9 +1007,9 @@ public: /* query SDL joystick and activate bindings */ ActivateJoystickBoundEvents(); - bool button_pressed[16]; + bool button_pressed[MAXBUTTON]; Bitu i; - for (i=0; i<16; i++) button_pressed[i]=false; + for (i=0; iaxes) axes_cap=axes; + hats_cap=emulated_hats; + if (hats_cap>axes) hats_cap=hats; + JOYSTICK_Enable(1,true); button_state=0; } @@ -1159,8 +1193,8 @@ public: if (bt_state>hat_priority[i][3]) bt_state=hat_priority[i][3]; } - bool button_pressed[6]; - for (i=0; i<6; i++) button_pressed[i]=false; + bool button_pressed[MAXBUTTON]; + for (i=0; i