idz, idac, swdc: Added deadzone config

This commit is contained in:
Dniel97 2023-08-29 02:22:05 +02:00
parent f6e961d4f4
commit ca4a8bd84d
Signed by untrusted user: Dniel97
GPG Key ID: 6180B3C768FB2E08
12 changed files with 168 additions and 78 deletions

View File

@ -96,6 +96,11 @@ autoNeutral=1
singleStickSteering=1 singleStickSteering=1
; Use linear steering instead of the default non-linear cubing steering. ; Use linear steering instead of the default non-linear cubing steering.
linearSteering=0 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. ; Adjust scaling for steering wheel input.
; ;
; This setting scales the steering wheel input so that the maximum positive ; This setting scales the steering wheel input so that the maximum positive
@ -111,7 +116,7 @@ restrict=128
[dinput] [dinput]
; Name of the DirectInput wheel to use (or any text that occurs in its name) ; 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. ; If this is left blank then the first DirectInput device will be used.
deviceName= deviceName=
@ -122,30 +127,30 @@ deviceName=
; ;
; Can be the same device as the wheel. ; Can be the same device as the wheel.
; ;
; Example: T500 ; Example: G29
shifterName= shifterName=
; Pedal mappings. Valid axis names are: ; Pedal mappings. Valid axis names are:
; ;
; X, Y, Z, RX, RY, RZ, U, V ; X, Y, Z, RX, RY, RZ, U, V
; ;
; (U and V are old names for Slider 1 and Slider 2). ; (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 brakeAxis=RZ
accelAxis=Y accelAxis=Y
; DirectInput button numbers to map to menu inputs. Note that buttons are ; DirectInput button numbers to map to menu inputs. Note that buttons are
; numbered from 1; some software numbers buttons from 0. ; numbered from 1; some software numbers buttons from 0.
start=3 start=1
viewChg=10 viewChg=2
; Button mappings for the simulated six-speed shifter. ; Button mappings for the simulated six-speed shifter.
shiftDn=1 shiftDn=5
shiftUp=2 shiftUp=6
; Button mappings for the positional shifter, if present. ; Button mappings for the positional shifter, if present.
gear1=1 gear1=13
gear2=2 gear2=14
gear3=3 gear3=15
gear4=4 gear4=16
gear5=5 gear5=17
gear6=6 gear6=18
; Invert the accelerator and or brake axis ; Invert the accelerator and or brake axis
; (Needed when using DirectInput for the Dualshock 4 for example) ; (Needed when using DirectInput for the Dualshock 4 for example)
reverseAccelAxis=0 reverseAccelAxis=0

View File

@ -12,6 +12,7 @@ appdata=
; Controls emulation of the Aime card reader assembly. ; Controls emulation of the Aime card reader assembly.
enable=1 enable=1
aimePath=DEVICE\aime.txt aimePath=DEVICE\aime.txt
felicaGen=0
[dns] [dns]
; Insert the hostname or IP address of the server you wish to use here. ; Insert the hostname or IP address of the server you wish to use here.
@ -86,6 +87,11 @@ autoNeutral=1
singleStickSteering=1 singleStickSteering=1
; Use linear steering instead of the default non-linear cubing steering. ; Use linear steering instead of the default non-linear cubing steering.
linearSteering=0 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. ; Adjust scaling for steering wheel input.
; ;
; This setting scales the steering wheel input so that the maximum positive ; This setting scales the steering wheel input so that the maximum positive
@ -101,7 +107,7 @@ restrict=97
[dinput] [dinput]
; Name of the DirectInput wheel to use (or any text that occurs in its name) ; 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. ; If this is left blank then the first DirectInput device will be used.
deviceName= deviceName=
@ -112,30 +118,30 @@ deviceName=
; ;
; Can be the same device as the wheel. ; Can be the same device as the wheel.
; ;
; Example: T500 ; Example: G29
shifterName= shifterName=
; Pedal mappings. Valid axis names are: ; Pedal mappings. Valid axis names are:
; ;
; X, Y, Z, RX, RY, RZ, U, V ; X, Y, Z, RX, RY, RZ, U, V
; ;
; (U and V are old names for Slider 1 and Slider 2). ; (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 brakeAxis=U
accelAxis=Y accelAxis=Y
; DirectInput button numbers to map to menu inputs. Note that buttons are ; DirectInput button numbers to map to menu inputs. Note that buttons are
; numbered from 1; some software numbers buttons from 0. ; numbered from 1; some software numbers buttons from 0.
start=3 start=1
viewChg=10 viewChg=2
; Button mappings for the simulated six-speed shifter. ; Button mappings for the simulated six-speed shifter.
shiftDn=1 shiftDn=5
shiftUp=2 shiftUp=6
; Button mappings for the positional shifter, if present. ; Button mappings for the positional shifter, if present.
gear1=1 gear1=13
gear2=2 gear2=14
gear3=3 gear3=15
gear4=4 gear4=16
gear5=5 gear5=17
gear6=6 gear6=18
; Invert the accelerator and or brake axis ; Invert the accelerator and or brake axis
; (Needed when using DirectInput for the Dualshock 4 for example) ; (Needed when using DirectInput for the Dualshock 4 for example)
reverseAccelAxis=0 reverseAccelAxis=0

View File

@ -68,6 +68,11 @@ mode=xinput
singleStickSteering=1 singleStickSteering=1
; Use linear steering instead of the default non-linear cubing steering. ; Use linear steering instead of the default non-linear cubing steering.
linearSteering=0 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. ; Adjust scaling for steering wheel input.
; ;
; This setting scales the steering wheel input so that the maximum positive ; This setting scales the steering wheel input so that the maximum positive

View File

@ -87,6 +87,18 @@ void idac_xi_config_load(struct idac_xi_config *cfg, const wchar_t *filename)
L"linearSteering", L"linearSteering",
0, 0,
filename); 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) void idac_io_config_load(struct idac_io_config *cfg, const wchar_t *filename)

View File

@ -25,6 +25,8 @@ struct idac_di_config {
struct idac_xi_config { struct idac_xi_config {
bool single_stick_steering; bool single_stick_steering;
bool linear_steering; bool linear_steering;
uint16_t left_stick_deadzone;
uint16_t right_stick_deadzone;
}; };
struct idac_io_config { struct idac_io_config {

View File

@ -27,6 +27,8 @@ static const struct idac_io_backend idac_xi_backend = {
static bool idac_xi_single_stick_steering; static bool idac_xi_single_stick_steering;
static bool idac_xi_linear_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 idac_xi_init(const struct idac_xi_config *cfg, const struct idac_io_backend **backend) {
HRESULT hr; HRESULT hr;
@ -50,13 +52,28 @@ HRESULT idac_io_poll(void) {
} }
static HRESULT idac_xi_config_apply(const struct idac_xi_config *cfg) { 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: --- Begin configuration ---\n");
dprintf("XInput: Single Stick Steering : %i\n", cfg->single_stick_steering); dprintf("XInput: Single Stick Steering : %i\n", cfg->single_stick_steering);
dprintf("XInput: Linear Steering . . . : %i\n", cfg->linear_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"); dprintf("XInput: --- End configuration ---\n");
idac_xi_single_stick_steering = cfg->single_stick_steering; idac_xi_single_stick_steering = cfg->single_stick_steering;
idac_xi_linear_steering = cfg->linear_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; return S_OK;
} }
@ -118,22 +135,6 @@ static void idac_xi_get_shifter(uint8_t *gear) {
idac_shifter_set(0); 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_dn = xb & (XINPUT_GAMEPAD_Y | XINPUT_GAMEPAD_LEFT_SHOULDER);
shift_up = xb & (XINPUT_GAMEPAD_X | XINPUT_GAMEPAD_RIGHT_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) { if (!idac_xi_linear_steering) {
// Apply non-linear transform for both sticks // Apply non-linear transform for both sticks
left = apply_non_linear_transform(left, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE); left = apply_non_linear_transform(left, idac_xi_left_stick_deadzone);
right = apply_non_linear_transform(right, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE); right = apply_non_linear_transform(right, idac_xi_right_stick_deadzone);
} else { } else {
if (left < -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { if (left < -idac_xi_left_stick_deadzone) {
left += XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE; left += idac_xi_left_stick_deadzone;
} else if (left > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { } else if (left > idac_xi_left_stick_deadzone) {
left -= XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE; left -= idac_xi_left_stick_deadzone;
} else { } else {
left = 0; left = 0;
} }
if (right < -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { if (right < -idac_xi_right_stick_deadzone) {
right += XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; right += idac_xi_right_stick_deadzone;
} else if (right > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { } else if (right > idac_xi_right_stick_deadzone) {
right -= XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; right -= idac_xi_right_stick_deadzone;
} else { } else {
right = 0; right = 0;
} }
@ -204,7 +205,6 @@ static void idac_xi_get_analogs(struct idac_io_analog_state *out) {
if (idac_xi_single_stick_steering) { if (idac_xi_single_stick_steering) {
out->wheel = left; out->wheel = left;
// dprintf("XInput: Single Stick Steering: %i\n", out->wheel);
} else { } else {
out->wheel = (left + right) / 2; out->wheel = (left + right) / 2;
} }

View File

@ -87,6 +87,18 @@ void idz_xi_config_load(struct idz_xi_config *cfg, const wchar_t *filename)
L"linearSteering", L"linearSteering",
0, 0,
filename); 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) void idz_io_config_load(struct idz_io_config *cfg, const wchar_t *filename)

View File

@ -25,6 +25,8 @@ struct idz_di_config {
struct idz_xi_config { struct idz_xi_config {
bool single_stick_steering; bool single_stick_steering;
bool linear_steering; bool linear_steering;
uint16_t left_stick_deadzone;
uint16_t right_stick_deadzone;
}; };
struct idz_io_config { struct idz_io_config {

View File

@ -28,6 +28,8 @@ static const struct idz_io_backend idz_xi_backend = {
static bool idz_xi_single_stick_steering; static bool idz_xi_single_stick_steering;
static bool idz_xi_linear_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) 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; 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: --- Begin configuration ---\n");
dprintf("XInput: Single Stick Steering : %i\n", cfg->single_stick_steering); dprintf("XInput: Single Stick Steering : %i\n", cfg->single_stick_steering);
dprintf("XInput: Linear Steering . . . : %i\n", cfg->linear_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"); dprintf("XInput: --- End configuration ---\n");
idz_xi_single_stick_steering = cfg->single_stick_steering; idz_xi_single_stick_steering = cfg->single_stick_steering;
idz_xi_linear_steering = cfg->linear_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; 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) { if (!idz_xi_linear_steering) {
// Apply non-linear transform for both sticks // Apply non-linear transform for both sticks
left = apply_non_linear_transform(left, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE); left = apply_non_linear_transform(left, idz_xi_left_stick_deadzone);
right = apply_non_linear_transform(right, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE); right = apply_non_linear_transform(right, idz_xi_right_stick_deadzone);
} else { } else {
if (left < -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { if (left < -idz_xi_left_stick_deadzone) {
left += XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE; left += idz_xi_left_stick_deadzone;
} else if (left > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { } else if (left > idz_xi_left_stick_deadzone) {
left -= XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE; left -= idz_xi_left_stick_deadzone;
} else { } else {
left = 0; left = 0;
} }
if (right < -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { if (right < -idz_xi_right_stick_deadzone) {
right += XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; right += idz_xi_right_stick_deadzone;
} else if (right > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { } else if (right > idz_xi_right_stick_deadzone) {
right -= XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; right -= idz_xi_right_stick_deadzone;
} else { } else {
right = 0; right = 0;
} }

View File

@ -77,6 +77,18 @@ void swdc_xi_config_load(struct swdc_xi_config *cfg, const wchar_t *filename)
L"linearSteering", L"linearSteering",
0, 0,
filename); 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) void swdc_io_config_load(struct swdc_io_config *cfg, const wchar_t *filename)

View File

@ -27,6 +27,8 @@ struct swdc_di_config {
struct swdc_xi_config { struct swdc_xi_config {
bool single_stick_steering; bool single_stick_steering;
bool linear_steering; bool linear_steering;
uint16_t left_stick_deadzone;
uint16_t right_stick_deadzone;
}; };
struct swdc_io_config { struct swdc_io_config {

View File

@ -25,6 +25,8 @@ static const struct swdc_io_backend swdc_xi_backend = {
static bool swdc_xi_single_stick_steering; static bool swdc_xi_single_stick_steering;
static bool swdc_xi_linear_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) 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; 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: --- Begin configuration ---\n");
dprintf("XInput: Single Stick Steering : %i\n", cfg->single_stick_steering); dprintf("XInput: Single Stick Steering : %i\n", cfg->single_stick_steering);
dprintf("XInput: Linear Steering . . . : %i\n", cfg->linear_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"); dprintf("XInput: --- End configuration ---\n");
swdc_xi_single_stick_steering = cfg->single_stick_steering; swdc_xi_single_stick_steering = cfg->single_stick_steering;
swdc_xi_linear_steering = cfg->linear_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; return S_OK;
} }
@ -168,21 +184,21 @@ static void swdc_xi_get_analogs(struct swdc_io_analog_state *out)
if (!swdc_xi_linear_steering) { if (!swdc_xi_linear_steering) {
// Apply non-linear transform for both sticks // Apply non-linear transform for both sticks
left = apply_non_linear_transform(left, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE); left = apply_non_linear_transform(left, swdc_xi_left_stick_deadzone);
right = apply_non_linear_transform(right, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE); right = apply_non_linear_transform(right, swdc_xi_right_stick_deadzone);
} else { } else {
if (left < -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { if (left < -swdc_xi_left_stick_deadzone) {
left += XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE; left += swdc_xi_left_stick_deadzone;
} else if (left > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) { } else if (left > swdc_xi_left_stick_deadzone) {
left -= XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE; left -= swdc_xi_left_stick_deadzone;
} else { } else {
left = 0; left = 0;
} }
if (right < -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { if (right < -swdc_xi_right_stick_deadzone) {
right += XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; right += swdc_xi_right_stick_deadzone;
} else if (right > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) { } else if (right > swdc_xi_right_stick_deadzone) {
right -= XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE; right -= swdc_xi_right_stick_deadzone;
} else { } else {
right = 0; right = 0;
} }