From c392dcfc90cf08f50c3a51c2896217f7b85df501 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 22 Feb 2007 08:44:07 +0000 Subject: [PATCH] Add new option: buttonwrap. For people who like to map a lot of keys to their joystick. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2817 --- include/joystick.h | 3 ++- src/dosbox.cpp | 8 +++++--- src/gui/sdl_mapper.cpp | 28 +++++++++++++++++----------- src/hardware/joystick.cpp | 4 +++- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/include/joystick.h b/include/joystick.h index 0afef907..d590250f 100644 --- a/include/joystick.h +++ b/include/joystick.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: joystick.h,v 1.10 2007-01-10 15:00:38 c2woody Exp $ */ +/* $Id: joystick.h,v 1.11 2007-02-22 08:44:06 qbix79 Exp $ */ #ifndef DOSBOX_JOYSTICK_H #define DOSBOX_JOYSTICK_H void JOYSTICK_Enable(Bitu which,bool enabled); @@ -45,4 +45,5 @@ enum JoystickType { }; extern JoystickType joytype; +extern bool button_wrapping_enabled; #endif diff --git a/src/dosbox.cpp b/src/dosbox.cpp index 8a3e7f0e..ced21783 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dosbox.cpp,v 1.114 2007-02-04 11:10:22 qbix79 Exp $ */ +/* $Id: dosbox.cpp,v 1.115 2007-02-22 08:44:06 qbix79 Exp $ */ #include #include @@ -311,14 +311,14 @@ void DOSBOX_Init(void) { secprop->Add_int("cycleup",500); secprop->Add_int("cycledown",20); MSG_Add("CPU_CONFIGFILE_HELP", - "core -- CPU Core used in emulation: normal" + "core -- CPU Core used in emulation: normal,simple" #if (C_DYNAMIC_X86) ",dynamic,auto.\n" " auto switches from normal to dynamic if appropriate" #endif ".\n" "cycles -- Amount of instructions dosbox tries to emulate each millisecond.\n" - " Setting this higher than your machine can handle is bad!\n" + " Setting this value too high results in sound dropouts and lags.\n" " You can also let DOSBox guess the correct value by setting it to max.\n" " The default setting (auto) switches to max if appropriate.\n" "cycleup -- Amount of cycles to increase/decrease with keycombo.\n" @@ -433,6 +433,7 @@ void DOSBOX_Init(void) { "timed -- enable timed intervals for axis. (false is old style behaviour).\n" "autofire -- continuously fires as long as you keep the button pressed.\n" "swap34 -- swap the 3rd and the 4th axis. can be useful for certain joysticks.\n" + "buttonwrap -- enable button wrapping at the number of emulated buttons.\n" ); secprop->AddInitFunction(&INT10_Init); @@ -442,6 +443,7 @@ void DOSBOX_Init(void) { secprop->Add_bool("timed",true); secprop->Add_bool("autofire",false); secprop->Add_bool("swap34",false); + secprop->Add_bool("buttonwrap",true); // had to rename these to serial due to conflicts in config secprop=control->AddSection_prop("serial",&SERIAL_Init,true); diff --git a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp index f915de2c..58b7da48 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.31 2007-01-11 09:51:37 qbix79 Exp $ */ +/* $Id: sdl_mapper.cpp,v 1.32 2007-02-22 08:44:07 qbix79 Exp $ */ #include #include @@ -608,7 +608,7 @@ public: emulated_buttons=2; pos_axis_lists=new CBindList[4]; neg_axis_lists=new CBindList[4]; - button_lists=new CBindList[6]; + button_lists=new CBindList[16]; hat_lists=new CBindList[4]; Bitu i; for (i=0; i<16; i++) { @@ -634,6 +634,9 @@ public: axes=SDL_JoystickNumAxes(sdl_joystick); buttons=SDL_JoystickNumButtons(sdl_joystick); hats=SDL_JoystickNumHats(sdl_joystick); + button_wrap=buttons; + if (button_wrapping_enabled) button_wrap=emulated_buttons; + if (button_wrap>16) button_wrap=16; LOG_MSG("Using joystick %s with %d axes and %d buttons",SDL_JoystickName(stick),axes,buttons); } ~CStickBindGroup() { @@ -673,7 +676,7 @@ public: } else if (event->type==SDL_JOYBUTTONDOWN) { if (event->button.which!=stick) return 0; #if defined (REDUCE_JOYSTICK_POLLING) - return CreateButtonBind(event->jbutton.button%emulated_buttons); + return CreateButtonBind(event->jbutton.button%button_wrap); #else return CreateButtonBind(event->jbutton.button); #endif @@ -724,7 +727,7 @@ public: for (i=0; i<16; i++) button_pressed[i]=false; for (i=0; i #include "dosbox.h" @@ -47,6 +47,7 @@ static JoyStick stick[2]; static Bit32u last_write = 0; static bool write_active = false; static bool swap34 = false; +bool button_wrapping_enabled = true; extern bool autofire; //sdl_mapper.cpp @@ -214,6 +215,7 @@ public: } autofire = section->Get_bool("autofire"); swap34 = section->Get_bool("swap34"); + button_wrapping_enabled = section->Get_bool("buttonwrap"); stick[0].enabled = false; stick[1].enabled = false; stick[0].xtick = stick[0].ytick = stick[1].xtick =