Browse Source

Restored the previous mouse move logic for Emscripten only.

Lasse Öörni 10 years ago
parent
commit
f42dd05319
1 changed files with 11 additions and 0 deletions
  1. 11 0
      Source/Urho3D/Input/Input.cpp

+ 11 - 0
Source/Urho3D/Input/Input.cpp

@@ -360,7 +360,12 @@ void Input::Update()
     #endif
 
     // Check for relative mode mouse move
+    // Note that Emscripten will use SDL mouse move events for relative mode instead
+    #ifndef EMSCRIPTEN
     if (!touchEmulation_ && (graphics_->GetExternalWindow() || (!mouseVisible_ && inputFocus_ && (flags & SDL_WINDOW_MOUSE_FOCUS))))
+    #else
+    if (!touchEmulation_ && mouseMode_ != MM_RELATIVE && (graphics_->GetExternalWindow() || (!mouseVisible_ && inputFocus_ && (flags & SDL_WINDOW_MOUSE_FOCUS))))
+    #endif
     {
         IntVector2 mousePosition = GetMousePosition();
         mouseMove_ = mousePosition - lastMousePosition_;
@@ -1563,7 +1568,13 @@ void Input::HandleSDLEvent(void* sdlEvent)
         break;
 
     case SDL_MOUSEMOTION:
+        // Emscripten will use SDL mouse move events for relative mode, as repositioning the mouse and
+        // measuring distance from window center is not supported
+        #ifndef EMSCRIPTEN
         if (mouseVisible_ && !touchEmulation_)
+        #else
+        if ((mouseVisible_ || mouseMode_ == MM_RELATIVE) && !touchEmulation_)
+        #endif
         {
             mouseMove_.x_ += evt.motion.xrel;
             mouseMove_.y_ += evt.motion.yrel;