From e36031ebfb84a689705c2b10b737b534cf27032a Mon Sep 17 00:00:00 2001 From: Hoe Date: Sat, 13 Jul 2024 22:34:02 +0800 Subject: [PATCH] Support non-standard wheel mapping button --- idacio/config.c | 4 ++++ idacio/config.h | 4 ++++ idacio/di.c | 26 ++++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/idacio/config.c b/idacio/config.c index 6bf6996..f7e8a70 100644 --- a/idacio/config.c +++ b/idacio/config.c @@ -58,8 +58,12 @@ void idac_di_config_load(struct idac_di_config *cfg, const wchar_t *filename) cfg->start = GetPrivateProfileIntW(L"dinput", L"start", 0, filename); cfg->view_chg = GetPrivateProfileIntW(L"dinput", L"viewChg", 0, filename); + cfg->up = GetPrivateProfileIntW(L"dinput", L"up", 0, filename); + cfg->down = GetPrivateProfileIntW(L"dinput", L"down", 0, filename); cfg->left = GetPrivateProfileIntW(L"dinput", L"left", 0, filename); cfg->right = GetPrivateProfileIntW(L"dinput", L"right", 0, filename); + cfg->leftThumb = GetPrivateProfileIntW(L"dinput", L"leftThumb", 0, filename); + cfg->rightThumb = GetPrivateProfileIntW(L"dinput", L"rightThumb", 0, filename); cfg->shift_dn = GetPrivateProfileIntW(L"dinput", L"shiftDn", 0, filename); cfg->shift_up = GetPrivateProfileIntW(L"dinput", L"shiftUp", 0, filename); diff --git a/idacio/config.h b/idacio/config.h index bbf568d..be243b9 100644 --- a/idacio/config.h +++ b/idacio/config.h @@ -16,8 +16,12 @@ struct idac_di_config { wchar_t accel_axis[16]; uint8_t start; uint8_t view_chg; + uint8_t up; + uint8_t down; uint8_t left; uint8_t right; + uint8_t leftThumb; + uint8_t rightThumb; uint8_t shift_dn; uint8_t shift_up; uint8_t gear[6]; diff --git a/idacio/di.c b/idacio/di.c index 55018e8..4d82862 100644 --- a/idacio/di.c +++ b/idacio/di.c @@ -69,8 +69,12 @@ static uint8_t idac_di_shift_dn; static uint8_t idac_di_shift_up; static uint8_t idac_di_view_chg; static uint8_t idac_di_start; +static uint8_t idac_di_up; +static uint8_t idac_di_down; static uint8_t idac_di_left; static uint8_t idac_di_right; +static uint8_t idac_di_leftThumb; +static uint8_t idac_di_rightThumb; static uint8_t idac_di_gear[6]; static bool idac_di_use_pedals; static bool idac_di_reverse_brake_axis; @@ -105,6 +109,8 @@ HRESULT idac_di_init( return hr; } + dprintf("DirectInput: Controller initializing\n"); + /* Initial D Zero has some built-in DirectInput support that is not particularly useful. idachook shorts this out by redirecting dinput8.dll to a no-op implementation of DirectInput. However, idacio does need to @@ -321,8 +327,12 @@ static HRESULT idac_di_config_apply(const struct idac_di_config *cfg) } dprintf("Wheel: Start button . . . : %i\n", cfg->start); dprintf("Wheel: View Change button : %i\n", cfg->view_chg); + dprintf("Wheel: Up button . . . . . : %i\n", cfg->up); + dprintf("Wheel: Down button . . . . : %i\n", cfg->down); dprintf("Wheel: Left button . . . . : %i\n", cfg->left); dprintf("Wheel: Right button . . . : %i\n", cfg->right); + dprintf("Wheel: LeftThumb button . : %i\n", cfg->leftThumb); + dprintf("Wheel: RightThumb button : %i\n", cfg->rightThumb); dprintf("Wheel: Shift Down button . : %i\n", cfg->shift_dn); dprintf("Wheel: Shift Up button . . : %i\n", cfg->shift_up); dprintf("Wheel: Reverse Brake Axis : %i\n", cfg->reverse_brake_axis); @@ -356,8 +366,12 @@ static HRESULT idac_di_config_apply(const struct idac_di_config *cfg) idac_di_off_accel = accel_axis->off; idac_di_start = cfg->start; idac_di_view_chg = cfg->view_chg; + idac_di_up = cfg->up; + idac_di_down = cfg->down; idac_di_left = cfg->left; idac_di_right = cfg->right; + idac_di_leftThumb = cfg->leftThumb; + idac_di_rightThumb = cfg->rightThumb; idac_di_shift_dn = cfg->shift_dn; idac_di_shift_up = cfg->shift_up; idac_di_reverse_brake_axis = cfg->reverse_brake_axis; @@ -504,11 +518,19 @@ static void idac_di_get_buttons(uint8_t *gamebtn_out) gamebtn |= IDAC_IO_GAMEBTN_VIEW_CHANGE; } - if (idac_di_left && state.st.rgbButtons[idac_di_left - 1]) { + if (idac_di_up && state.st.rgbButtons[idac_di_up - 1]) { + gamebtn |= IDAC_IO_GAMEBTN_UP; + } + + if (idac_di_down && state.st.rgbButtons[idac_di_down - 1]) { + gamebtn |= IDAC_IO_GAMEBTN_DOWN; + } + + if (idac_di_left && (state.st.rgbButtons[idac_di_left - 1] | state.st.rgbButtons[idac_di_leftThumb - 1])) { gamebtn |= IDAC_IO_GAMEBTN_LEFT; } - if (idac_di_right && state.st.rgbButtons[idac_di_right - 1]) { + if (idac_di_right && (state.st.rgbButtons[idac_di_right - 1] | state.st.rgbButtons[idac_di_rightThumb - 1])) { gamebtn |= IDAC_IO_GAMEBTN_RIGHT; }