From 0a27ed2aae2e3cddd66ae33ae73de2c0a79394d6 Mon Sep 17 00:00:00 2001 From: Dniel97 Date: Sun, 4 Jan 2026 10:11:15 +0100 Subject: [PATCH] idz, swdc: add up/down/left/right DInput button config --- dist/idz/segatools.ini | 8 +++++++ dist/swdc/segatools.ini | 5 ++++ games/idacio/config.c | 4 ++-- games/idacio/config.h | 4 ++-- games/idacio/di.c | 50 ++++++++++++++++++++------------------- games/idzio/config.c | 4 ++++ games/idzio/config.h | 4 ++++ games/idzio/di.c | 52 +++++++++++++++++++++++++++++++++++++++++ games/swdcio/config.c | 4 ++++ games/swdcio/config.h | 4 ++++ games/swdcio/di.c | 52 +++++++++++++++++++++++++++++++++++++++++ 11 files changed, 163 insertions(+), 28 deletions(-) diff --git a/dist/idz/segatools.ini b/dist/idz/segatools.ini index 7e2035b..fc2ec69 100644 --- a/dist/idz/segatools.ini +++ b/dist/idz/segatools.ini @@ -230,6 +230,14 @@ accelAxis=Y ; numbered from 1; some software numbers buttons from 0. start=1 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 +; Additional mapping for up and down buttons in DPad. +up=4 +down=3 ; Button mappings for the simulated six-speed shifter. shiftDn=5 shiftUp=6 diff --git a/dist/swdc/segatools.ini b/dist/swdc/segatools.ini index 46d8dd8..6c93ae7 100644 --- a/dist/swdc/segatools.ini +++ b/dist/swdc/segatools.ini @@ -187,6 +187,11 @@ accelAxis=Y ; numbered from 1; some software numbers buttons from 0. start=1 viewChg=2 +; DPad is already emulated, but some wheels use buttons rather than a DPad. +up=4 +down=3 +left=7 +right=8 ; Button mappings for the steering wheel paddles. paddleLeft=6 paddleRight=5 diff --git a/games/idacio/config.c b/games/idacio/config.c index a325fa8..a5c1769 100644 --- a/games/idacio/config.c +++ b/games/idacio/config.c @@ -58,10 +58,10 @@ 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->left = GetPrivateProfileIntW(L"dinput", L"left", 0, filename); - cfg->right = GetPrivateProfileIntW(L"dinput", L"right", 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->shift_dn = GetPrivateProfileIntW(L"dinput", L"shiftDn", 0, filename); cfg->shift_up = GetPrivateProfileIntW(L"dinput", L"shiftUp", 0, filename); diff --git a/games/idacio/config.h b/games/idacio/config.h index df70404..5b7e736 100644 --- a/games/idacio/config.h +++ b/games/idacio/config.h @@ -16,10 +16,10 @@ struct idac_di_config { wchar_t accel_axis[16]; uint8_t start; uint8_t view_chg; - uint8_t left; - uint8_t right; uint8_t up; uint8_t down; + uint8_t left; + uint8_t right; uint8_t shift_dn; uint8_t shift_up; uint8_t gear[6]; diff --git a/games/idacio/di.c b/games/idacio/di.c index e676062..848abe1 100644 --- a/games/idacio/di.c +++ b/games/idacio/di.c @@ -69,10 +69,10 @@ 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_left; -static uint8_t idac_di_right; 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_gear[6]; static bool idac_di_use_pedals; static bool idac_di_reverse_brake_axis; @@ -237,6 +237,18 @@ static HRESULT idac_di_config_apply(const struct idac_di_config *cfg) return E_INVALIDARG; } + if (cfg->up > 32) { + dprintf("Wheel: Invalid up button: %i\n", cfg->up); + + return E_INVALIDARG; + } + + if (cfg->down > 32) { + dprintf("Wheel: Invalid down button: %i\n", cfg->down); + + return E_INVALIDARG; + } + if (cfg->left > 32) { dprintf("Wheel: Invalid left button: %i\n", cfg->left); @@ -249,16 +261,6 @@ static HRESULT idac_di_config_apply(const struct idac_di_config *cfg) return E_INVALIDARG; } - if (cfg->up > 32) { - dprintf("Wheel: Invalid up button: %i\n", cfg->up); - return E_INVALIDARG; - } - - if (cfg->down > 32) { - dprintf("Wheel: Invalid down button: %i\n", cfg->down); - return E_INVALIDARG; - } - if (cfg->shift_dn > 32) { dprintf("Wheel: Invalid shift down button: %i\n", cfg->shift_dn); @@ -292,10 +294,10 @@ 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: Left button . . . . : %i\n", cfg->left); - dprintf("Wheel: Right button . . . : %i\n", cfg->right); 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: 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); @@ -329,10 +331,10 @@ 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_left = cfg->left; - idac_di_right = cfg->right; idac_di_up = cfg->up; idac_di_down = cfg->down; + idac_di_left = cfg->left; + idac_di_right = cfg->right; idac_di_shift_dn = cfg->shift_dn; idac_di_shift_up = cfg->shift_up; idac_di_reverse_brake_axis = cfg->reverse_brake_axis; @@ -488,14 +490,6 @@ 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]) { - gamebtn |= IDAC_IO_GAMEBTN_LEFT; - } - - if (idac_di_right && state.st.rgbButtons[idac_di_right - 1]) { - gamebtn |= IDAC_IO_GAMEBTN_RIGHT; - } - if (idac_di_up && state.st.rgbButtons[idac_di_up - 1]) { gamebtn |= IDAC_IO_GAMEBTN_UP; } @@ -504,6 +498,14 @@ static void idac_di_get_buttons(uint8_t *gamebtn_out) gamebtn |= IDAC_IO_GAMEBTN_DOWN; } + 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; } diff --git a/games/idzio/config.c b/games/idzio/config.c index 369a4c5..81b3a70 100644 --- a/games/idzio/config.c +++ b/games/idzio/config.c @@ -58,6 +58,10 @@ void idz_di_config_load(struct idz_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->shift_dn = GetPrivateProfileIntW(L"dinput", L"shiftDn", 0, filename); cfg->shift_up = GetPrivateProfileIntW(L"dinput", L"shiftUp", 0, filename); diff --git a/games/idzio/config.h b/games/idzio/config.h index 7a17f00..78b4b50 100644 --- a/games/idzio/config.h +++ b/games/idzio/config.h @@ -16,6 +16,10 @@ struct idz_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 shift_dn; uint8_t shift_up; uint8_t gear[6]; diff --git a/games/idzio/di.c b/games/idzio/di.c index 00968fa..39be873 100644 --- a/games/idzio/di.c +++ b/games/idzio/di.c @@ -76,6 +76,10 @@ static uint8_t idz_di_shift_dn; static uint8_t idz_di_shift_up; static uint8_t idz_di_view_chg; static uint8_t idz_di_start; +static uint8_t idz_di_up; +static uint8_t idz_di_down; +static uint8_t idz_di_left; +static uint8_t idz_di_right; static uint8_t idz_di_gear[6]; static bool idz_di_use_pedals; static bool idz_di_reverse_brake_axis; @@ -276,6 +280,30 @@ static HRESULT idz_di_config_apply(const struct idz_di_config *cfg) return E_INVALIDARG; } + if (cfg->up > 32) { + dprintf("Wheel: Invalid up button: %i\n", cfg->up); + + return E_INVALIDARG; + } + + if (cfg->down > 32) { + dprintf("Wheel: Invalid down button: %i\n", cfg->down); + + 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) { dprintf("Wheel: Invalid shift down button: %i\n", cfg->shift_dn); @@ -309,6 +337,10 @@ static HRESULT idz_di_config_apply(const struct idz_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: 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); @@ -341,6 +373,10 @@ static HRESULT idz_di_config_apply(const struct idz_di_config *cfg) idz_di_off_brake = brake_axis->off; idz_di_off_accel = accel_axis->off; idz_di_start = cfg->start; + idz_di_up = cfg->up; + idz_di_down = cfg->down; + idz_di_left = cfg->left; + idz_di_right = cfg->right; idz_di_view_chg = cfg->view_chg; idz_di_shift_dn = cfg->shift_dn; idz_di_shift_up = cfg->shift_up; @@ -497,6 +533,22 @@ static void idz_di_jvs_read_buttons(uint8_t *gamebtn_out) gamebtn |= IDZ_IO_GAMEBTN_VIEW_CHANGE; } + if (idz_di_up && state.st.rgbButtons[idz_di_up - 1]) { + gamebtn |= IDZ_IO_GAMEBTN_UP; + } + + if (idz_di_down && state.st.rgbButtons[idz_di_down - 1]) { + gamebtn |= IDZ_IO_GAMEBTN_DOWN; + } + + if (idz_di_left && state.st.rgbButtons[idz_di_left - 1]) { + gamebtn |= IDZ_IO_GAMEBTN_LEFT; + } + + if (idz_di_right && state.st.rgbButtons[idz_di_right - 1]) { + gamebtn |= IDZ_IO_GAMEBTN_RIGHT; + } + *gamebtn_out = gamebtn; } diff --git a/games/swdcio/config.c b/games/swdcio/config.c index 4f095ce..9bf45a8 100644 --- a/games/swdcio/config.c +++ b/games/swdcio/config.c @@ -50,6 +50,10 @@ void swdc_di_config_load(struct swdc_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->paddle_left = GetPrivateProfileIntW(L"dinput", L"paddleLeft", 0, filename); cfg->paddle_right = GetPrivateProfileIntW(L"dinput", L"paddleRight", 0, filename); cfg->wheel_green = GetPrivateProfileIntW(L"dinput", L"wheelGreen", 0, filename); diff --git a/games/swdcio/config.h b/games/swdcio/config.h index 9a630a2..c4e2dc3 100644 --- a/games/swdcio/config.h +++ b/games/swdcio/config.h @@ -11,6 +11,10 @@ struct swdc_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 paddle_left; uint8_t paddle_right; uint8_t wheel_green; diff --git a/games/swdcio/di.c b/games/swdcio/di.c index 14c8a45..d0ac006 100644 --- a/games/swdcio/di.c +++ b/games/swdcio/di.c @@ -61,6 +61,10 @@ static uint8_t swdc_di_paddle_left; static uint8_t swdc_di_paddle_right; static uint8_t swdc_di_view_chg; static uint8_t swdc_di_start; +static uint8_t swdc_di_up; +static uint8_t swdc_di_down; +static uint8_t swdc_di_left; +static uint8_t swdc_di_right; static uint8_t swdc_di_wheel_green; static uint8_t swdc_di_wheel_red; static uint8_t swdc_di_wheel_blue; @@ -202,6 +206,30 @@ static HRESULT swdc_di_config_apply(const struct swdc_di_config *cfg) return E_INVALIDARG; } + if (cfg->up > 32) { + dprintf("Wheel: Invalid up button: %i\n", cfg->up); + + return E_INVALIDARG; + } + + if (cfg->down > 32) { + dprintf("Wheel: Invalid down button: %i\n", cfg->down); + + 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->paddle_left > 32) { dprintf("Wheel: Invalid left paddle button: %i\n", cfg->paddle_left); @@ -249,6 +277,10 @@ static HRESULT swdc_di_config_apply(const struct swdc_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: Paddle Left button . . : %i\n", cfg->paddle_left); dprintf("Wheel: Paddle Right button . : %i\n", cfg->paddle_right); dprintf("Wheel: Steering Green button : %i\n", cfg->wheel_green); @@ -272,6 +304,10 @@ static HRESULT swdc_di_config_apply(const struct swdc_di_config *cfg) swdc_di_off_accel = accel_axis->off; swdc_di_start = cfg->start; swdc_di_view_chg = cfg->view_chg; + swdc_di_up = cfg->up; + swdc_di_down = cfg->down; + swdc_di_left = cfg->left; + swdc_di_right = cfg->right; swdc_di_paddle_left = cfg->paddle_left; swdc_di_paddle_right = cfg->paddle_right; swdc_di_wheel_green = cfg->wheel_green; @@ -399,6 +435,22 @@ static void swdc_di_get_buttons(uint16_t *gamebtn_out) gamebtn |= SWDC_IO_GAMEBTN_VIEW_CHANGE; } + if (swdc_di_up && state.st.rgbButtons[swdc_di_up - 1]) { + gamebtn |= SWDC_IO_GAMEBTN_UP; + } + + if (swdc_di_down && state.st.rgbButtons[swdc_di_down - 1]) { + gamebtn |= SWDC_IO_GAMEBTN_DOWN; + } + + if (swdc_di_left && state.st.rgbButtons[swdc_di_left - 1]) { + gamebtn |= SWDC_IO_GAMEBTN_LEFT; + } + + if (swdc_di_right && state.st.rgbButtons[swdc_di_right - 1]) { + gamebtn |= SWDC_IO_GAMEBTN_RIGHT; + } + if (swdc_di_paddle_left && state.st.rgbButtons[swdc_di_paddle_left - 1]) { gamebtn |= SWDC_IO_GAMEBTN_STEERING_PADDLE_LEFT; }