]> code.delx.au - refind/blobdiff - refind/menu.c
Use AbsoluteMaxX and Y to determine actual screen position touched
[refind] / refind / menu.c
index 762fd7ae2cb985199fb17445755498e457fee082..471922826d1c03ec75e5b85ca5e9a31307c88317 100644 (file)
@@ -396,7 +396,7 @@ static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Sty
     UINTN MenuExit;
        
        EFI_STATUS TouchStatus = EFI_NOT_READY;
-       EFI_ABSOLUTE_POINTER_STATE *TouchState = NULL;
+       EFI_ABSOLUTE_POINTER_STATE TouchState;
 
     if (Screen->TimeoutSeconds > 0) {
         HaveTimeout = TRUE;
@@ -469,7 +469,7 @@ static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Sty
 
         // read key press or touch event (and wait for them if applicable)
         if(TouchEnabled) {
-             TouchStatus = refit_call2_wrapper(TouchProtocol->GetState, TouchProtocol, TouchState);
+             TouchStatus = refit_call2_wrapper(TouchProtocol->GetState, TouchProtocol, &TouchState);
         }
         Status = refit_call2_wrapper(ST->ConIn->ReadKeyStroke, ST->ConIn, &key);
 
@@ -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