Prechádzať zdrojové kódy

Add touch emulation stationary fingers for multi-gestures by pressing down other mouse buttons than the left.

Lasse Öörni 11 rokov pred
rodič
commit
cbf91aaa8a
2 zmenil súbory, kde vykonal 6 pridanie a 5 odobranie
  1. 1 1
      Docs/Reference.dox
  2. 5 4
      Source/Engine/Input/Input.cpp

+ 1 - 1
Docs/Reference.dox

@@ -1393,7 +1393,7 @@ Whenever a recognized gesture is entered by the user, the E_GESTUREINPUT event w
 
 Touch input can also emulate a virtual joystick by displaying on-screen buttons. See the function \ref Input::AddScreenJoystick "AddScreenJoystick()".
 
-Touch emulation can be used to test mobile applications on a desktop machine without a touch screen. See \ref Input::SetTouchEmulation "SetTouchEmulation()". When touch emulation is enabled, the left mouse button acts as the touch "finger", actual mouse events are no longer sent, and the operating system mouse cursor is forced visible.
+Touch emulation can be used to test mobile applications on a desktop machine without a touch screen. See \ref Input::SetTouchEmulation "SetTouchEmulation()". When touch emulation is enabled, actual mouse events are no longer sent and the operating system mouse cursor is forced visible. The left mouse button acts as a moving finger, while the rest of the mouse buttons act as stationary fingers for multi-finger gestures. For example pressing down both left and right mouse buttons, then dragging the mouse with the buttons still pressed would emulate a two-finger pinch zoom-in gesture.
 
 \section InputPlatformSpecific Platform-specific details
 

+ 5 - 4
Source/Engine/Input/Input.cpp

@@ -1071,7 +1071,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
     case SDL_MOUSEBUTTONDOWN:
         if (!touchEmulation_)
             SetMouseButton(1 << (evt.button.button - 1), true);
-        else if (touchEmulation_ && evt.button.button == 1)
+        else
         {
             int x, y;
             SDL_GetMouseState(&x, &y);
@@ -1079,7 +1079,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
             SDL_Event event;
             event.type = SDL_FINGERDOWN;
             event.tfinger.touchId = 0;
-            event.tfinger.fingerId = 0;
+            event.tfinger.fingerId = evt.button.button - 1;
             event.tfinger.pressure = 1.0f;
             event.tfinger.x = (float)x / (float)graphics_->GetWidth();
             event.tfinger.y = (float)y / (float)graphics_->GetHeight();
@@ -1092,7 +1092,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
     case SDL_MOUSEBUTTONUP:
         if (!touchEmulation_)
             SetMouseButton(1 << (evt.button.button - 1), false);
-        else if (touchEmulation_ && evt.button.button == 1)
+        else
         {
             int x, y;
             SDL_GetMouseState(&x, &y);
@@ -1100,7 +1100,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
             SDL_Event event;
             event.type = SDL_FINGERUP;
             event.tfinger.touchId = 0;
-            event.tfinger.fingerId = 0;
+            event.tfinger.fingerId = evt.button.button - 1;;
             event.tfinger.pressure = 0.0f;
             event.tfinger.x = (float)x / (float)graphics_->GetWidth();
             event.tfinger.y = (float)y / (float)graphics_->GetHeight();
@@ -1130,6 +1130,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
             eventData[P_QUALIFIERS] = GetQualifiers();
             SendEvent(E_MOUSEMOVE, eventData);
         }
+        // Only the left mouse button "finger" moves along with the mouse movement
         else if (touchEmulation_ && touches_.Contains(0))
         {
             int x, y;