diff --git a/dist/idac/segatools.ini b/dist/idac/segatools.ini index ce5fc8a..0994d84 100644 --- a/dist/idac/segatools.ini +++ b/dist/idac/segatools.ini @@ -96,6 +96,11 @@ autoNeutral=1 singleStickSteering=1 ; Use linear steering instead of the default non-linear cubing steering. linearSteering=0 +; Configure deadzones for the left and right thumbsticks. +; The default value for the left stick is 7849, max value is 32767. +leftStickDeadzone=7849 +; The default value for the right stick is 8689, max value is 32767. +rightStickDeadzone=8689 ; Adjust scaling for steering wheel input. ; ; This setting scales the steering wheel input so that the maximum positive @@ -111,7 +116,7 @@ restrict=128 [dinput] ; Name of the DirectInput wheel to use (or any text that occurs in its name) -; Example: TMX +; Example: G29 ; ; If this is left blank then the first DirectInput device will be used. deviceName= @@ -122,30 +127,30 @@ deviceName= ; ; Can be the same device as the wheel. ; -; Example: T500 +; Example: G29 shifterName= ; Pedal mappings. Valid axis names are: ; ; X, Y, Z, RX, RY, RZ, U, V ; ; (U and V are old names for Slider 1 and Slider 2). -; The examples below are valid for a Thrustmaster TMX. +; The examples below are valid for a Logitech G29. brakeAxis=RZ accelAxis=Y ; DirectInput button numbers to map to menu inputs. Note that buttons are ; numbered from 1; some software numbers buttons from 0. -start=3 -viewChg=10 +start=1 +viewChg=2 ; Button mappings for the simulated six-speed shifter. -shiftDn=1 -shiftUp=2 +shiftDn=5 +shiftUp=6 ; Button mappings for the positional shifter, if present. -gear1=1 -gear2=2 -gear3=3 -gear4=4 -gear5=5 -gear6=6 +gear1=13 +gear2=14 +gear3=15 +gear4=16 +gear5=17 +gear6=18 ; Invert the accelerator and or brake axis ; (Needed when using DirectInput for the Dualshock 4 for example) reverseAccelAxis=0 diff --git a/dist/idz/segatools.ini b/dist/idz/segatools.ini index 6c68321..8c45076 100644 --- a/dist/idz/segatools.ini +++ b/dist/idz/segatools.ini @@ -12,6 +12,7 @@ appdata= ; Controls emulation of the Aime card reader assembly. enable=1 aimePath=DEVICE\aime.txt +felicaGen=0 [dns] ; Insert the hostname or IP address of the server you wish to use here. @@ -86,6 +87,11 @@ autoNeutral=1 singleStickSteering=1 ; Use linear steering instead of the default non-linear cubing steering. linearSteering=0 +; Configure deadzones for the left and right thumbsticks. +; The default value for the left stick is 7849, max value is 32767. +leftStickDeadzone=7849 +; The default value for the right stick is 8689, max value is 32767. +rightStickDeadzone=8689 ; Adjust scaling for steering wheel input. ; ; This setting scales the steering wheel input so that the maximum positive @@ -101,7 +107,7 @@ restrict=97 [dinput] ; Name of the DirectInput wheel to use (or any text that occurs in its name) -; Example: TMX +; Example: G29 ; ; If this is left blank then the first DirectInput device will be used. deviceName= @@ -112,30 +118,30 @@ deviceName= ; ; Can be the same device as the wheel. ; -; Example: T500 +; Example: G29 shifterName= ; Pedal mappings. Valid axis names are: ; ; X, Y, Z, RX, RY, RZ, U, V ; ; (U and V are old names for Slider 1 and Slider 2). -; The examples below are valid for a Thrustmaster TMX. -brakeAxis=RZ +; The examples below are valid for a Logitech G29. +brakeAxis=U accelAxis=Y ; DirectInput button numbers to map to menu inputs. Note that buttons are ; numbered from 1; some software numbers buttons from 0. -start=3 -viewChg=10 +start=1 +viewChg=2 ; Button mappings for the simulated six-speed shifter. -shiftDn=1 -shiftUp=2 +shiftDn=5 +shiftUp=6 ; Button mappings for the positional shifter, if present. -gear1=1 -gear2=2 -gear3=3 -gear4=4 -gear5=5 -gear6=6 +gear1=13 +gear2=14 +gear3=15 +gear4=16 +gear5=17 +gear6=18 ; Invert the accelerator and or brake axis ; (Needed when using DirectInput for the Dualshock 4 for example) reverseAccelAxis=0 diff --git a/dist/swdc/segatools.ini b/dist/swdc/segatools.ini index ef762c5..24cbb8f 100644 --- a/dist/swdc/segatools.ini +++ b/dist/swdc/segatools.ini @@ -68,6 +68,11 @@ mode=xinput singleStickSteering=1 ; Use linear steering instead of the default non-linear cubing steering. linearSteering=0 +; Configure deadzones for the left and right thumbsticks. +; The default value for the left stick is 7849, max value is 32767. +leftStickDeadzone=7849 +; The default value for the right stick is 8689, max value is 32767. +rightStickDeadzone=8689 ; Adjust scaling for steering wheel input. ; ; This setting scales the steering wheel input so that the maximum positive diff --git a/idacio/config.c b/idacio/config.c index ce7e201..fc0f832 100644 --- a/idacio/config.c +++ b/idacio/config.c @@ -87,6 +87,18 @@ void idac_xi_config_load(struct idac_xi_config *cfg, const wchar_t *filename) L"linearSteering", 0, filename); + + cfg->left_stick_deadzone = GetPrivateProfileIntW( + L"io4", + L"leftStickDeadzone", + 7849, + filename); + + cfg->right_stick_deadzone = GetPrivateProfileIntW( + L"io4", + L"rightStickDeadzone", + 8689, + filename); } void idac_io_config_load(struct idac_io_config *cfg, const wchar_t *filename) diff --git a/idacio/config.h b/idacio/config.h index 05332da..4b8a3eb 100644 --- a/idacio/config.h +++ b/idacio/config.h @@ -25,6 +25,8 @@ struct idac_di_config { struct idac_xi_config { bool single_stick_steering; bool linear_steering; + uint16_t left_stick_deadzone; + uint16_t right_stick_deadzone; }; struct idac_io_config { diff --git a/idacio/xi.c b/idacio/xi.c index 3a41aaa..918acad 100644 --- a/idacio/xi.c +++ b/idacio/xi.c @@ -27,6 +27,8 @@ static const struct idac_io_backend idac_xi_backend = { static bool idac_xi_single_stick_steering; static bool idac_xi_linear_steering; +static uint16_t idac_xi_left_stick_deadzone; +static uint16_t idac_xi_right_stick_deadzone; HRESULT idac_xi_init(const struct idac_xi_config *cfg, const struct idac_io_backend **backend) { HRESULT hr; @@ -50,13 +52,28 @@ HRESULT idac_io_poll(void) { } static HRESULT idac_xi_config_apply(const struct idac_xi_config *cfg) { + /* Deadzones check */ + if (cfg->left_stick_deadzone > 32767 || cfg->left_stick_deadzone < 0) { + dprintf("XInput: Left stick deadzone is too large or negative\n"); + return E_INVALIDARG; + } + + if (cfg->right_stick_deadzone > 32767 || cfg->right_stick_deadzone < 0) { + dprintf("XInput: Right stick deadzone is too large or negative\n"); + return E_INVALIDARG; + } + dprintf("XInput: --- Begin configuration ---\n"); dprintf("XInput: Single Stick Steering : %i\n", cfg->single_stick_steering); dprintf("XInput: Linear Steering . . . : %i\n", cfg->linear_steering); + dprintf("XInput: Left Deadzone . . . . : %i\n", cfg->left_stick_deadzone); + dprintf("XInput: Right Deadzone . . . : %i\n", cfg->right_stick_deadzone); dprintf("XInput: --- End configuration ---\n"); idac_xi_single_stick_steering = cfg->single_stick_steering; idac_xi_linear_steering = cfg->linear_steering; + idac_xi_left_stick_deadzone = cfg->left_stick_deadzone; + idac_xi_right_stick_deadzone = cfg->right_stick_deadzone; return S_OK; } @@ -118,22 +135,6 @@ static void idac_xi_get_shifter(uint8_t *gear) { idac_shifter_set(0); } - /* - // Alternative shifting mode - if (xb & XINPUT_GAMEPAD_X) { - // Set to Gear 2 when X is pressed - idac_shifter_set(2); - } - - if (xb & XINPUT_GAMEPAD_Y) { - // Set to Gear 3 when Y is pressed - idac_shifter_set(3); - } - - shift_dn = xb & XINPUT_GAMEPAD_LEFT_SHOULDER; - shift_up = xb & XINPUT_GAMEPAD_RIGHT_SHOULDER; - */ - shift_dn = xb & (XINPUT_GAMEPAD_Y | XINPUT_GAMEPAD_LEFT_SHOULDER); shift_up = xb & (XINPUT_GAMEPAD_X | XINPUT_GAMEPAD_RIGHT_SHOULDER); @@ -182,21 +183,21 @@ static void idac_xi_get_analogs(struct idac_io_analog_state *out) { if (!idac_xi_linear_steering) { // Apply non-linear transform for both sticks - left = apply_non_linear_transform(left, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE); - right = apply_non_linear_transform(right, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE); + left = apply_non_linear_transform(left, idac_xi_left_stick_deadzone); + right = apply_non_linear_transform(right, idac_xi_right_stick_deadzone); } else { - if (left < -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { - left += XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE; - } else if (left > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { - left -= XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE; + if (left < -idac_xi_left_stick_deadzone) { + left += idac_xi_left_stick_deadzone; + } else if (left > idac_xi_left_stick_deadzone) { + left -= idac_xi_left_stick_deadzone; } else { left = 0; } - if (right < -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { - right += XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; - } else if (right > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { - right -= XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; + if (right < -idac_xi_right_stick_deadzone) { + right += idac_xi_right_stick_deadzone; + } else if (right > idac_xi_right_stick_deadzone) { + right -= idac_xi_right_stick_deadzone; } else { right = 0; } @@ -204,7 +205,6 @@ static void idac_xi_get_analogs(struct idac_io_analog_state *out) { if (idac_xi_single_stick_steering) { out->wheel = left; - // dprintf("XInput: Single Stick Steering: %i\n", out->wheel); } else { out->wheel = (left + right) / 2; } diff --git a/idzio/config.c b/idzio/config.c index e49b550..2bb51ff 100644 --- a/idzio/config.c +++ b/idzio/config.c @@ -87,6 +87,18 @@ void idz_xi_config_load(struct idz_xi_config *cfg, const wchar_t *filename) L"linearSteering", 0, filename); + + cfg->left_stick_deadzone = GetPrivateProfileIntW( + L"io3", + L"leftStickDeadzone", + 7849, + filename); + + cfg->right_stick_deadzone = GetPrivateProfileIntW( + L"io3", + L"rightStickDeadzone", + 8689, + filename); } void idz_io_config_load(struct idz_io_config *cfg, const wchar_t *filename) diff --git a/idzio/config.h b/idzio/config.h index 3d2668b..24934ca 100644 --- a/idzio/config.h +++ b/idzio/config.h @@ -25,6 +25,8 @@ struct idz_di_config { struct idz_xi_config { bool single_stick_steering; bool linear_steering; + uint16_t left_stick_deadzone; + uint16_t right_stick_deadzone; }; struct idz_io_config { diff --git a/idzio/xi.c b/idzio/xi.c index ebd1ea9..413fa56 100644 --- a/idzio/xi.c +++ b/idzio/xi.c @@ -28,6 +28,8 @@ static const struct idz_io_backend idz_xi_backend = { static bool idz_xi_single_stick_steering; static bool idz_xi_linear_steering; +static uint16_t idz_xi_left_stick_deadzone; +static uint16_t idz_xi_right_stick_deadzone; HRESULT idz_xi_init(const struct idz_xi_config *cfg, const struct idz_io_backend **backend) { @@ -47,15 +49,29 @@ HRESULT idz_xi_init(const struct idz_xi_config *cfg, const struct idz_io_backend return S_OK; } -static HRESULT idz_xi_config_apply(const struct idz_xi_config *cfg) -{ +static HRESULT idz_xi_config_apply(const struct idz_xi_config *cfg) { + /* Deadzones check */ + if (cfg->left_stick_deadzone > 32767 || cfg->left_stick_deadzone < 0) { + dprintf("XInput: Left stick deadzone is too large or negative\n"); + return E_INVALIDARG; + } + + if (cfg->right_stick_deadzone > 32767 || cfg->right_stick_deadzone < 0) { + dprintf("XInput: Right stick deadzone is too large or negative\n"); + return E_INVALIDARG; + } + dprintf("XInput: --- Begin configuration ---\n"); dprintf("XInput: Single Stick Steering : %i\n", cfg->single_stick_steering); dprintf("XInput: Linear Steering . . . : %i\n", cfg->linear_steering); + dprintf("XInput: Left Deadzone . . . . : %i\n", cfg->left_stick_deadzone); + dprintf("XInput: Right Deadzone . . . : %i\n", cfg->right_stick_deadzone); dprintf("XInput: --- End configuration ---\n"); idz_xi_single_stick_steering = cfg->single_stick_steering; idz_xi_linear_steering = cfg->linear_steering; + idz_xi_left_stick_deadzone = cfg->left_stick_deadzone; + idz_xi_right_stick_deadzone = cfg->right_stick_deadzone; return S_OK; } @@ -168,21 +184,21 @@ static void idz_xi_jvs_read_analogs(struct idz_io_analog_state *out) if (!idz_xi_linear_steering) { // Apply non-linear transform for both sticks - left = apply_non_linear_transform(left, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE); - right = apply_non_linear_transform(right, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE); + left = apply_non_linear_transform(left, idz_xi_left_stick_deadzone); + right = apply_non_linear_transform(right, idz_xi_right_stick_deadzone); } else { - if (left < -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { - left += XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE; - } else if (left > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { - left -= XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE; + if (left < -idz_xi_left_stick_deadzone) { + left += idz_xi_left_stick_deadzone; + } else if (left > idz_xi_left_stick_deadzone) { + left -= idz_xi_left_stick_deadzone; } else { left = 0; } - if (right < -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { - right += XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; - } else if (right > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { - right -= XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; + if (right < -idz_xi_right_stick_deadzone) { + right += idz_xi_right_stick_deadzone; + } else if (right > idz_xi_right_stick_deadzone) { + right -= idz_xi_right_stick_deadzone; } else { right = 0; } diff --git a/swdcio/config.c b/swdcio/config.c index ae4a1f5..c7494fe 100644 --- a/swdcio/config.c +++ b/swdcio/config.c @@ -77,6 +77,18 @@ void swdc_xi_config_load(struct swdc_xi_config *cfg, const wchar_t *filename) L"linearSteering", 0, filename); + + cfg->left_stick_deadzone = GetPrivateProfileIntW( + L"io4", + L"leftStickDeadzone", + 7849, + filename); + + cfg->right_stick_deadzone = GetPrivateProfileIntW( + L"io4", + L"rightStickDeadzone", + 8689, + filename); } void swdc_io_config_load(struct swdc_io_config *cfg, const wchar_t *filename) diff --git a/swdcio/config.h b/swdcio/config.h index 0225d59..1b09380 100644 --- a/swdcio/config.h +++ b/swdcio/config.h @@ -27,6 +27,8 @@ struct swdc_di_config { struct swdc_xi_config { bool single_stick_steering; bool linear_steering; + uint16_t left_stick_deadzone; + uint16_t right_stick_deadzone; }; struct swdc_io_config { diff --git a/swdcio/xi.c b/swdcio/xi.c index 9a98ec4..3067d3f 100644 --- a/swdcio/xi.c +++ b/swdcio/xi.c @@ -25,6 +25,8 @@ static const struct swdc_io_backend swdc_xi_backend = { static bool swdc_xi_single_stick_steering; static bool swdc_xi_linear_steering; +static uint16_t swdc_xi_left_stick_deadzone; +static uint16_t swdc_xi_right_stick_deadzone; HRESULT swdc_xi_init(const struct swdc_xi_config *cfg, const struct swdc_io_backend **backend) { @@ -49,15 +51,29 @@ HRESULT swdc_io_poll(void) return S_OK; } -static HRESULT swdc_xi_config_apply(const struct swdc_xi_config *cfg) -{ +static HRESULT swdc_xi_config_apply(const struct swdc_xi_config *cfg) { + /* Deadzones check */ + if (cfg->left_stick_deadzone > 32767 || cfg->left_stick_deadzone < 0) { + dprintf("XInput: Left stick deadzone is too large or negative\n"); + return E_INVALIDARG; + } + + if (cfg->right_stick_deadzone > 32767 || cfg->right_stick_deadzone < 0) { + dprintf("XInput: Right stick deadzone is too large or negative\n"); + return E_INVALIDARG; + } + dprintf("XInput: --- Begin configuration ---\n"); dprintf("XInput: Single Stick Steering : %i\n", cfg->single_stick_steering); dprintf("XInput: Linear Steering . . . : %i\n", cfg->linear_steering); + dprintf("XInput: Left Deadzone . . . . : %i\n", cfg->left_stick_deadzone); + dprintf("XInput: Right Deadzone . . . : %i\n", cfg->right_stick_deadzone); dprintf("XInput: --- End configuration ---\n"); swdc_xi_single_stick_steering = cfg->single_stick_steering; swdc_xi_linear_steering = cfg->linear_steering; + swdc_xi_left_stick_deadzone = cfg->left_stick_deadzone; + swdc_xi_right_stick_deadzone = cfg->right_stick_deadzone; return S_OK; } @@ -168,21 +184,21 @@ static void swdc_xi_get_analogs(struct swdc_io_analog_state *out) if (!swdc_xi_linear_steering) { // Apply non-linear transform for both sticks - left = apply_non_linear_transform(left, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE); - right = apply_non_linear_transform(right, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE); + left = apply_non_linear_transform(left, swdc_xi_left_stick_deadzone); + right = apply_non_linear_transform(right, swdc_xi_right_stick_deadzone); } else { - if (left < -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { - left += XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE; - } else if (left > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { - left -= XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE; + if (left < -swdc_xi_left_stick_deadzone) { + left += swdc_xi_left_stick_deadzone; + } else if (left > swdc_xi_left_stick_deadzone) { + left -= swdc_xi_left_stick_deadzone; } else { left = 0; } - if (right < -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { - right += XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; - } else if (right > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { - right -= XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; + if (right < -swdc_xi_right_stick_deadzone) { + right += swdc_xi_right_stick_deadzone; + } else if (right > swdc_xi_right_stick_deadzone) { + right -= swdc_xi_right_stick_deadzone; } else { right = 0; }