overlay: mouse-as-touch needs to check if subscreen window is active (#842)
## Link to GitHub Issue or related Pull Request, if one exists Fixes #840 ## Description of change Currently, for subscreen games, mouse events are still delivered even when the subscreen overlay window is not visible. Change this so that the subscreen overlay must be active and under the mouse cursor for the mouse-to-touch transformation to occur. Applies to both native and wintouchemu. ## Testing Needs to test everything again.. iidx: - [ ] full screen with overlay - [ ] single window with overlay - [ ] two window Test: mouse, poke, api, real touch screen sdvx: - [ ] full screen with overlay - [ ] windowed popn - [x] full screen with overlay - [x] window with overlay - [x] dedicated window gitadora - [x] single window with overlay - [x] dedicated sub window nostalgia - [x] fullscreen - [x] windowed test: poke wintouchemu - [ ] Do all of the above again with wintouchemu
This commit is contained in:
@@ -41,7 +41,7 @@ namespace nativetouch::inject {
|
||||
}
|
||||
|
||||
POINT transformed = *position;
|
||||
return transform::screen_to_game(window, &transformed);
|
||||
return transform::mouse_to_game(window, &transformed);
|
||||
}
|
||||
|
||||
// release the active injected contact and its window capture
|
||||
@@ -108,7 +108,7 @@ namespace nativetouch::inject {
|
||||
}
|
||||
|
||||
POINT transformed = position;
|
||||
if (!transform::screen_to_game(window, &transformed)) {
|
||||
if (!transform::mouse_to_game(window, &transformed)) {
|
||||
end_mouse_contact(window);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace nativetouch::transform {
|
||||
static bool has_active_overlay_transform() {
|
||||
return overlay::OVERLAY != nullptr &&
|
||||
overlay::OVERLAY->get_active() &&
|
||||
overlay::OVERLAY->can_transform_touch_input();
|
||||
overlay::OVERLAY->has_subscreen_touch_transform();
|
||||
}
|
||||
|
||||
static bool transform_overlay_touch_position(POINT *position) {
|
||||
@@ -120,6 +120,25 @@ namespace nativetouch::transform {
|
||||
return transform_overlay_touch_position(position);
|
||||
}
|
||||
|
||||
bool mouse_to_game(HWND window, POINT *position) {
|
||||
|
||||
// exception: iidx tdj dedicated subscreen window is allowed
|
||||
if (is_tdj_dedicated_subscreen(window)) {
|
||||
return screen_to_game(window, position);
|
||||
}
|
||||
|
||||
// if this game has a subscreen overlay that can transform touch input
|
||||
// but the window is hidden or not under the cursor, reject mouse-as-touch
|
||||
// (e.g., iidx/sdvx are rejected here, but nostalgia is allowed)
|
||||
if (overlay::OVERLAY != nullptr &&
|
||||
overlay::OVERLAY->has_subscreen_touch_transform() &&
|
||||
!overlay::OVERLAY->accepts_subscreen_mouse_input()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return screen_to_game(window, position);
|
||||
}
|
||||
|
||||
// route hardware screen coordinates through dedicated or overlay mapping and report the result
|
||||
Result hardware_to_game(POINT *position) {
|
||||
const auto dedicated_subscreen = is_tdj_dedicated_subscreen(TDJ_SUBSCREEN_WINDOW);
|
||||
|
||||
@@ -12,5 +12,6 @@ namespace nativetouch::transform {
|
||||
bool is_tdj_dedicated_subscreen(HWND window);
|
||||
bool game_to_screen(HWND window, POINT *position);
|
||||
bool screen_to_game(HWND window, POINT *position);
|
||||
bool mouse_to_game(HWND window, POINT *position);
|
||||
Result hardware_to_game(POINT *position);
|
||||
}
|
||||
|
||||
@@ -944,7 +944,7 @@ void touch_get_points(std::vector<TouchPoint> &touch_points, bool overlay) {
|
||||
if (!overlay &&
|
||||
overlay::OVERLAY &&
|
||||
overlay::OVERLAY->get_active() &&
|
||||
!overlay::OVERLAY->can_transform_touch_input() &&
|
||||
!overlay::OVERLAY->has_subscreen_touch_transform() &&
|
||||
ImGui::GetIO().WantCaptureMouse) {
|
||||
|
||||
return;
|
||||
@@ -971,7 +971,7 @@ void touch_get_events(std::vector<TouchEvent> &touch_events, bool overlay) {
|
||||
if (!overlay &&
|
||||
overlay::OVERLAY &&
|
||||
overlay::OVERLAY->get_active() &&
|
||||
!overlay::OVERLAY->can_transform_touch_input() &&
|
||||
!overlay::OVERLAY->has_subscreen_touch_transform() &&
|
||||
ImGui::GetIO().WantCaptureMouse) {
|
||||
|
||||
TOUCH_EVENTS.reset();
|
||||
|
||||
Reference in New Issue
Block a user