Explorar o código

Allow triggering mouse button presses from a screen joystick while using touch emulation.

Lasse Öörni %!s(int64=11) %!d(string=hai) anos
pai
achega
8b5d884f3c
Modificáronse 1 ficheiros con 7 adicións e 2 borrados
  1. 7 2
      Source/Engine/Input/Input.cpp

+ 7 - 2
Source/Engine/Input/Input.cpp

@@ -1583,14 +1583,19 @@ void Input::HandleScreenJoystickTouch(StringHash eventType, VariantMap& eventDat
                 evt.key.keysym.sym = keyBindingVar.GetInt();
                 evt.key.keysym.sym = keyBindingVar.GetInt();
                 evt.key.keysym.scancode = SDL_SCANCODE_UNKNOWN;
                 evt.key.keysym.scancode = SDL_SCANCODE_UNKNOWN;
             }
             }
-            if (!mouseButtonBindingVar.IsEmpty() && !touchEmulation_)
+            if (!mouseButtonBindingVar.IsEmpty())
             {
             {
                 // Mouse button are sent as extra events besides key events
                 // Mouse button are sent as extra events besides key events
-                // Do not send mouse events in touch emulation mode, because those would in turn be re-interpreted as touch
+                // Disable touch emulation handling during this to prevent endless loop
+                bool oldTouchEmulation = touchEmulation_;
+                touchEmulation_ = false;
+                
                 SDL_Event evt;
                 SDL_Event evt;
                 evt.type = eventType == E_TOUCHBEGIN ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP;
                 evt.type = eventType == E_TOUCHBEGIN ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP;
                 evt.button.button = mouseButtonBindingVar.GetInt();
                 evt.button.button = mouseButtonBindingVar.GetInt();
                 HandleSDLEvent(&evt);
                 HandleSDLEvent(&evt);
+                
+                touchEmulation_ = oldTouchEmulation;
             }
             }
         }
         }
     }
     }