From 36222228bb3e6801363feea0443f810345bc3e12 Mon Sep 17 00:00:00 2001 From: Petr Bartos Date: Wed, 23 Mar 2022 18:02:23 +0100 Subject: [PATCH] Allow to draw cursor outside visible area to avoid weird jumping around edges when pointing outside --- .../app/src/main/cpp/code/q3_ui/ui_atoms.c | 20 +++++++----------- android/app/src/main/cpp/code/ui/ui_main.c | 21 +++++++------------ 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/android/app/src/main/cpp/code/q3_ui/ui_atoms.c b/android/app/src/main/cpp/code/q3_ui/ui_atoms.c index 5c760c48..9d634484 100644 --- a/android/app/src/main/cpp/code/q3_ui/ui_atoms.c +++ b/android/app/src/main/cpp/code/q3_ui/ui_atoms.c @@ -915,27 +915,23 @@ UI_MouseEvent void UI_MouseEvent( int dx, int dy ) { int i; - int bias; menucommon_s* m; if (!uis.activemenu) return; - // convert X bias to 640 coords - bias = uis.bias / UI_GetXScale(); - // update mouse screen position uis.cursorx += dx; - if (uis.cursorx < -bias) - uis.cursorx = -bias; - else if (uis.cursorx > SCREEN_WIDTH+bias) - uis.cursorx = SCREEN_WIDTH+bias; + if (uis.cursorx < -16) + uis.cursorx = -16; + else if (uis.cursorx > SCREEN_WIDTH+16) + uis.cursorx = SCREEN_WIDTH+16; uis.cursory += dy; - if (uis.cursory < 0) - uis.cursory = 0; - else if (uis.cursory > SCREEN_HEIGHT) - uis.cursory = SCREEN_HEIGHT; + if (uis.cursory < -16) + uis.cursory = -16; + else if (uis.cursory > SCREEN_HEIGHT+16) + uis.cursory = SCREEN_HEIGHT+16; vr->menuCursorX = &uis.cursorx; vr->menuCursorY = &uis.cursory; diff --git a/android/app/src/main/cpp/code/ui/ui_main.c b/android/app/src/main/cpp/code/ui/ui_main.c index f2fde787..75d3d065 100644 --- a/android/app/src/main/cpp/code/ui/ui_main.c +++ b/android/app/src/main/cpp/code/ui/ui_main.c @@ -5259,23 +5259,18 @@ UI_MouseEvent */ void _UI_MouseEvent( int dx, int dy ) { - int bias; - - // convert X bias to 640 coords - bias = uiInfo.uiDC.bias / uiInfo.uiDC.xscale; - // update mouse screen position uiInfo.uiDC.cursorx += dx; - if (uiInfo.uiDC.cursorx < -bias) - uiInfo.uiDC.cursorx = -bias; - else if (uiInfo.uiDC.cursorx > SCREEN_WIDTH+bias) - uiInfo.uiDC.cursorx = SCREEN_WIDTH+bias; + if (uiInfo.uiDC.cursorx < -16) + uiInfo.uiDC.cursorx = -16; + else if (uiInfo.uiDC.cursorx > SCREEN_WIDTH+16) + uiInfo.uiDC.cursorx = SCREEN_WIDTH+16; uiInfo.uiDC.cursory += dy; - if (uiInfo.uiDC.cursory < 0) - uiInfo.uiDC.cursory = 0; - else if (uiInfo.uiDC.cursory > SCREEN_HEIGHT) - uiInfo.uiDC.cursory = SCREEN_HEIGHT; + if (uiInfo.uiDC.cursory < -16) + uiInfo.uiDC.cursory = -16; + else if (uiInfo.uiDC.cursory > SCREEN_HEIGHT+16) + uiInfo.uiDC.cursory = SCREEN_HEIGHT+16; vr->menuCursorX = &uiInfo.uiDC.cursorx; vr->menuCursorY = &uiInfo.uiDC.cursory;