idac: added left and right button mapping

This commit is contained in:
Dniel97 2023-09-04 23:31:52 +02:00
parent 9bef9e49f8
commit eb2eef927a
Signed by untrusted user: Dniel97
GPG Key ID: 6180B3C768FB2E08
4 changed files with 35 additions and 0 deletions

View File

@ -144,6 +144,11 @@ accelAxis=Y
; numbered from 1; some software numbers buttons from 0. ; numbered from 1; some software numbers buttons from 0.
start=1 start=1
viewChg=2 viewChg=2
; DPad is already emulated, but in order to trigger "Time Up" and exit the
; course you need to press both left and right on the DPad at the same time.
; This is not possible on most devices, so we set the left and right button again.
left=7
right=8
; Button mappings for the simulated six-speed shifter. ; Button mappings for the simulated six-speed shifter.
shiftDn=5 shiftDn=5
shiftUp=6 shiftUp=6

View File

@ -50,6 +50,8 @@ void idac_di_config_load(struct idac_di_config *cfg, const wchar_t *filename)
cfg->start = GetPrivateProfileIntW(L"dinput", L"start", 0, filename); cfg->start = GetPrivateProfileIntW(L"dinput", L"start", 0, filename);
cfg->view_chg = GetPrivateProfileIntW(L"dinput", L"viewChg", 0, filename); cfg->view_chg = GetPrivateProfileIntW(L"dinput", L"viewChg", 0, filename);
cfg->left = GetPrivateProfileIntW(L"dinput", L"left", 0, filename);
cfg->right = GetPrivateProfileIntW(L"dinput", L"right", 0, filename);
cfg->shift_dn = GetPrivateProfileIntW(L"dinput", L"shiftDn", 0, filename); cfg->shift_dn = GetPrivateProfileIntW(L"dinput", L"shiftDn", 0, filename);
cfg->shift_up = GetPrivateProfileIntW(L"dinput", L"shiftUp", 0, filename); cfg->shift_up = GetPrivateProfileIntW(L"dinput", L"shiftUp", 0, filename);

View File

@ -15,6 +15,8 @@ struct idac_di_config {
wchar_t accel_axis[16]; wchar_t accel_axis[16];
uint8_t start; uint8_t start;
uint8_t view_chg; uint8_t view_chg;
uint8_t left;
uint8_t right;
uint8_t shift_dn; uint8_t shift_dn;
uint8_t shift_up; uint8_t shift_up;
uint8_t gear[6]; uint8_t gear[6];

View File

@ -65,6 +65,8 @@ static uint8_t idac_di_shift_dn;
static uint8_t idac_di_shift_up; static uint8_t idac_di_shift_up;
static uint8_t idac_di_view_chg; static uint8_t idac_di_view_chg;
static uint8_t idac_di_start; static uint8_t idac_di_start;
static uint8_t idac_di_left;
static uint8_t idac_di_right;
static uint8_t idac_di_gear[6]; static uint8_t idac_di_gear[6];
static bool idac_di_reverse_brake_axis; static bool idac_di_reverse_brake_axis;
static bool idac_di_reverse_accel_axis; static bool idac_di_reverse_accel_axis;
@ -235,6 +237,18 @@ static HRESULT idac_di_config_apply(const struct idac_di_config *cfg)
return E_INVALIDARG; return E_INVALIDARG;
} }
if (cfg->left > 32) {
dprintf("Wheel: Invalid left button: %i\n", cfg->left);
return E_INVALIDARG;
}
if (cfg->right > 32) {
dprintf("Wheel: Invalid right button: %i\n", cfg->right);
return E_INVALIDARG;
}
if (cfg->shift_dn > 32) { if (cfg->shift_dn > 32) {
dprintf("Wheel: Invalid shift down button: %i\n", cfg->shift_dn); dprintf("Wheel: Invalid shift down button: %i\n", cfg->shift_dn);
@ -266,6 +280,8 @@ static HRESULT idac_di_config_apply(const struct idac_di_config *cfg)
dprintf("Wheel: Accel axis . . . . : %S\n", accel_axis->name); dprintf("Wheel: Accel axis . . . . : %S\n", accel_axis->name);
dprintf("Wheel: Start button . . . : %i\n", cfg->start); dprintf("Wheel: Start button . . . : %i\n", cfg->start);
dprintf("Wheel: View Change button : %i\n", cfg->view_chg); dprintf("Wheel: View Change button : %i\n", cfg->view_chg);
dprintf("Wheel: Left button . . . . : %i\n", cfg->left);
dprintf("Wheel: Right button . . . : %i\n", cfg->right);
dprintf("Wheel: Shift Down button . : %i\n", cfg->shift_dn); dprintf("Wheel: Shift Down button . : %i\n", cfg->shift_dn);
dprintf("Wheel: Shift Up button . . : %i\n", cfg->shift_up); dprintf("Wheel: Shift Up button . . : %i\n", cfg->shift_up);
dprintf("Wheel: Reverse Brake Axis : %i\n", cfg->reverse_brake_axis); dprintf("Wheel: Reverse Brake Axis : %i\n", cfg->reverse_brake_axis);
@ -290,6 +306,8 @@ static HRESULT idac_di_config_apply(const struct idac_di_config *cfg)
idac_di_off_accel = accel_axis->off; idac_di_off_accel = accel_axis->off;
idac_di_start = cfg->start; idac_di_start = cfg->start;
idac_di_view_chg = cfg->view_chg; idac_di_view_chg = cfg->view_chg;
idac_di_left = cfg->left;
idac_di_right = cfg->right;
idac_di_shift_dn = cfg->shift_dn; idac_di_shift_dn = cfg->shift_dn;
idac_di_shift_up = cfg->shift_up; idac_di_shift_up = cfg->shift_up;
idac_di_reverse_brake_axis = cfg->reverse_brake_axis; idac_di_reverse_brake_axis = cfg->reverse_brake_axis;
@ -398,6 +416,14 @@ static void idac_di_get_buttons(uint8_t *gamebtn_out)
gamebtn |= IDAC_IO_GAMEBTN_VIEW_CHANGE; gamebtn |= IDAC_IO_GAMEBTN_VIEW_CHANGE;
} }
if (idac_di_left && state.st.rgbButtons[idac_di_left - 1]) {
gamebtn |= IDAC_IO_GAMEBTN_LEFT;
}
if (idac_di_right && state.st.rgbButtons[idac_di_right - 1]) {
gamebtn |= IDAC_IO_GAMEBTN_RIGHT;
}
*gamebtn_out = gamebtn; *gamebtn_out = gamebtn;
} }