|
|
@@ -38,7 +38,8 @@ enum MouseMode
|
|
|
MM_ABSOLUTE = 0,
|
|
|
MM_RELATIVE,
|
|
|
MM_WRAP,
|
|
|
- MM_FREE
|
|
|
+ MM_FREE,
|
|
|
+ MM_INVALID
|
|
|
};
|
|
|
|
|
|
class Deserializer;
|
|
|
@@ -155,7 +156,9 @@ public:
|
|
|
/// Reset last mouse visibility that was not suppressed in SetMouseVisible.
|
|
|
void ResetMouseVisible();
|
|
|
/// Set whether the mouse is currently being grabbed by an operation.
|
|
|
- void SetMouseGrabbed(bool grab);
|
|
|
+ void SetMouseGrabbed(bool grab, bool suppressEvent = false);
|
|
|
+ /// Reset the mouse grabbed to the last unsuppressed SetMouseGrabbed call
|
|
|
+ void ResetMouseGrabbed();
|
|
|
/// Set the mouse mode.
|
|
|
/** Set the mouse mode behaviour.
|
|
|
* MM_ABSOLUTE is the default behaviour, allowing the toggling of operating system cursor visibility and allowing the cursor to escape the window when visible.
|
|
|
@@ -174,7 +177,9 @@ public:
|
|
|
* MM_FREE does not grab/confine the mouse cursor even when it is hidden. This can be used for cases where the cursor should render using the operating system
|
|
|
* outside the window, and perform custom rendering (with SetMouseVisible(false)) inside.
|
|
|
*/
|
|
|
- void SetMouseMode(MouseMode mode);
|
|
|
+ void SetMouseMode(MouseMode mode, bool suppressEvent = false);
|
|
|
+ /// Reset the last mouse mode that wasn't suppressed in SetMouseMode
|
|
|
+ void ResetMouseMode();
|
|
|
/// Add screen joystick.
|
|
|
/** Return the joystick instance ID when successful or negative on error.
|
|
|
* If layout file is not given, use the default screen joystick layout.
|
|
|
@@ -240,28 +245,22 @@ public:
|
|
|
int GetQualifiers() const;
|
|
|
/// Return mouse position within window. Should only be used with a visible mouse cursor.
|
|
|
IntVector2 GetMousePosition() const;
|
|
|
-
|
|
|
/// Return mouse movement since last frame.
|
|
|
- const IntVector2& GetMouseMove() const { return mouseMove_; }
|
|
|
-
|
|
|
+ const IntVector2& GetMouseMove() const;
|
|
|
/// Return horizontal mouse movement since last frame.
|
|
|
- int GetMouseMoveX() const { return mouseMove_.x_; }
|
|
|
-
|
|
|
+ int GetMouseMoveX() const;
|
|
|
/// Return vertical mouse movement since last frame.
|
|
|
- int GetMouseMoveY() const { return mouseMove_.y_; }
|
|
|
-
|
|
|
+ int GetMouseMoveY() const;
|
|
|
/// Return mouse wheel movement since last frame.
|
|
|
int GetMouseMoveWheel() const { return mouseMoveWheel_; }
|
|
|
|
|
|
/// Return number of active finger touches.
|
|
|
unsigned GetNumTouches() const { return touches_.Size(); }
|
|
|
-
|
|
|
/// Return active finger touch by index.
|
|
|
TouchState* GetTouch(unsigned index) const;
|
|
|
|
|
|
/// Return number of connected joysticks.
|
|
|
unsigned GetNumJoysticks() const { return joysticks_.Size(); }
|
|
|
-
|
|
|
/// Return joystick state by ID, or null if does not exist.
|
|
|
JoystickState* GetJoystick(SDL_JoystickID id);
|
|
|
/// Return joystick state by index, or null if does not exist. 0 = first connected joystick.
|
|
|
@@ -282,9 +281,10 @@ public:
|
|
|
|
|
|
/// Return whether the operating system mouse cursor is visible.
|
|
|
bool IsMouseVisible() const { return mouseVisible_; }
|
|
|
-
|
|
|
/// Return whether the mouse is currently being grabbed by an operation.
|
|
|
bool IsMouseGrabbed() const { return mouseGrabbed_; }
|
|
|
+ /// Return whether the mouse is locked to the window
|
|
|
+ bool IsMouseLocked() const;
|
|
|
|
|
|
/// Return the mouse mode.
|
|
|
MouseMode GetMouseMode() const { return mouseMode_; }
|
|
|
@@ -310,6 +310,8 @@ private:
|
|
|
void ResetState();
|
|
|
/// Clear touch states and send touch end events.
|
|
|
void ResetTouches();
|
|
|
+ /// Reset input accumulation.
|
|
|
+ void ResetInputAccumulation();
|
|
|
/// Get the index of a touch based on the touch ID.
|
|
|
unsigned GetTouchIndexFromID(int touchID);
|
|
|
/// Used internally to return and remove the next available touch index.
|
|
|
@@ -322,16 +324,16 @@ private:
|
|
|
void SetMouseButton(int button, bool newState);
|
|
|
/// Handle a key change.
|
|
|
void SetKey(int key, int scancode, bool newState);
|
|
|
-#ifdef __EMSCRIPTEN__
|
|
|
- /// Set whether the operating system mouse cursor is visible (Emscripten platform only).
|
|
|
- void SetMouseVisibleEmscripten(bool enable);
|
|
|
- /// Set mouse mode (Emscripten platform only).
|
|
|
- void SetMouseModeEmscripten(MouseMode mode);
|
|
|
-#endif
|
|
|
/// Handle mouse wheel change.
|
|
|
void SetMouseWheel(int delta);
|
|
|
/// Internal function to set the mouse cursor position.
|
|
|
void SetMousePosition(const IntVector2& position);
|
|
|
+ /// Center the mouse position.
|
|
|
+ void CenterMousePosition();
|
|
|
+ /// Suppress next mouse movement.
|
|
|
+ void SuppressNextMouseMove();
|
|
|
+ /// Unsuppress mouse movement.
|
|
|
+ void UnsuppressMouseMove();
|
|
|
/// Handle screen mode event.
|
|
|
void HandleScreenMode(StringHash eventType, VariantMap& eventData);
|
|
|
/// Handle frame start event.
|
|
|
@@ -341,6 +343,22 @@ private:
|
|
|
/// Handle SDL event.
|
|
|
void HandleSDLEvent(void* sdlEvent);
|
|
|
|
|
|
+#ifndef __EMSCRIPTEN__
|
|
|
+ /// Set SDL mouse mode relative.
|
|
|
+ void SetMouseModeRelative(SDL_bool enable);
|
|
|
+ /// Set SDL mouse mode absolute.
|
|
|
+ void SetMouseModeAbsolute(SDL_bool enable);
|
|
|
+#else
|
|
|
+ /// Set whether the operating system mouse cursor is visible (Emscripten platform only).
|
|
|
+ void SetMouseVisibleEmscripten(bool enable, bool suppressEvent = false);
|
|
|
+ /// Set mouse mode final resolution (Emscripten platform only).
|
|
|
+ void SetMouseModeEmscriptenFinal(MouseMode mode, bool suppressEvent = false);
|
|
|
+ /// SetMouseMode (Emscripten platform only).
|
|
|
+ void SetMouseModeEmscripten(MouseMode mode, bool suppressEvent);
|
|
|
+ /// Handle frame end event.
|
|
|
+ void HandleEndFrame(StringHash eventType, VariantMap& eventData);
|
|
|
+#endif
|
|
|
+
|
|
|
/// Graphics subsystem.
|
|
|
WeakPtr<Graphics> graphics_;
|
|
|
/// Key down state.
|
|
|
@@ -383,8 +401,16 @@ private:
|
|
|
bool lastMouseVisible_;
|
|
|
/// Flag to indicate the mouse is being grabbed by an operation. Subsystems like UI that uses mouse should temporarily ignore the mouse hover or click events.
|
|
|
bool mouseGrabbed_;
|
|
|
+ /// The last mouse grabbed set by SetMouseGrabbed.
|
|
|
+ bool lastMouseGrabbed_;
|
|
|
/// Determines the mode of mouse behaviour.
|
|
|
MouseMode mouseMode_;
|
|
|
+ /// The last mouse mode set by SetMouseMode.
|
|
|
+ MouseMode lastMouseMode_;
|
|
|
+#ifndef __EMSCRIPTEN__
|
|
|
+ /// Flag to determine whether SDL mouse relative was used.
|
|
|
+ bool sdlMouseRelative_;
|
|
|
+#endif
|
|
|
/// Touch emulation mode flag.
|
|
|
bool touchEmulation_;
|
|
|
/// Input focus flag.
|
|
|
@@ -401,13 +427,16 @@ private:
|
|
|
bool screenModeChanged_;
|
|
|
/// Initialized flag.
|
|
|
bool initialized_;
|
|
|
+
|
|
|
#ifdef __EMSCRIPTEN__
|
|
|
/// Emscripten Input glue instance.
|
|
|
EmscriptenInput* emscriptenInput_;
|
|
|
- /// Flag used to detect mouse jump when exiting pointer lock.
|
|
|
+ /// Flag used to detect mouse jump when exiting pointer-lock.
|
|
|
bool emscriptenExitingPointerLock_;
|
|
|
- /// Flag used to detect mouse jump on initial mouse click when entering pointer lock.
|
|
|
+ /// Flag used to detect mouse jump on initial mouse click when entering pointer-lock.
|
|
|
bool emscriptenEnteredPointerLock_;
|
|
|
+ /// Flag indicating current pointer-lock status.
|
|
|
+ bool emscriptenPointerLock_;
|
|
|
#endif
|
|
|
};
|
|
|
|