Use AbsoluteMaxX and Y to determine actual screen position touched
authorTom Briden <tom@decompile.me.uk>
Thu, 27 Oct 2016 15:59:37 +0000 (16:59 +0100)
committerTom Briden <tom@decompile.me.uk>
Thu, 27 Oct 2016 16:06:30 +0000 (17:06 +0100)
If the AbsoluteMax doesn't match the screen resolution then the touch
position passed in to FindMainMenuItem is totally wrong

refind/menu.c

index 4191e5d..4719228 100644 (file)
@@ -614,7 +614,11 @@ static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Sty
                     break;
             }
         } else { //react to touch event
-            UINTN Item = FindMainMenuItem(Screen, &State, TouchState.CurrentX, TouchState.CurrentY);
+            //the TouchProtocol min/max may not match the screen size
+            UINT32 TouchScreenPosX = (TouchState.CurrentX * UGAWidth) / TouchProtocol->Mode->AbsoluteMaxX;
+            UINT32 TouchScreenPosY = (TouchState.CurrentY * UGAHeight) / TouchProtocol->Mode->AbsoluteMaxY;
+
+            UINTN Item = FindMainMenuItem(Screen, &State, TouchScreenPosX, TouchScreenPosY);
             switch (Item) {
                 case TOUCH_NO_ITEM:
                     //do nothing