Update to spice2x-25-04-25 (pre-apply)

> broken commit
This commit is contained in:
[ ]
2025-05-07 00:25:31 +09:00
parent 04dee88276
commit c94de456b5
543 changed files with 78491 additions and 91698 deletions
+63 -30
View File
@@ -34,7 +34,10 @@ const char *INSERT_CARD_TEXT = "Insert Card";
static const int TOUCH_EVENT_BUFFER_SIZE = 1024 * 4;
static const int TOUCH_EVENT_BUFFER_THRESHOLD1 = 1024 * 2;
static const int TOUCH_EVENT_BUFFER_THRESHOLD2 = 1024 * 3;
bool SPICETOUCH_CARD_DISABLE = false;
// in mainline spicetools, this was false (show by default)
// in spice2x, this is true (hide by default)
bool SPICETOUCH_CARD_DISABLE = true;
HWND SPICETOUCH_TOUCH_HWND = nullptr;
int SPICETOUCH_TOUCH_X = 0;
int SPICETOUCH_TOUCH_Y = 0;
@@ -135,8 +138,15 @@ static void touch_initialize() {
}
SPICETOUCH_INITIALIZED = true;
if (!RI_MGR) {
log_fatal(
LOG_MODULE_NAME,
"touch_initialize() - RI Manager not available, called too early! "
"This is a BUG in spice, please file a bug report with log.txt.");
}
// initialize handler
if (RI_MGR && rawinput::touch::is_enabled(RI_MGR.get())) {
if (rawinput::touch::is_enabled(RI_MGR.get())) {
TOUCH_HANDLER = new RawInputTouchHandler();
} else if (Win8Handler::is_available()) {
TOUCH_HANDLER = new Win8Handler();
@@ -163,13 +173,26 @@ static inline void touch_unregister_window(HWND hWnd) {
}
}
bool is_touch_available() {
bool is_touch_available(LPCSTR caller) {
static bool called_once = false;
if (!RI_MGR) {
log_fatal(
LOG_MODULE_NAME,
"is_touch_available({}) - RI Manager not available, called too early! "
"This is a BUG in spice, please file a bug report with log.txt.",
caller);
}
// initialize touch handler
touch_initialize();
// Check if a touch handler has been set. No need to call `is_available` here
// as `touch_initialize` does that.
if (!called_once) {
log_misc("touch", "is_touch_available called by: {}, returning {}",
caller, (TOUCH_HANDLER != nullptr) ? "TRUE" : "false");
called_once = true;
}
return TOUCH_HANDLER != nullptr;
}
@@ -199,7 +222,7 @@ static LRESULT CALLBACK SpiceTouchWndProc(HWND hWnd, UINT msg, WPARAM wParam, LP
SPICETOUCH_REGISTERED_TOUCH = true;
// check if touch is available
if (is_touch_available()) {
if (is_touch_available("SpiceTouchWndProc")) {
// notify the handler of our window
TOUCH_HANDLER->window_register(hWnd);
@@ -217,6 +240,13 @@ static LRESULT CALLBACK SpiceTouchWndProc(HWND hWnd, UINT msg, WPARAM wParam, LP
rawinput::touch::display_update();
}
if (msg == WM_CLOSE) {
if ((GRAPHICS_IIDX_WSUB && hWnd == TDJ_SUBSCREEN_WINDOW) || (hWnd == SDVX_SUBSCREEN_WINDOW)) {
log_misc("touch", "ignore WM_CLOSE for subscreen window");
return false;
}
}
// check messages for dedicated window
if (SPICETOUCH_TOUCH_THREAD != nullptr) {
@@ -431,7 +461,7 @@ static LRESULT CALLBACK SpiceTouchWndProc(HWND hWnd, UINT msg, WPARAM wParam, LP
};
// check if imgui is handling this mouse event
if (overlay::OVERLAY != nullptr && ImGui::GetIO().WantCaptureMouse) {
if (overlay::OVERLAY != nullptr && overlay::OVERLAY->get_active() && ImGui::GetIO().WantCaptureMouse) {
result.action = ACTION_RETURN_DEFAULT;
} else if (TOUCH_HANDLER != nullptr) {
@@ -666,19 +696,8 @@ void touch_create_wnd(HWND hWnd, bool overlay) {
return;
}
// get window rect
RECT windowRect {};
GetWindowRect(hWnd, &windowRect);
// adjust to client area
POINT p {.x = 0, .y = 0};
ClientToScreen(hWnd, &p);
windowRect.top = p.y;
int touch_x = windowRect.left;
int touch_y = windowRect.top;
int touch_width = windowRect.right - touch_x;
int touch_height = windowRect.bottom - touch_y;
// calculate touch window dimensions
update_spicetouch_window_dimensions(hWnd);
// create window
HWND touch_window = CreateWindowExA(
@@ -686,17 +705,19 @@ void touch_create_wnd(HWND hWnd, bool overlay) {
SPICETOUCH_CLASS_NAME,
"SpiceTools Touch",
(DWORD) CW_USEDEFAULT,
touch_x,
touch_y,
touch_width,
touch_height,
SPICETOUCH_TOUCH_X,
SPICETOUCH_TOUCH_Y,
SPICETOUCH_TOUCH_WIDTH,
SPICETOUCH_TOUCH_HEIGHT,
hWnd,
nullptr,
GetModuleHandle(nullptr),
nullptr
);
log_info(LOG_MODULE_NAME, "creating SpiceTouch window {}x{} @ {}, {}", touch_x, touch_y, touch_width, touch_height);
log_misc(
LOG_MODULE_NAME, "create SpiceTouch window ({}x{} @ {}, {})",
SPICETOUCH_TOUCH_WIDTH, SPICETOUCH_TOUCH_HEIGHT, SPICETOUCH_TOUCH_X, SPICETOUCH_TOUCH_Y);
// check window
if (touch_window == nullptr) {
@@ -704,12 +725,8 @@ void touch_create_wnd(HWND hWnd, bool overlay) {
return;
}
// save reference and dimensions
// save reference
SPICETOUCH_TOUCH_HWND = touch_window;
SPICETOUCH_TOUCH_X = touch_x;
SPICETOUCH_TOUCH_Y = touch_y;
SPICETOUCH_TOUCH_WIDTH = touch_width;
SPICETOUCH_TOUCH_HEIGHT = touch_height;
// window settings
ShowWindow(touch_window, SW_SHOWNOACTIVATE);
@@ -915,3 +932,19 @@ void touch_get_events(std::vector<TouchEvent> &touch_events, bool overlay) {
touch_events.push_back(TOUCH_EVENTS.get());
}
}
void update_spicetouch_window_dimensions(HWND hWnd) {
RECT clientRect {};
GetClientRect(hWnd, &clientRect);
// adjust to client area
POINT topleft {.x = 0, .y = 0};
ClientToScreen(hWnd, &topleft);
POINT bottomright {.x = clientRect.right, .y = clientRect.bottom};
ClientToScreen(hWnd, &bottomright);
SPICETOUCH_TOUCH_X = topleft.x;
SPICETOUCH_TOUCH_Y = topleft.y;
SPICETOUCH_TOUCH_WIDTH = bottomright.x - topleft.x;
SPICETOUCH_TOUCH_HEIGHT = bottomright.y - topleft.y;
}
+3 -1
View File
@@ -27,7 +27,7 @@ extern int SPICETOUCH_TOUCH_Y;
extern int SPICETOUCH_TOUCH_WIDTH;
extern int SPICETOUCH_TOUCH_HEIGHT;
bool is_touch_available();
bool is_touch_available(LPCSTR caller);
void touch_attach_wnd(HWND hWnd);
void touch_attach_dx_hook();
@@ -39,3 +39,5 @@ 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);
+57
View File
@@ -0,0 +1,57 @@
// set version to Windows 8 to enable Windows 8 touch functions
#define _WIN32_WINNT 0x0602
#include "touch_indicators.h"
#include "util/libutils.h"
#include "util/logging.h"
static HINSTANCE USER32_INSTANCE = nullptr;
typedef BOOL (WINAPI *SetWindowFeedbackSetting_t)(HWND, FEEDBACK_TYPE, DWORD, UINT32, const VOID *);
static SetWindowFeedbackSetting_t pSetWindowFeedbackSetting = nullptr;
void disable_touch_indicators(HWND hwnd) {
if (USER32_INSTANCE == nullptr) {
USER32_INSTANCE = libutils::load_library("user32.dll");
}
if (USER32_INSTANCE == nullptr) {
return;
}
if (pSetWindowFeedbackSetting == nullptr) {
pSetWindowFeedbackSetting = libutils::try_proc<SetWindowFeedbackSetting_t>(
USER32_INSTANCE, "SetWindowFeedbackSetting");
}
if (pSetWindowFeedbackSetting == nullptr) {
return;
}
log_info("touch_indicators", "disable visual feedback for touch events for HWND={}", fmt::ptr(hwnd));
BOOL enabled = FALSE;
pSetWindowFeedbackSetting(
hwnd,
FEEDBACK_TOUCH_CONTACTVISUALIZATION,
0, sizeof(enabled), &enabled);
pSetWindowFeedbackSetting(
hwnd,
FEEDBACK_TOUCH_TAP,
0, sizeof(enabled), &enabled);
pSetWindowFeedbackSetting(
hwnd,
FEEDBACK_TOUCH_DOUBLETAP,
0, sizeof(enabled), &enabled);
pSetWindowFeedbackSetting(
hwnd,
FEEDBACK_TOUCH_PRESSANDHOLD,
0, sizeof(enabled), &enabled);
pSetWindowFeedbackSetting(
hwnd,
FEEDBACK_TOUCH_RIGHTTAP,
0, sizeof(enabled), &enabled);
pSetWindowFeedbackSetting(
hwnd,
FEEDBACK_GESTURE_PRESSANDTAP,
0, sizeof(enabled), &enabled);
}
+5
View File
@@ -0,0 +1,5 @@
#pragma once
#include <windows.h>
void disable_touch_indicators(HWND hwnd);