forked from Hay1tsme/segatools
Compare commits
7 Commits
2025-07-27
...
2025-08-06
Author | SHA1 | Date | |
---|---|---|---|
43486709a1
|
|||
55a3859891
|
|||
74e3cb2f84
|
|||
3f2cfb6a26
|
|||
80f34fe6f0
|
|||
e74e2a0d47
|
|||
122034f922
|
3
dist/apm3/launch.bat
vendored
3
dist/apm3/launch.bat
vendored
@ -20,7 +20,8 @@ pushd %~dp0
|
|||||||
qprocess amdaemon.exe > NUL
|
qprocess amdaemon.exe > NUL
|
||||||
IF %ERRORLEVEL% NEQ 0 start /min "AM Daemon" inject -d -k apm3hook.dll amdaemon.exe -c daemon_config\common.json daemon_config\server.json config_hook.json
|
IF %ERRORLEVEL% NEQ 0 start /min "AM Daemon" inject -d -k apm3hook.dll amdaemon.exe -c daemon_config\common.json daemon_config\server.json config_hook.json
|
||||||
|
|
||||||
inject -d -k apm3hook.dll APMV3System -screen-fullscreen 0 -screen-width 1920 -screen-height 1080 -popupWindow -logFile output_log.txt
|
REM Add "-screen-fullscreen 0 -popupWindow" if you want to run in windowed mode
|
||||||
|
inject -d -k apm3hook.dll APMV3System -logFile output_log.txt
|
||||||
|
|
||||||
if exist %tmp%\segaboot (
|
if exist %tmp%\segaboot (
|
||||||
del %tmp%\segaboot
|
del %tmp%\segaboot
|
||||||
|
25
dist/fgo/segatools.ini
vendored
25
dist/fgo/segatools.ini
vendored
@ -194,19 +194,20 @@ stickDeadzone=7849
|
|||||||
[keyboard]
|
[keyboard]
|
||||||
; Keyboard bindings:
|
; Keyboard bindings:
|
||||||
|
|
||||||
; Stick controls (default: WASD)
|
; Keyboard movement
|
||||||
|
; Default is WASD keys for Joystick movemnt
|
||||||
up=0x57
|
up=0x57
|
||||||
left=0x41
|
|
||||||
down=0x53
|
down=0x53
|
||||||
|
left=0x41
|
||||||
right=0x44
|
right=0x44
|
||||||
|
|
||||||
; Attack (default: Space)
|
; Dash button. Default is the Left Shift,
|
||||||
attack=0x20
|
dash=0xA0
|
||||||
; Dash (default: LSHIFT)
|
; Cycle Target button. Default is the F key.
|
||||||
dash=0xa0
|
target=0x46
|
||||||
; Change Target (default: J)
|
; Attack button, Default is the Right Mouse Button.
|
||||||
target=0x4A
|
attack=0x02
|
||||||
; Re-center camera (default: K)
|
; Noble Phantasm button. Default is the Spacebar
|
||||||
camera=0x4B
|
np=0x20
|
||||||
; Noble Phantasm (default: L)
|
; Center Camera, Default is the C key
|
||||||
np=0x4C
|
camera=0x43
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <dinput.h>
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "apm3io/backend.h"
|
#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(
|
static BOOL CALLBACK apm3_di_enum_callback(
|
||||||
const DIDEVICEINSTANCEW *dev,
|
const DIDEVICEINSTANCEW *dev,
|
||||||
void *ctx);
|
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 void apm3_di_get_gamebtns(uint16_t *gamebtn_out);
|
||||||
static uint8_t apm3_di_decode_pov(DWORD pov);
|
static uint8_t apm3_di_decode_pov(DWORD pov);
|
||||||
|
|
||||||
@ -42,7 +34,7 @@ static IDirectInputDevice8W *apm3_di_dev;
|
|||||||
static IDirectInputEffect *apm3_di_fx;
|
static IDirectInputEffect *apm3_di_fx;
|
||||||
static uint8_t apm3_di_home;
|
static uint8_t apm3_di_home;
|
||||||
static uint8_t apm3_di_start;
|
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(
|
HRESULT apm3_di_init(
|
||||||
const struct apm3_di_config *cfg,
|
const struct apm3_di_config *cfg,
|
||||||
@ -50,10 +42,6 @@ HRESULT apm3_di_init(
|
|||||||
const struct apm3_io_backend **backend)
|
const struct apm3_io_backend **backend)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
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(cfg != NULL);
|
||||||
assert(backend != NULL);
|
assert(backend != NULL);
|
||||||
@ -72,6 +60,18 @@ HRESULT apm3_di_init(
|
|||||||
return hr;
|
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(
|
hr = IDirectInput8_EnumDevices(
|
||||||
apm3_di_api,
|
apm3_di_api,
|
||||||
DI8DEVCLASS_GAMECTRL,
|
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);
|
dprintf("Stick: Start button . . . : %i\n", cfg->start);
|
||||||
|
|
||||||
/* Print the configuration for all 8 buttons */
|
/* 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]);
|
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_start = cfg->start;
|
||||||
apm3_di_home = cfg->home;
|
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];
|
apm3_di_button[i] = cfg->button[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,18 +88,9 @@ void idac_hook_config_load(
|
|||||||
platform_config_load(&cfg->platform, filename);
|
platform_config_load(&cfg->platform, filename);
|
||||||
aime_config_load(&cfg->aime, filename);
|
aime_config_load(&cfg->aime, filename);
|
||||||
idac_dll_config_load(&cfg->dll, filename);
|
idac_dll_config_load(&cfg->dll, filename);
|
||||||
zinput_config_load(&cfg->zinput, filename);
|
|
||||||
dvd_config_load(&cfg->dvd, filename);
|
dvd_config_load(&cfg->dvd, filename);
|
||||||
io4_config_load(&cfg->io4, filename);
|
io4_config_load(&cfg->io4, filename);
|
||||||
ffb_config_load(&cfg->ffb, filename);
|
ffb_config_load(&cfg->ffb, filename);
|
||||||
led15070_config_load(&cfg->led15070, filename);
|
led15070_config_load(&cfg->led15070, filename);
|
||||||
indrun_config_load(&cfg->indrun, filename);
|
indrun_config_load(&cfg->indrun, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zinput_config_load(struct zinput_config *cfg, const wchar_t *filename)
|
|
||||||
{
|
|
||||||
assert(cfg != NULL);
|
|
||||||
assert(filename != NULL);
|
|
||||||
|
|
||||||
cfg->enable = GetPrivateProfileIntW(L"zinput", L"enable", 1, filename);
|
|
||||||
}
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "hooklib/dvd.h"
|
#include "hooklib/dvd.h"
|
||||||
|
|
||||||
#include "idachook/idac-dll.h"
|
#include "idachook/idac-dll.h"
|
||||||
#include "idachook/zinput.h"
|
|
||||||
#include "idachook/indrun.h"
|
#include "idachook/indrun.h"
|
||||||
|
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
@ -21,7 +20,6 @@ struct idac_hook_config {
|
|||||||
struct io4_config io4;
|
struct io4_config io4;
|
||||||
struct ffb_config ffb;
|
struct ffb_config ffb;
|
||||||
struct idac_dll_config dll;
|
struct idac_dll_config dll;
|
||||||
struct zinput_config zinput;
|
|
||||||
struct led15070_config led15070;
|
struct led15070_config led15070;
|
||||||
struct indrun_config indrun;
|
struct indrun_config indrun;
|
||||||
};
|
};
|
||||||
@ -34,10 +32,6 @@ void idac_hook_config_load(
|
|||||||
struct idac_hook_config *cfg,
|
struct idac_hook_config *cfg,
|
||||||
const wchar_t *filename);
|
const wchar_t *filename);
|
||||||
|
|
||||||
void zinput_config_load(
|
|
||||||
struct zinput_config *cfg,
|
|
||||||
const wchar_t *filename);
|
|
||||||
|
|
||||||
void indrun_config_load(
|
void indrun_config_load(
|
||||||
struct indrun_config *cfg,
|
struct indrun_config *cfg,
|
||||||
const wchar_t *filename);
|
const wchar_t *filename);
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "idachook/idac-dll.h"
|
#include "idachook/idac-dll.h"
|
||||||
#include "idachook/io4.h"
|
#include "idachook/io4.h"
|
||||||
#include "idachook/ffb.h"
|
#include "idachook/ffb.h"
|
||||||
#include "idachook/zinput.h"
|
|
||||||
|
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
|
|
||||||
@ -55,7 +54,6 @@ static DWORD CALLBACK idac_pre_startup(void)
|
|||||||
/* Hook Win32 APIs */
|
/* Hook Win32 APIs */
|
||||||
|
|
||||||
serial_hook_init();
|
serial_hook_init();
|
||||||
zinput_hook_init(&idac_hook_cfg.zinput);
|
|
||||||
dvd_hook_init(&idac_hook_cfg.dvd, idac_hook_mod);
|
dvd_hook_init(&idac_hook_cfg.dvd, idac_hook_mod);
|
||||||
|
|
||||||
/* Initialize emulation hooks */
|
/* Initialize emulation hooks */
|
||||||
|
@ -25,8 +25,6 @@ shared_library(
|
|||||||
'idac-dll.h',
|
'idac-dll.h',
|
||||||
'io4.c',
|
'io4.c',
|
||||||
'io4.h',
|
'io4.h',
|
||||||
'zinput.c',
|
|
||||||
'zinput.h',
|
|
||||||
'indrun.c',
|
'indrun.c',
|
||||||
'indrun.h',
|
'indrun.h',
|
||||||
'ffb.c',
|
'ffb.c',
|
||||||
|
@ -1,187 +0,0 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <dinput.h>
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "idachook/config.h"
|
|
||||||
#include "idachook/zinput.h"
|
|
||||||
|
|
||||||
#include "hook/table.h"
|
|
||||||
|
|
||||||
#include "util/dprintf.h"
|
|
||||||
|
|
||||||
HRESULT WINAPI hook_DirectInput8Create(
|
|
||||||
HINSTANCE hinst,
|
|
||||||
DWORD dwVersion,
|
|
||||||
REFIID riidltf,
|
|
||||||
LPVOID *ppvOut,
|
|
||||||
LPUNKNOWN punkOuter);
|
|
||||||
|
|
||||||
static unsigned long WINAPI hook_AddRef(IUnknown *self);
|
|
||||||
|
|
||||||
static unsigned long WINAPI hook_Release(IUnknown *self);
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_CreateDevice(
|
|
||||||
IDirectInput8W *self,
|
|
||||||
REFGUID rguid,
|
|
||||||
LPDIRECTINPUTDEVICE8W * lplpDirectInputDevice,
|
|
||||||
LPUNKNOWN pUnkOuter);
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_EnumDevices(
|
|
||||||
IDirectInput8W *self,
|
|
||||||
DWORD dwDevType,
|
|
||||||
LPDIENUMDEVICESCALLBACKW lpCallback,
|
|
||||||
LPVOID pvRef,
|
|
||||||
DWORD dwFlags);
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_SetDataFormat(
|
|
||||||
IDirectInputDevice8W *self,
|
|
||||||
LPCDIDATAFORMAT lpdf);
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_SetCooperativeLevel(
|
|
||||||
IDirectInputDevice8W *self,
|
|
||||||
HWND hwnd,
|
|
||||||
DWORD flags);
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_Acquire(IDirectInputDevice8W *self);
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_Unacquire(IDirectInputDevice8W *self);
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_GetDeviceState(
|
|
||||||
IDirectInputDevice8W *self,
|
|
||||||
DWORD cbData,
|
|
||||||
LPVOID lpvData);
|
|
||||||
|
|
||||||
static const IDirectInput8WVtbl api_vtbl = {
|
|
||||||
.AddRef = (void *) hook_AddRef,
|
|
||||||
.Release = (void *) hook_Release,
|
|
||||||
.CreateDevice = hook_CreateDevice,
|
|
||||||
.EnumDevices = hook_EnumDevices,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const IDirectInput8W api = { (void *) &api_vtbl };
|
|
||||||
|
|
||||||
static const IDirectInputDevice8WVtbl dev_vtbl = {
|
|
||||||
.AddRef = (void *) hook_AddRef,
|
|
||||||
.Release = (void *) hook_Release,
|
|
||||||
.SetDataFormat = hook_SetDataFormat,
|
|
||||||
.SetCooperativeLevel= hook_SetCooperativeLevel,
|
|
||||||
.Acquire = hook_Acquire,
|
|
||||||
.Unacquire = hook_Unacquire,
|
|
||||||
.GetDeviceState = hook_GetDeviceState,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const IDirectInputDevice8W dev = { (void *) &dev_vtbl };
|
|
||||||
|
|
||||||
static const struct hook_symbol zinput_hook_syms[] = {
|
|
||||||
{
|
|
||||||
.name = "DirectInput8Create",
|
|
||||||
.patch = hook_DirectInput8Create,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HRESULT zinput_hook_init(struct zinput_config *cfg)
|
|
||||||
{
|
|
||||||
assert(cfg != NULL);
|
|
||||||
|
|
||||||
if (!cfg->enable) {
|
|
||||||
return S_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
hook_table_apply(
|
|
||||||
NULL,
|
|
||||||
"dinput8.dll",
|
|
||||||
zinput_hook_syms,
|
|
||||||
_countof(zinput_hook_syms));
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT WINAPI hook_DirectInput8Create(
|
|
||||||
HINSTANCE hinst,
|
|
||||||
DWORD dwVersion,
|
|
||||||
REFIID riidltf,
|
|
||||||
LPVOID *ppvOut,
|
|
||||||
LPUNKNOWN punkOuter)
|
|
||||||
{
|
|
||||||
dprintf("ZInput: Blocking built-in DirectInput support\n");
|
|
||||||
*ppvOut = (void *) &api;
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned long WINAPI hook_AddRef(IUnknown *self)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned long WINAPI hook_Release(IUnknown *self)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_CreateDevice(
|
|
||||||
IDirectInput8W *self,
|
|
||||||
REFGUID rguid,
|
|
||||||
LPDIRECTINPUTDEVICE8W *lplpDirectInputDevice,
|
|
||||||
LPUNKNOWN pUnkOuter)
|
|
||||||
{
|
|
||||||
dprintf("ZInput: %s\n", __func__);
|
|
||||||
*lplpDirectInputDevice = (void *) &dev;
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_EnumDevices(
|
|
||||||
IDirectInput8W *self,
|
|
||||||
DWORD dwDevType,
|
|
||||||
LPDIENUMDEVICESCALLBACKW lpCallback,
|
|
||||||
LPVOID pvRef,
|
|
||||||
DWORD dwFlags)
|
|
||||||
{
|
|
||||||
dprintf("ZInput: %s\n", __func__);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_SetDataFormat(
|
|
||||||
IDirectInputDevice8W *self,
|
|
||||||
LPCDIDATAFORMAT lpdf)
|
|
||||||
{
|
|
||||||
dprintf("ZInput: %s\n", __func__);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_SetCooperativeLevel(
|
|
||||||
IDirectInputDevice8W *self,
|
|
||||||
HWND hwnd,
|
|
||||||
DWORD flags)
|
|
||||||
{
|
|
||||||
dprintf("ZInput: %s\n", __func__);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_Acquire(IDirectInputDevice8W *self)
|
|
||||||
{
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_Unacquire(IDirectInputDevice8W *self)
|
|
||||||
{
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI hook_GetDeviceState(
|
|
||||||
IDirectInputDevice8W *self,
|
|
||||||
DWORD cbData,
|
|
||||||
LPVOID lpvData)
|
|
||||||
{
|
|
||||||
memset(lpvData, 0, cbData);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
struct zinput_config {
|
|
||||||
bool enable;
|
|
||||||
};
|
|
||||||
|
|
||||||
HRESULT zinput_hook_init(struct zinput_config *cfg);
|
|
@ -1,11 +1,5 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <dinput.h>
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
#include "idacio/backend.h"
|
#include "idacio/backend.h"
|
||||||
#include "idacio/config.h"
|
#include "idacio/config.h"
|
||||||
@ -88,10 +82,6 @@ HRESULT idac_di_init(
|
|||||||
const struct idac_io_backend **backend)
|
const struct idac_io_backend **backend)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
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(cfg != NULL);
|
||||||
assert(backend != NULL);
|
assert(backend != NULL);
|
||||||
@ -110,38 +100,7 @@ HRESULT idac_di_init(
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initial D THE ARCADE has some built-in DirectInput support that is not
|
hr = DirectInput8Create(
|
||||||
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(
|
|
||||||
inst,
|
inst,
|
||||||
DIRECTINPUT_VERSION,
|
DIRECTINPUT_VERSION,
|
||||||
&IID_IDirectInput8W,
|
&IID_IDirectInput8W,
|
||||||
@ -149,8 +108,7 @@ HRESULT idac_di_init(
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
dprintf("DirectInput: API create failed: %08x\n", (int) hr);
|
dprintf("DirectInput: DirectInput8Create failed: %08x\n", (int)hr);
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <dinput.h>
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
#include "swdcio/backend.h"
|
#include "swdcio/backend.h"
|
||||||
#include "swdcio/config.h"
|
#include "swdcio/config.h"
|
||||||
@ -81,10 +75,6 @@ HRESULT swdc_di_init(
|
|||||||
const struct swdc_io_backend **backend)
|
const struct swdc_io_backend **backend)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
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(cfg != NULL);
|
||||||
assert(backend != NULL);
|
assert(backend != NULL);
|
||||||
@ -103,38 +93,7 @@ HRESULT swdc_di_init(
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SWDC has some built-in DirectInput support that is not
|
hr = DirectInput8Create(
|
||||||
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(
|
|
||||||
inst,
|
inst,
|
||||||
DIRECTINPUT_VERSION,
|
DIRECTINPUT_VERSION,
|
||||||
&IID_IDirectInput8W,
|
&IID_IDirectInput8W,
|
||||||
@ -142,7 +101,7 @@ HRESULT swdc_di_init(
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
dprintf("DirectInput: API create failed: %08x\n", (int) hr);
|
dprintf("DirectInput: DirectInput8Create failed: %08x\n", (int) hr);
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ static int16_t calculate_norm_steering(int16_t axis, uint16_t deadzone, bool lin
|
|||||||
|
|
||||||
// optionally normalize the magnitude with respect to its expected range
|
// optionally normalize the magnitude with respect to its expected range
|
||||||
// giving a magnitude value of 0.0 to 1.0
|
// giving a magnitude value of 0.0 to 1.0
|
||||||
norm_magnitude = (int16_t)(magnitude / (max_stick_value - deadzone));
|
norm_magnitude = (magnitude / (max_stick_value - deadzone));
|
||||||
} else // if the controller is in the deadzone zero out the magnitude
|
} else // if the controller is in the deadzone zero out the magnitude
|
||||||
{
|
{
|
||||||
magnitude = 0.0;
|
magnitude = 0.0;
|
||||||
|
Reference in New Issue
Block a user