From 112ec0d6378ea258a387b10b9e6cc7c1a32f40e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Strohh=C3=A4cker?= Date: Mon, 5 Nov 2007 21:46:26 +0000 Subject: [PATCH] don't speed up small mouse movements; skip some duplicate mouse events (don't add a move if another move is already in the queue) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3041 --- src/ints/mouse.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ints/mouse.cpp b/src/ints/mouse.cpp index a95c7116..5b1fe4ba 100644 --- a/src/ints/mouse.cpp +++ b/src/ints/mouse.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: mouse.cpp,v 1.70 2007-11-05 17:49:17 c2woody Exp $ */ +/* $Id: mouse.cpp,v 1.71 2007-11-05 21:46:26 c2woody Exp $ */ #include #include @@ -198,11 +198,15 @@ Bitu PS2_Handler(void) { INLINE void Mouse_AddEvent(Bit16u type) { if (mouse.events0) { + /* Skip duplicate events */ + if ((type==MOUSE_MOVED) && (mouse.buttons==0)) return; + /* Always put the newest element in the front as that the events are + * handled backwards (prevents doubleclicks while moving) + */ + for(Bitu i = mouse.events ; i ; i--) + mouse.event_queue[i] = mouse.event_queue[i-1]; + } mouse.event_queue[0].type=type; mouse.event_queue[0].buttons=mouse.buttons; mouse.events++; @@ -415,8 +419,8 @@ void Mouse_CursorMoved(float xrel,float yrel,float x,float y,bool emulate) { float dx = xrel * mouse.pixelPerMickey_x; float dy = yrel * mouse.pixelPerMickey_y; - if((fabs(x) > 1.0) || (mouse.senv_x < 1.0)) dx *= mouse.senv_x; - if((fabs(y) > 1.0) || (mouse.senv_y < 1.0)) dy *= mouse.senv_y; + if((fabs(xrel) > 1.0) || (mouse.senv_x < 1.0)) dx *= mouse.senv_x; + if((fabs(yrel) > 1.0) || (mouse.senv_y < 1.0)) dy *= mouse.senv_y; if (useps2callback) dy *= 2; mouse.mickey_x += dx;