diff --git a/source/blood/src/_functio.h b/source/blood/src/_functio.h index 6abff9b450..c726e14f72 100644 --- a/source/blood/src/_functio.h +++ b/source/blood/src/_functio.h @@ -356,6 +356,15 @@ static const int32_t joystickanalogdeaddefaults[MAXJOYAXES] = }; +static const int32_t joystickanalogaxissolodeadzone[MAXJOYAXES] = + { + 1, + 0, + 0, + 0, + }; + + static const int32_t joystickanalogsaturatedefaults[MAXJOYAXES] = { DEFAULTJOYSTICKANALOGUESATURATE*3, diff --git a/source/blood/src/config.cpp b/source/blood/src/config.cpp index 1a5382f520..adf107b57a 100644 --- a/source/blood/src/config.cpp +++ b/source/blood/src/config.cpp @@ -65,6 +65,7 @@ int32_t JoystickAnalogueScale[MAXJOYAXES]; int32_t JoystickAnalogueDead[MAXJOYAXES]; int32_t JoystickAnalogueSaturate[MAXJOYAXES]; int32_t JoystickAnalogueInvert[MAXJOYAXES]; +int32_t JoystickAnalogueAxisSoloDeadZone[MAXJOYAXES]; uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2]; int32_t scripthandle; int32_t setupread; @@ -481,6 +482,9 @@ void CONFIG_SetDefaults(void) JoystickAnalogueInvert[i] = 0; CONTROL_SetAnalogAxisInvert(i, JoystickAnalogueInvert[i]); + + JoystickAnalogueAxisSoloDeadZone[i] = 0; + JOYSTICK_SetAxisSoloDeadZone(i, JoystickAnalogueAxisSoloDeadZone[i]); } #else for (int i=0; inValue = JoystickAnalogueDead[nAxis]; pItemOptionsControlJoystickAxisSaturate[nAxis]->nValue = JoystickAnalogueSaturate[nAxis]; + pItemOptionsControlJoystickAxisSoloDeadzone[nAxis]->at20 = JoystickAnalogueAxisSoloDeadZone[nAxis]; } } @@ -2526,6 +2533,19 @@ void SetJoystickSaturate(CGameMenuItemSlider* pItem) } } +void SetJoystickSoloDeadzone(CGameMenuItemZBool* pItem) +{ + for (int nAxis = 0; nAxis < MAXJOYAXES; nAxis++) + { + if (pItem == pItemOptionsControlJoystickAxisSoloDeadzone[nAxis]) + { + JoystickAnalogueAxisSoloDeadZone[nAxis] = pItem->at20; + JOYSTICK_SetAxisSoloDeadZone(nAxis, JoystickAnalogueAxisSoloDeadZone[nAxis]); + break; + } + } +} + void PreDrawControlMouse(CGameMenuItem *pItem) { if (pItem == &itemOptionsControlMouseVerticalAim) diff --git a/source/mact/include/_control.h b/source/mact/include/_control.h index e43c2c931c..e4ab903458 100644 --- a/source/mact/include/_control.h +++ b/source/mact/include/_control.h @@ -126,6 +126,7 @@ typedef struct ControllerAxis uint16_t deadzone; uint16_t saturation; bool invert; + bool solodeadzone; } ControllerAxis_t; typedef struct UserInputState diff --git a/source/mact/include/joystick.h b/source/mact/include/joystick.h index 671a6b3c7e..42d84fcd9b 100644 --- a/source/mact/include/joystick.h +++ b/source/mact/include/joystick.h @@ -54,6 +54,7 @@ int32_t JOYSTICK_GetControllerButtons( void ); void JOYSTICK_ClearAllButtons( void ); int32_t JOYSTICK_GetHat( int32_t h ); void JOYSTICK_SetDeadZone(int32_t axis, uint16_t dead, uint16_t satur); +void JOYSTICK_SetAxisSoloDeadZone(int32_t axis, bool dead); #ifdef __cplusplus } diff --git a/source/mact/src/control.cpp b/source/mact/src/control.cpp index bf31ced274..3cfaeb4b96 100644 --- a/source/mact/src/control.cpp +++ b/source/mact/src/control.cpp @@ -267,6 +267,11 @@ void JOYSTICK_SetDeadZone(int32_t axis, uint16_t dead, uint16_t satur) joyAxes[axis].saturation = satur; } +void JOYSTICK_SetAxisSoloDeadZone(int32_t axis, bool dead) +{ + joyAxes[axis].solodeadzone = dead; +} + void CONTROL_SetAnalogAxisScale(int32_t whichaxis, int32_t axisscale, controldevice device) { float *set; @@ -488,7 +493,7 @@ static void controlUpdateAxisState(int index, ControlInfo *const info) else { // this assumes there are two sticks comprised of axes 0 and 1, and 2 and 3... because when isGameController is true, there are - if (index <= CONTROLLER_AXIS_LEFTY || (joystick.isGameController && (index <= CONTROLLER_AXIS_RIGHTY))) + if (!a.solodeadzone && (index <= CONTROLLER_AXIS_LEFTY || (joystick.isGameController && (index <= CONTROLLER_AXIS_RIGHTY)))) axisScaled10k = min(10000, joydist(joystick.pAxis[index & ~1], joystick.pAxis[index | 1]) * 10000 / 32767); if (axisScaled10k < a.deadzone)