1
0
Fork 0

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
This commit is contained in:
Peter Veenstra 2007-02-22 08:44:07 +00:00
parent cfa3a9d466
commit c392dcfc90
4 changed files with 27 additions and 16 deletions

View file

@ -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

View file

@ -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 <stdlib.h>
#include <stdarg.h>
@ -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);

View file

@ -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 <vector>
#include <list>
@ -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<MAX_VJOY_BUTTONS; i++) {
if (virtual_joysticks[emustick].button_pressed[i])
button_pressed[i % emulated_buttons]=true;
button_pressed[i % button_wrap]=true;
}
for (i=0; i<emulated_buttons; i++) {
if (autofire && (button_pressed[i]))
@ -747,9 +750,9 @@ public:
/* read button states */
for (i=0; i<buttons; i++) {
if (SDL_JoystickGetButton(sdl_joystick,i))
button_pressed[i % emulated_buttons]=true;
button_pressed[i % button_wrap]=true;
}
for (i=0; i<emulated_buttons; i++) {
for (i=0; i<button_wrap; i++) {
/* activate binding if button state has changed */
if (button_pressed[i]!=old_button_state[i]) {
if (button_pressed[i]) ActivateBindList(&button_lists[i],32767,true);
@ -802,7 +805,7 @@ private:
return NULL;
}
CBind * CreateButtonBind(Bitu button) {
if (button<emulated_buttons)
if (button<button_wrap)
return new CJButtonBind(&button_lists[button],this,button);
return NULL;
}
@ -828,7 +831,7 @@ protected:
CBindList * neg_axis_lists;
CBindList * button_lists;
CBindList * hat_lists;
Bitu stick,emustick,axes,buttons,hats,emulated_axes,emulated_buttons;
Bitu stick,emustick,axes,buttons,hats,emulated_axes,emulated_buttons,button_wrap;
SDL_Joystick * sdl_joystick;
char configname[10];
Bitu button_autofire[16];
@ -844,6 +847,7 @@ public:
C4AxisBindGroup(Bitu _stick) : CStickBindGroup (_stick){
emulated_axes=4;
emulated_buttons=4;
if (button_wrapping_enabled) button_wrap=emulated_buttons;
JOYSTICK_Enable(1,true);
}
@ -885,7 +889,7 @@ public:
for (i=0; i<16; i++) button_pressed[i]=false;
for (i=0; i<MAX_VJOY_BUTTONS; i++) {
if (virtual_joysticks[0].button_pressed[i])
button_pressed[i % emulated_buttons]=true;
button_pressed[i % button_wrap]=true;
}
for (i=0; i<emulated_buttons; i++) {
@ -908,6 +912,7 @@ public:
emulated_axes=4;
emulated_buttons=4;
old_hat_position=0;
if (button_wrapping_enabled) button_wrap=emulated_buttons;
JOYSTICK_Enable(1,true);
JOYSTICK_Move_Y(1,1.0);
}
@ -957,7 +962,7 @@ public:
for (i=0; i<16; i++) button_pressed[i]=false;
for (i=0; i<MAX_VJOY_BUTTONS; i++) {
if (virtual_joysticks[0].button_pressed[i])
button_pressed[i % emulated_buttons]=true;
button_pressed[i % button_wrap]=true;
}
for (i=0; i<emulated_buttons; i++) {
@ -1036,6 +1041,7 @@ public:
CCHBindGroup(Bitu _stick) : CStickBindGroup (_stick){
emulated_axes=4;
emulated_buttons=6;
if (button_wrapping_enabled) button_wrap=emulated_buttons;
JOYSTICK_Enable(1,true);
button_state=0;
}
@ -1134,7 +1140,7 @@ public:
for (i=0; i<6; i++) button_pressed[i]=false;
for (i=0; i<MAX_VJOY_BUTTONS; i++) {
if (virtual_joysticks[0].button_pressed[i])
button_pressed[i % emulated_buttons]=true;
button_pressed[i % button_wrap]=true;
}
for (i=0; i<6; i++) {

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: joystick.cpp,v 1.17 2007-01-11 09:51:37 qbix79 Exp $ */
/* $Id: joystick.cpp,v 1.18 2007-02-22 08:44:07 qbix79 Exp $ */
#include <string.h>
#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 =