sdvx, touch: hook Windows touch API when main monitor is rotated 270 degrees (portrait flipped) (#558)

## Link to GitHub Issue, if one exists
n/a

## Description of change
Game expects primary monitor to be in 90 deg rotation, and does the
touch calculation accordingly.

If the user does 270 deg rotation ("portrait, flipped") then the game's
touch calculation is flipped upside down. Detect this and provide the
fixed up values in the touch hook.

## Testing
Tested with SDVX in 90 deg, 270 deg rotation, and 1080p, forced 1440p.
This commit is contained in:
bicarus
2026-02-27 14:22:56 -08:00
committed by GitHub
parent 955c50a9f3
commit 954e6022d9
4 changed files with 45 additions and 9 deletions
+5 -2
View File
@@ -21,8 +21,9 @@
#include "util/socd_cleaner.h" #include "util/socd_cleaner.h"
#include "util/time.h" #include "util/time.h"
#include "util/libutils.h" #include "util/libutils.h"
#include "misc/wintouchemu.h"
#include "misc/eamuse.h" #include "misc/eamuse.h"
#include "misc/nativetouchhook.h"
#include "misc/wintouchemu.h"
#include "bi2x_hook.h" #include "bi2x_hook.h"
#include "camera.h" #include "camera.h"
#include "io.h" #include "io.h"
@@ -416,9 +417,11 @@ namespace games::sdvx {
} }
if (is_valkyrie_model()) { if (is_valkyrie_model()) {
if (NATIVETOUCH) {
nativetouchhook::hook(avs::game::DLL_INSTANCE);
} else if (!NATIVETOUCH && !GRAPHICS_WINDOWED) {
// hook touch window // hook touch window
// in windowed mode, game can accept mouse input on the second screen // in windowed mode, game can accept mouse input on the second screen
if (!NATIVETOUCH && !GRAPHICS_WINDOWED) {
wintouchemu::FORCE = true; wintouchemu::FORCE = true;
wintouchemu::INJECT_MOUSE_AS_WM_TOUCH = true; wintouchemu::INJECT_MOUSE_AS_WM_TOUCH = true;
wintouchemu::hook_title_ends( wintouchemu::hook_title_ends(
+27
View File
@@ -2,7 +2,10 @@
// mingw otherwise doesn't load touch stuff // mingw otherwise doesn't load touch stuff
#define _WIN32_WINNT 0x0601 #define _WIN32_WINNT 0x0601
#include "avs/game.h"
#include "wintouchemu.h" #include "wintouchemu.h"
#include "rawinput/touch.h"
#include "hooks/graphics/graphics.h"
#include "util/detour.h" #include "util/detour.h"
#include "util/logging.h" #include "util/logging.h"
@@ -63,6 +66,11 @@ namespace nativetouchhook {
point->cyContact = 0; 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( static BOOL WINAPI GetTouchInputInfoHook(
HTOUCHINPUT hTouchInput, UINT cInputs, PTOUCHINPUT pInputs, int cbSize) { HTOUCHINPUT hTouchInput, UINT cInputs, PTOUCHINPUT pInputs, int cbSize) {
@@ -72,11 +80,30 @@ namespace nativetouchhook {
return result; 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++) { for (size_t i = 0; i < cInputs; i++) {
PTOUCHINPUT point = &pInputs[i]; PTOUCHINPUT point = &pInputs[i];
if (avs::game::is_model("LDJ")) {
strip_contact_size(point); strip_contact_size(point);
} }
if (flip_values) {
flip_touch_points(point);
}
}
return result; return result;
} }
+4 -4
View File
@@ -26,10 +26,10 @@ namespace rawinput::touch {
bool INVERTED = false; bool INVERTED = false;
// state // state
static bool DISPLAY_INITIALIZED = false; DWORD DISPLAY_ORIENTATION = DMDO_DEFAULT;
static DWORD DISPLAY_ORIENTATION = DMDO_DEFAULT; long DISPLAY_SIZE_X = 1920L;
static long DISPLAY_SIZE_X = 1920L; long DISPLAY_SIZE_Y = 1080L;
static long DISPLAY_SIZE_Y = 1080L; bool DISPLAY_INITIALIZED = false;
bool is_touchscreen(Device *device) { bool is_touchscreen(Device *device) {
+6
View File
@@ -9,6 +9,12 @@ namespace rawinput::touch {
extern bool DISABLED; extern bool DISABLED;
extern bool INVERTED; 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); bool is_touchscreen(Device *device);
void enable(Device *device); void enable(Device *device);
void disable(Device *device); void disable(Device *device);