mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Fixed bug 4581 - generate synthetic mouse events at window boundaries
when real touch events are actually outside the window.
This commit is contained in:
parent
cfefe5434a
commit
aae49015da
@ -257,21 +257,19 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid,
|
||||
if (finger_touching == SDL_FALSE) {
|
||||
int pos_x = (int)(x * (float)window->w);
|
||||
int pos_y = (int)(y * (float)window->h);
|
||||
if (pos_x >= 0 && pos_y >= 0 && pos_x < window->w && pos_y < window->h) {
|
||||
if (pos_x < 0) pos_x = 0;
|
||||
if (pos_x > window->w - 1) pos_x = window->w - 1;
|
||||
if (pos_y < 0) pos_y = 0;
|
||||
if (pos_y > window->h - 1) pos_y = window->h - 1;
|
||||
SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
|
||||
SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) {
|
||||
int pos_x = (int)(x * (float)window->w);
|
||||
int pos_y = (int)(y * (float)window->h);
|
||||
if (pos_x >= 0 && pos_y >= 0 && pos_x < window->w && pos_y < window->h) {
|
||||
SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (down) {
|
||||
if (finger_touching == SDL_FALSE) {
|
||||
finger_touching = SDL_TRUE;
|
||||
@ -361,14 +359,16 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid,
|
||||
if (finger_touching == SDL_TRUE && track_touchid == id && track_fingerid == fingerid) {
|
||||
int pos_x = (int)(x * (float)window->w);
|
||||
int pos_y = (int)(y * (float)window->h);
|
||||
if (pos_x >= 0 && pos_y >= 0 && pos_x < window->w && pos_y < window->h) {
|
||||
if (pos_x < 0) pos_x = 0;
|
||||
if (pos_x > window->w - 1) pos_x = window->w - 1;
|
||||
if (pos_y < 0) pos_y = 0;
|
||||
if (pos_y > window->h - 1) pos_y = window->h - 1;
|
||||
SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, pos_x, pos_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
finger = SDL_GetFinger(touch,fingerid);
|
||||
if (!finger) {
|
||||
|
Loading…
Reference in New Issue
Block a user