From 122034f922b2c50bc7c67a59971d767dfb614b6f Mon Sep 17 00:00:00 2001 From: Dniel97 Date: Sun, 27 Jul 2025 22:05:07 +0200 Subject: [PATCH 1/2] [fgo] improve keyboard bindings --- dist/fgo/segatools.ini | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/dist/fgo/segatools.ini b/dist/fgo/segatools.ini index 20d3633..b833a1a 100644 --- a/dist/fgo/segatools.ini +++ b/dist/fgo/segatools.ini @@ -194,19 +194,20 @@ stickDeadzone=7849 [keyboard] ; Keyboard bindings: -; Stick controls (default: WASD) +; Keyboard movement +; Default is WASD keys for Joystick movemnt up=0x57 -left=0x41 down=0x53 +left=0x41 right=0x44 -; Attack (default: Space) -attack=0x20 -; Dash (default: LSHIFT) -dash=0xa0 -; Change Target (default: J) -target=0x4A -; Re-center camera (default: K) -camera=0x4B -; Noble Phantasm (default: L) -np=0x4C +; Dash button. Default is the Left Shift, +dash=0xA0 +; Cycle Target button. Default is the F key. +target=0x46 +; Attack button, Default is the Right Mouse Button. +attack=0x02 +; Noble Phantasm button. Default is the Spacebar +np=0x20 +; Center Camera, Default is the C key +camera=0x43 From e74e2a0d479b3a225307adffa982dc1b3c3974c5 Mon Sep 17 00:00:00 2001 From: Dniel97 Date: Tue, 29 Jul 2025 18:06:10 +0200 Subject: [PATCH 2/2] [apm3, swdc, idac] DInput8 cleanup --- games/apm3io/di.c | 30 ++++++++++++++--------------- games/idacio/di.c | 48 +++------------------------------------------- games/swdcio/di.c | 49 ++++------------------------------------------- 3 files changed, 22 insertions(+), 105 deletions(-) diff --git a/games/apm3io/di.c b/games/apm3io/di.c index 9b6005f..29bac6e 100644 --- a/games/apm3io/di.c +++ b/games/apm3io/di.c @@ -1,9 +1,4 @@ #include -#include - -#include -#include -#include #include #include "apm3io/backend.h" @@ -25,9 +20,6 @@ static HRESULT apm3_di_config_apply(const struct apm3_di_config *cfg); static BOOL CALLBACK apm3_di_enum_callback( const DIDEVICEINSTANCEW *dev, void *ctx); -static BOOL CALLBACK apm3_di_enum_callback_shifter( - const DIDEVICEINSTANCEW *dev, - void *ctx); static void apm3_di_get_gamebtns(uint16_t *gamebtn_out); static uint8_t apm3_di_decode_pov(DWORD pov); @@ -42,7 +34,7 @@ static IDirectInputDevice8W *apm3_di_dev; static IDirectInputEffect *apm3_di_fx; static uint8_t apm3_di_home; static uint8_t apm3_di_start; -static uint8_t apm3_di_button[8]; +static uint8_t apm3_di_button[APM3_BUTTON_COUNT]; HRESULT apm3_di_init( const struct apm3_di_config *cfg, @@ -50,10 +42,6 @@ HRESULT apm3_di_init( const struct apm3_io_backend **backend) { HRESULT hr; - HMODULE dinput8; - HRESULT (WINAPI *api_entry)(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN); - wchar_t dll_path[MAX_PATH]; - UINT path_pos; assert(cfg != NULL); assert(backend != NULL); @@ -72,6 +60,18 @@ HRESULT apm3_di_init( return hr; } + hr = DirectInput8Create( + inst, + DIRECTINPUT_VERSION, + &IID_IDirectInput8W, + (void**)&apm3_di_api, + NULL); + + if (FAILED(hr)) { + dprintf("DirectInput: DirectInput8Create failed: %08x\n", (int)hr); + return hr; + } + hr = IDirectInput8_EnumDevices( apm3_di_api, DI8DEVCLASS_GAMECTRL, @@ -138,7 +138,7 @@ static HRESULT apm3_di_config_apply(const struct apm3_di_config *cfg) dprintf("Stick: Start button . . . : %i\n", cfg->start); /* Print the configuration for all 8 buttons */ - for (i = 0; i < 8; i++) { + for (i = 0; i < APM3_BUTTON_COUNT; i++) { dprintf("Stick: Button %i . . . . . : %i\n", i, cfg->button[i]); } @@ -147,7 +147,7 @@ static HRESULT apm3_di_config_apply(const struct apm3_di_config *cfg) apm3_di_start = cfg->start; apm3_di_home = cfg->home; - for (i = 0; i < 8; i++) { + for (i = 0; i < APM3_BUTTON_COUNT; i++) { apm3_di_button[i] = cfg->button[i]; } diff --git a/games/idacio/di.c b/games/idacio/di.c index 8a464ed..8a52e9c 100644 --- a/games/idacio/di.c +++ b/games/idacio/di.c @@ -1,11 +1,5 @@ #include -#include - #include -#include -#include -#include -#include #include "idacio/backend.h" #include "idacio/config.h" @@ -88,10 +82,6 @@ HRESULT idac_di_init( const struct idac_io_backend **backend) { HRESULT hr; - HMODULE dinput8; - HRESULT (WINAPI *api_entry)(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN); - wchar_t dll_path[MAX_PATH]; - UINT path_pos; assert(cfg != NULL); assert(backend != NULL); @@ -110,47 +100,15 @@ HRESULT idac_di_init( return hr; } - /* Initial D THE ARCADE 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 - talk to the real operating system implementation of DirectInput without - the stub DLL interfering, so build a path to - C:\Windows\System32\dinput.dll here. */ - - dll_path[0] = L'\0'; - path_pos = GetSystemDirectoryW(dll_path, _countof(dll_path)); - wcscat_s( - dll_path + path_pos, - _countof(dll_path) - path_pos, - L"\\dinput8.dll"); - - dinput8 = LoadLibraryW(dll_path); - - if (dinput8 == NULL) { - hr = HRESULT_FROM_WIN32(GetLastError()); - dprintf("DirectInput: LoadLibrary failed: %08x\n", (int) hr); - - return hr; - } - - api_entry = (void *) GetProcAddress(dinput8, "DirectInput8Create"); - - if (api_entry == NULL) { - dprintf("DirectInput: GetProcAddress failed\n"); - - return E_FAIL; - } - - hr = api_entry( + hr = DirectInput8Create( inst, DIRECTINPUT_VERSION, &IID_IDirectInput8W, - (void **) &idac_di_api, + (void**)&idac_di_api, NULL); if (FAILED(hr)) { - dprintf("DirectInput: API create failed: %08x\n", (int) hr); - + dprintf("DirectInput: DirectInput8Create failed: %08x\n", (int)hr); return hr; } diff --git a/games/swdcio/di.c b/games/swdcio/di.c index 8012454..14c8a45 100644 --- a/games/swdcio/di.c +++ b/games/swdcio/di.c @@ -1,11 +1,5 @@ #include -#include - #include -#include -#include -#include -#include #include "swdcio/backend.h" #include "swdcio/config.h" @@ -81,10 +75,6 @@ HRESULT swdc_di_init( const struct swdc_io_backend **backend) { HRESULT hr; - HMODULE dinput8; - HRESULT (WINAPI *api_entry)(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN); - wchar_t dll_path[MAX_PATH]; - UINT path_pos; assert(cfg != NULL); assert(backend != NULL); @@ -103,46 +93,15 @@ HRESULT swdc_di_init( return hr; } - /* SWDC has some built-in DirectInput support that is not - particularly useful. swdchook shorts this out by redirecting dinput8.dll - to a no-op implementation of DirectInput. However, swdcio does need to - talk to the real operating system implementation of DirectInput without - the stub DLL interfering, so build a path to - C:\Windows\System32\dinput.dll here. */ - - dll_path[0] = L'\0'; - path_pos = GetSystemDirectoryW(dll_path, _countof(dll_path)); - wcscat_s( - dll_path + path_pos, - _countof(dll_path) - path_pos, - L"\\dinput8.dll"); - - dinput8 = LoadLibraryW(dll_path); - - if (dinput8 == NULL) { - hr = HRESULT_FROM_WIN32(GetLastError()); - dprintf("DirectInput: LoadLibrary failed: %08x\n", (int) hr); - - return hr; - } - - api_entry = (void *) GetProcAddress(dinput8, "DirectInput8Create"); - - if (api_entry == NULL) { - dprintf("DirectInput: GetProcAddress failed\n"); - - return E_FAIL; - } - - hr = api_entry( + hr = DirectInput8Create( inst, DIRECTINPUT_VERSION, &IID_IDirectInput8W, - (void **) &swdc_di_api, + (void**)&swdc_di_api, NULL); - + if (FAILED(hr)) { - dprintf("DirectInput: API create failed: %08x\n", (int) hr); + dprintf("DirectInput: DirectInput8Create failed: %08x\n", (int) hr); return hr; }