From 61df2a666c567b841cf030cf2b81100f50b5c5bd Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Fri, 20 Sep 2013 04:48:59 +0000 Subject: [PATCH] Clamp mouse position --- src/fbdriver.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/fbdriver.c b/src/fbdriver.c index c9771e4..fe8dff7 100644 --- a/src/fbdriver.c +++ b/src/fbdriver.c @@ -448,9 +448,21 @@ void check_input_events(void) if (ev.type == EV_REL) { if (ev.code == REL_X) + { g_mouse_raw_x += ev.value; + if (g_mouse_raw_x < 0) + g_mouse_raw_x = 0; + if (g_mouse_raw_x > 639) + g_mouse_raw_x = 639; + } else // REL_Y + { g_mouse_raw_y += ev.value; + if (g_mouse_raw_y < 0) + g_mouse_raw_y = 0; + if (g_mouse_raw_y > 399) + g_mouse_raw_y = 399; + } g_inputstate |= UPDATE_INPUT_MOUSE; } else if (ev.type == EV_KEY) @@ -496,4 +508,5 @@ int main(int argc,char *argv[]) exit(-1); gsportmain(argc, argv); xdriver_end(); + return 0; }