mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 22:55:40 +12:00
SDL: Fix mouse coords in gyroscope emulation
This commit is contained in:
parent
11e7eb7fd6
commit
13bff60257
1 changed files with 7 additions and 2 deletions
|
@ -247,8 +247,13 @@ void FrontendSDL::run() {
|
||||||
|
|
||||||
// Handle "dragging" across the touchscreen
|
// Handle "dragging" across the touchscreen
|
||||||
if (hid.isTouchScreenPressed()) {
|
if (hid.isTouchScreenPressed()) {
|
||||||
const s32 x = event.motion.x;
|
if (windowWidth == 0 || windowHeight == 0) [[unlikely]] {
|
||||||
const s32 y = event.motion.y;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Go from window positions to [0, 400) for x and [0, 480) for y
|
||||||
|
const s32 x = (s32)std::round(event.motion.x * 400.f / windowWidth);
|
||||||
|
const s32 y = (s32)std::round(event.motion.y * 480.f / windowHeight);
|
||||||
|
|
||||||
// Check if touch falls in the touch screen area and register the new touch screen position
|
// Check if touch falls in the touch screen area and register the new touch screen position
|
||||||
if (y >= 240 && y <= 480 && x >= 40 && x < 40 + 320) {
|
if (y >= 240 && y <= 480 && x >= 40 && x < 40 + 320) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue