mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-02-20 19:12:11 +00:00
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.
This commit is contained in:
parent
412dad6758
commit
61d3efec98
1 changed files with 17 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue