# HG changeset patch # User John Tsiombikas # Date 1335068128 -10800 # Node ID 0f305fc0b5482add6a479a7228316ef4df609f1c # Parent 3fae5eb6a411f8f41eda64d72991807bc2971713 fixed the mouse warping in low framerates diff -r 3fae5eb6a411 -r 0f305fc0b548 src/game.cc --- a/src/game.cc Sun Apr 22 06:39:23 2012 +0300 +++ b/src/game.cc Sun Apr 22 07:15:28 2012 +0300 @@ -150,6 +150,8 @@ prev_y = y; } +#define EDGE_PIXELS (win_ysz / 4) + void game_input_mmotion(int x, int y) { int dx = x - prev_x; @@ -157,7 +159,8 @@ prev_x = x; prev_y = y; - if(ignore_next_motion) { + if(ignore_next_motion || abs(dx) >= win_xsz / 2 - EDGE_PIXELS || + abs(dy) >= win_ysz / 2 - EDGE_PIXELS) { ignore_next_motion = false; return; } @@ -165,8 +168,9 @@ if(dbg_inside) { ship.turn((float)-dx / win_xsz, (float)-dy / win_ysz); - ignore_next_motion = true; - glutWarpPointer(win_xsz / 2, win_ysz / 2); + if(x < EDGE_PIXELS || x >= win_xsz - EDGE_PIXELS || y < EDGE_PIXELS || y >= win_ysz - EDGE_PIXELS) { + glutWarpPointer(win_xsz / 2, win_ysz / 2); + } } else { if(bnstate[0]) { dbgcam.input_rotate(10.0 * dx / win_xsz, 10.0 * dy / win_ysz, 0);