Files
spice2x.github.io/src/spice2x/touch/touch.h
T
bicarus 623e1e3998 touch: inject mouse and poke into native touch modes (#815)
## Link to GitHub Issue or related Pull Request, if one exists
Part 1 of many fixes for #814.

## Description of change
For the native touch hook - add code to inject synthetic touches using
Windows API (`InjectTouchInput`).

Note that this is Windows 8+ only, but we can make an assumption that we
are running on Win10+ for these games (TDJ/UFC/High Cheers) since the
cabs assume Win10.

Detect mouse events and allow IIDX poke to call into this to inject
synthetic touches.

Also, update the nativetouchhook to independently calculate window size
and rotation, instead of relying on rawinput layer.

## Testing
Tested to work with native touch option on IIDX, SDVX, POPN, all full
screen / windowed / sub on/off combinations.

Edge cases:

* sdvx main monitor rotated 270 deg
* touch invert option
* windowed mode resize / moved

All seem to work.
2026-07-21 00:04:38 -07:00

46 lines
1.1 KiB
C++

#pragma once
#include <vector>
#include <windows.h>
struct TouchPoint {
DWORD id;
LONG x, y;
bool mouse;
double down_ms = 0.0; // performance-counter milliseconds when the contact first landed
};
enum TouchEventType {
TOUCH_DOWN,
TOUCH_MOVE,
TOUCH_UP
};
struct TouchEvent {
DWORD id;
LONG x, y;
TouchEventType type;
bool mouse;
};
extern bool SPICETOUCH_CARD_DISABLE;
extern HWND SPICETOUCH_TOUCH_HWND;
extern int SPICETOUCH_TOUCH_X;
extern int SPICETOUCH_TOUCH_Y;
extern int SPICETOUCH_TOUCH_WIDTH;
extern int SPICETOUCH_TOUCH_HEIGHT;
bool is_touch_available(LPCSTR caller);
bool is_mouse_message_from_touchscreen();
void touch_attach_wnd(HWND hWnd);
void touch_attach_dx_hook();
void touch_create_wnd(HWND hWnd, bool overlay = false);
void touch_detach();
void touch_write_points(std::vector<TouchPoint> *touch_points);
void touch_remove_points(std::vector<DWORD> *touch_point_ids);
void touch_get_points(std::vector<TouchPoint> &touch_points, bool overlay = false);
void touch_get_events(std::vector<TouchEvent> &touch_events, bool overlay = false);
void update_spicetouch_window_dimensions(HWND hWnd);