mirror of
https://gitea.tendokyu.moe/TeamTofuShop/segatools.git
synced 2026-09-22 22:37:59 +03:00
soul: Fix touch
This commit is contained in:
@@ -24,6 +24,7 @@ void touch_screen_config_load(struct touch_screen_config *cfg, const wchar_t *fi
|
||||
cfg->enable = GetPrivateProfileIntW(L"touch", L"enable", 1, filename);
|
||||
cfg->remap = GetPrivateProfileIntW(L"touch", L"remap", 1, filename);
|
||||
cfg->cursor = GetPrivateProfileIntW(L"touch", L"cursor", 1, filename);
|
||||
cfg->setwndptr = GetPrivateProfileIntW(L"touch", L"setwndptr", 0, filename);
|
||||
}
|
||||
|
||||
void printer_config_load(struct printer_config *cfg, const wchar_t *filename)
|
||||
|
||||
+22
-2
@@ -43,6 +43,8 @@ static BOOL WINAPI hook_GetTouchInputInfo(
|
||||
|
||||
static HCURSOR WINAPI hook_SetCursor(HCURSOR cursor);
|
||||
|
||||
static LONG_PTR WINAPI hook_SetWindowLongPtrA(HWND hWnd, int nIndex, LONG_PTR dwNewLong);
|
||||
|
||||
/* Link pointers */
|
||||
|
||||
static ATOM (WINAPI *next_RegisterClassExA)(
|
||||
@@ -67,6 +69,8 @@ static BOOL (WINAPI *next_GetTouchInputInfo)(
|
||||
|
||||
static HCURSOR(WINAPI *next_SetCursor)(HCURSOR cursor);
|
||||
|
||||
static LONG_PTR (WINAPI *next_SetWindowLongPtrA)(HWND hWnd, int nIndex, LONG_PTR dwNewLong);
|
||||
|
||||
static bool touch_hook_initted;
|
||||
static bool touch_held;
|
||||
static HWND registered_hWnd;
|
||||
@@ -100,6 +104,11 @@ static const struct hook_symbol touch_hooks[] = {
|
||||
.patch = hook_SetCursor,
|
||||
.link = (void **) &next_SetCursor
|
||||
},
|
||||
{
|
||||
.name = "SetWindowLongPtrA",
|
||||
.patch = hook_SetWindowLongPtrA,
|
||||
.link = (void**) &next_SetWindowLongPtrA
|
||||
},
|
||||
};
|
||||
|
||||
void touch_screen_hook_init(const struct touch_screen_config *cfg, HINSTANCE self)
|
||||
@@ -152,7 +161,7 @@ static LRESULT hook_wndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
|
||||
static ATOM WINAPI hook_RegisterClassExA(
|
||||
WNDCLASSEXA* wndClass
|
||||
) {
|
||||
if (wndClass->lpfnWndProc) {
|
||||
if (!touch_config.setwndptr && wndClass->lpfnWndProc) {
|
||||
orig_wndProc = wndClass->lpfnWndProc;
|
||||
wndClass->lpfnWndProc = (WNDPROC) hook_wndProc;
|
||||
}
|
||||
@@ -182,6 +191,17 @@ static BOOL WINAPI hook_RegisterTouchWindow(
|
||||
return true;
|
||||
}
|
||||
|
||||
// Soul Reverse uses this to initialize wndprocs handling input
|
||||
|
||||
static LONG_PTR WINAPI hook_SetWindowLongPtrA(HWND hWnd, int nIndex, LONG_PTR dwNewLong) {
|
||||
if (touch_config.setwndptr && nIndex == -4) {
|
||||
orig_wndProc = (WNDPROC) dwNewLong;
|
||||
dwNewLong = (LONG_PTR) hook_wndProc;
|
||||
}
|
||||
|
||||
return next_SetWindowLongPtrA(hWnd, nIndex, dwNewLong);
|
||||
}
|
||||
|
||||
// Converting mouse event to touch event
|
||||
static BOOL WINAPI hook_GetTouchInputInfo(
|
||||
HANDLE hTouchInput,
|
||||
@@ -231,7 +251,7 @@ static BOOL WINAPI hook_GetTouchInputInfo(
|
||||
touch_input->x = cursorPos.x * 100;
|
||||
touch_input->y = cursorPos.y * 100;
|
||||
touch_input->hSource = hTouchInput;
|
||||
touch_input->dwID = 0;
|
||||
touch_input->dwID = 1;
|
||||
touch_input->dwFlags = 0;
|
||||
if (mouse_state && !mouse_state_old) {
|
||||
touch_input->dwFlags |= TOUCHEVENTF_DOWN;
|
||||
|
||||
@@ -8,6 +8,7 @@ struct touch_screen_config {
|
||||
bool enable;
|
||||
bool remap;
|
||||
bool cursor;
|
||||
bool setwndptr;
|
||||
};
|
||||
|
||||
/* Init is not thread safe because API hook init is not thread safe blah
|
||||
|
||||
Vendored
+3
-1
@@ -104,8 +104,10 @@ dipsw1=1
|
||||
[touch]
|
||||
; WinTouch emulation setting.
|
||||
enable=1
|
||||
remap=1
|
||||
remap=0
|
||||
cursor=1
|
||||
; Alternative hooking method for Soul Reverse
|
||||
setwndptr=1
|
||||
|
||||
; -----------------------------------------------------------------------------
|
||||
; Custom IO settings
|
||||
|
||||
Reference in New Issue
Block a user