diff --git a/src/spice2x/games/sdvx/sdvx.cpp b/src/spice2x/games/sdvx/sdvx.cpp index b4f02c7..20a7265 100644 --- a/src/spice2x/games/sdvx/sdvx.cpp +++ b/src/spice2x/games/sdvx/sdvx.cpp @@ -21,8 +21,9 @@ #include "util/socd_cleaner.h" #include "util/time.h" #include "util/libutils.h" -#include "misc/wintouchemu.h" #include "misc/eamuse.h" +#include "misc/nativetouchhook.h" +#include "misc/wintouchemu.h" #include "bi2x_hook.h" #include "camera.h" #include "io.h" @@ -416,9 +417,11 @@ namespace games::sdvx { } if (is_valkyrie_model()) { - // hook touch window - // in windowed mode, game can accept mouse input on the second screen - if (!NATIVETOUCH && !GRAPHICS_WINDOWED) { + if (NATIVETOUCH) { + nativetouchhook::hook(avs::game::DLL_INSTANCE); + } else if (!NATIVETOUCH && !GRAPHICS_WINDOWED) { + // hook touch window + // in windowed mode, game can accept mouse input on the second screen wintouchemu::FORCE = true; wintouchemu::INJECT_MOUSE_AS_WM_TOUCH = true; wintouchemu::hook_title_ends( diff --git a/src/spice2x/misc/nativetouchhook.cpp b/src/spice2x/misc/nativetouchhook.cpp index 92b5298..8441653 100644 --- a/src/spice2x/misc/nativetouchhook.cpp +++ b/src/spice2x/misc/nativetouchhook.cpp @@ -2,7 +2,10 @@ // mingw otherwise doesn't load touch stuff #define _WIN32_WINNT 0x0601 +#include "avs/game.h" #include "wintouchemu.h" +#include "rawinput/touch.h" +#include "hooks/graphics/graphics.h" #include "util/detour.h" #include "util/logging.h" @@ -63,6 +66,11 @@ namespace nativetouchhook { point->cyContact = 0; } + static void flip_touch_points(PTOUCHINPUT point) { + point->x = rawinput::touch::DISPLAY_SIZE_X * 100 - point->x; + point->y = rawinput::touch::DISPLAY_SIZE_Y * 100 - point->y; + } + static BOOL WINAPI GetTouchInputInfoHook( HTOUCHINPUT hTouchInput, UINT cInputs, PTOUCHINPUT pInputs, int cbSize) { @@ -72,9 +80,28 @@ namespace nativetouchhook { return result; } + bool flip_values = false; + if (avs::game::is_model("KFC") && rawinput::touch::DISPLAY_INITIALIZED) { + log_debug( + "touch::native", "DISPLAY_ORIENTATION = {}, DISPLAY_SIZE_X = {}, DISPLAY_SIZE_Y = {}", + rawinput::touch::DISPLAY_ORIENTATION, + rawinput::touch::DISPLAY_SIZE_X, + rawinput::touch::DISPLAY_SIZE_Y); + if (rawinput::touch::DISPLAY_ORIENTATION == DMDO_270) { + flip_values = true; + } + } + for (size_t i = 0; i < cInputs; i++) { PTOUCHINPUT point = &pInputs[i]; - strip_contact_size(point); + + if (avs::game::is_model("LDJ")) { + strip_contact_size(point); + } + + if (flip_values) { + flip_touch_points(point); + } } return result; diff --git a/src/spice2x/rawinput/touch.cpp b/src/spice2x/rawinput/touch.cpp index 7b7ac70..530acc1 100644 --- a/src/spice2x/rawinput/touch.cpp +++ b/src/spice2x/rawinput/touch.cpp @@ -26,10 +26,10 @@ namespace rawinput::touch { bool INVERTED = false; // state - static bool DISPLAY_INITIALIZED = false; - static DWORD DISPLAY_ORIENTATION = DMDO_DEFAULT; - static long DISPLAY_SIZE_X = 1920L; - static long DISPLAY_SIZE_Y = 1080L; + DWORD DISPLAY_ORIENTATION = DMDO_DEFAULT; + long DISPLAY_SIZE_X = 1920L; + long DISPLAY_SIZE_Y = 1080L; + bool DISPLAY_INITIALIZED = false; bool is_touchscreen(Device *device) { diff --git a/src/spice2x/rawinput/touch.h b/src/spice2x/rawinput/touch.h index a301111..2c527a5 100644 --- a/src/spice2x/rawinput/touch.h +++ b/src/spice2x/rawinput/touch.h @@ -9,6 +9,12 @@ namespace rawinput::touch { extern bool DISABLED; extern bool INVERTED; + // global state + extern DWORD DISPLAY_ORIENTATION; + extern long DISPLAY_SIZE_X; + extern long DISPLAY_SIZE_Y; + extern bool DISPLAY_INITIALIZED; + bool is_touchscreen(Device *device); void enable(Device *device); void disable(Device *device);