From 61d3efec98b04d45b6cc6c4a0b5f3ffe732fdfec Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Wed, 30 Sep 2015 18:38:27 +0200 Subject: [PATCH] Fix mouse cursor moving to fast in fullscreen GUIs (main menu, PDA) The fullscreen guis pretend to be 640x480 internally, also for the mouse cursor position. So adding the actually moved pixels (when playing the game at a higher resolution) to the GUIs cursor position makes it move too fast. To fix that I detect (hopefully that check is reliable!) if the idUserInterfaceLocal instance is a fullscreen GUI and if so scale the reported mouse moved pixels with 640/actual_window_width and 480/actual_window_height. --- neo/ui/UserInterface.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/neo/ui/UserInterface.cpp b/neo/ui/UserInterface.cpp index 1c1647c8..f4844d6a 100644 --- a/neo/ui/UserInterface.cpp +++ b/neo/ui/UserInterface.cpp @@ -342,8 +342,23 @@ const char *idUserInterfaceLocal::HandleEvent( const sysEvent_t *event, int _tim } if ( event->evType == SE_MOUSE ) { - cursorX += event->evValue; - cursorY += event->evValue2; + if ( !desktop || (desktop->GetFlags() & WIN_MENUGUI) ) { + // DG: this is a fullscreen GUI, scale the mousedelta added to cursorX/Y + // so by 640/w, because the GUI pretends that everything is 640x480 + // even if the actual resolution is higher => mouse moved too fast + float w = renderSystem->GetScreenWidth(); + float h = renderSystem->GetScreenHeight(); + if( w <= 0.0f || h <= 0.0f ) { + w = 640.0f; + h = 480.0f; + } + cursorX += event->evValue * (640.0f/w); + cursorY += event->evValue2 * (480.0f/h); + } else { + // not a fullscreen GUI but some ingame thing - no scaling needed + cursorX += event->evValue; + cursorY += event->evValue2; + } if (cursorX < 0) { cursorX = 0;