浏览代码

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

Lasse Öörni 11 年之前
父节点
当前提交
8b5d884f3c
共有 1 个文件被更改,包括 7 次插入2 次删除
  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.scancode = SDL_SCANCODE_UNKNOWN;
             }
-            if (!mouseButtonBindingVar.IsEmpty() && !touchEmulation_)
+            if (!mouseButtonBindingVar.IsEmpty())
             {
                 // 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;
                 evt.type = eventType == E_TOUCHBEGIN ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP;
                 evt.button.button = mouseButtonBindingVar.GetInt();
                 HandleSDLEvent(&evt);
+                
+                touchEmulation_ = oldTouchEmulation;
             }
         }
     }