Skip to content

Commit

Permalink
INPUT: Block touch motion events, and debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
meag committed Jan 23, 2021
1 parent 9d844ea commit 5245371
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions vid_sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,25 +793,32 @@ static void HandleEvents(void)
keyb_textinputevent(event.text.text);
break;
case SDL_MOUSEMOTION:
if (mouse_active && !SDL_GetRelativeMouseMode()) {
float factor = (IN_MouseTrackingRequired() ? cursor_sensitivity.value : 1);

mx = event.motion.x - old_x;
my = event.motion.y - old_y;
cursor_x = min(max(0, cursor_x + (event.motion.x - glConfig.vidWidth / 2) * factor), VID_RenderWidth2D());
cursor_y = min(max(0, cursor_y + (event.motion.y - glConfig.vidHeight / 2) * factor), VID_RenderHeight2D());
SDL_WarpMouseInWindow(sdl_window, glConfig.vidWidth / 2, glConfig.vidHeight / 2);
old_x = glConfig.vidWidth / 2;
old_y = glConfig.vidHeight / 2;
}
else {
float factor = (IN_MouseTrackingRequired() ? cursor_sensitivity.value : 1);
if (event.motion.which != SDL_TOUCH_MOUSEID || !in_ignore_touch_events.integer) {
#ifdef __APPLE__
if (developer.integer == 2) {
Con_Printf("motion event, which = %d\n", event.motion.which);
}
#endif
if (mouse_active && !SDL_GetRelativeMouseMode()) {
float factor = (IN_MouseTrackingRequired() ? cursor_sensitivity.value : 1);

mx = event.motion.x - old_x;
my = event.motion.y - old_y;
cursor_x = min(max(0, cursor_x + (event.motion.x - glConfig.vidWidth / 2) * factor), VID_RenderWidth2D());
cursor_y = min(max(0, cursor_y + (event.motion.y - glConfig.vidHeight / 2) * factor), VID_RenderHeight2D());
SDL_WarpMouseInWindow(sdl_window, glConfig.vidWidth / 2, glConfig.vidHeight / 2);
old_x = glConfig.vidWidth / 2;
old_y = glConfig.vidHeight / 2;
}
else {
float factor = (IN_MouseTrackingRequired() ? cursor_sensitivity.value : 1);

cursor_x += event.motion.xrel * factor;
cursor_y += event.motion.yrel * factor;
cursor_x += event.motion.xrel * factor;
cursor_y += event.motion.yrel * factor;

cursor_x = bound(0, cursor_x, VID_RenderWidth2D());
cursor_y = bound(0, cursor_y, VID_RenderHeight2D());
cursor_x = bound(0, cursor_x, VID_RenderWidth2D());
cursor_y = bound(0, cursor_y, VID_RenderHeight2D());
}
}
break;
case SDL_MOUSEBUTTONDOWN:
Expand Down

0 comments on commit 5245371

Please sign in to comment.