diff --git a/src/Magnum/Platform/AbstractXApplication.h b/src/Magnum/Platform/AbstractXApplication.h index ac149cb0d..c714b0e8e 100644 --- a/src/Magnum/Platform/AbstractXApplication.h +++ b/src/Magnum/Platform/AbstractXApplication.h @@ -115,6 +115,7 @@ class AbstractXApplication { /* The damn thing cannot handle forward enum declarations */ #ifndef DOXYGEN_GENERATING_OUTPUT + enum class PointerEventSource: UnsignedByte; enum class Pointer: UnsignedByte; #endif @@ -453,6 +454,21 @@ class AbstractXApplication { Flags _flags; }; +/** +@brief Pointer event source +@m_since_latest + +@see @ref PointerEvent::source(), @ref PointerMoveEvent::source() +*/ +enum class AbstractXApplication::PointerEventSource: UnsignedByte { + /** + * The event is coming from a mouse + * @see @ref Pointer::MouseLeft, @ref Pointer::MouseMiddle, + * @ref Pointer::MouseRight + */ + Mouse, +}; + /** @brief Pointer type @m_since_latest @@ -462,16 +478,21 @@ class AbstractXApplication { @ref ScrollEvent::pointers() */ enum class AbstractXApplication::Pointer: UnsignedByte { - /** Left mouse button. Corresponds to `Button1` / `Button1Mask`. */ + /** + * Left mouse button. Corresponds to `Button1` / `Button1Mask`. + * @see @ref PointerEventSource::Mouse + */ MouseLeft = 1 << 0, /** * Middle mouse button. Corresponds to `Button2` / `Button2Mask`. + * @see @ref PointerEventSource::Mouse */ MouseMiddle = 1 << 1, /** * Right mouse button. Corresponds to `Button3` / `Button3Mask`. + * @see @ref PointerEventSource::Mouse */ MouseRight = 1 << 2 }; @@ -1211,9 +1232,36 @@ class AbstractXApplication::PointerEvent: public InputEvent { /** @brief Moving is not allowed */ PointerEvent& operator=(PointerEvent&&) = delete; + /** + * @brief Pointer event source + * + * Included mainly for compatibility with touch-aware application + * implementations such as @ref Sdl2Application, returns always + * @ref PointerEventSource::Mouse. + */ + PointerEventSource source() const { return PointerEventSource::Mouse; } + /** @brief Pointer type that was pressed or released */ Pointer pointer() const { return _pointer; } + /** + * @brief Whether the pointer is primary + * + * Included mainly for compatibility with touch-aware application + * implementations such as @ref Sdl2Application, returns always + * @cpp true @ce. + */ + bool isPrimary() const { return true; } + + /** + * @brief Pointer ID + * + * Included mainly for compatibility with touch-aware application + * implementations such as @ref Sdl2Application, returns always + * @cpp 0 @ce. + */ + Long id() const { return 0; } + /** * @brief Position * @@ -1303,6 +1351,15 @@ class AbstractXApplication::PointerMoveEvent: public InputEvent { /** @brief Moving is not allowed */ PointerMoveEvent& operator=(PointerMoveEvent&&) = delete; + /** + * @brief Pointer event source + * + * Included mainly for compatibility with touch-aware application + * implementations such as @ref Sdl2Application, returns always + * @ref PointerEventSource::Mouse. + */ + PointerEventSource source() const { return PointerEventSource::Mouse; } + /** * @brief Pointer type that was added or removed from the set of pressed pointers * @@ -1323,6 +1380,24 @@ class AbstractXApplication::PointerMoveEvent: public InputEvent { */ Pointers pointers() const { return _pointers; } + /** + * @brief Whether the pointer is primary + * + * Included mainly for compatibility with touch-aware application + * implementations such as @ref Sdl2Application, returns always + * @cpp true @ce. + */ + bool isPrimary() const { return true; } + + /** + * @brief Pointer ID + * + * Included mainly for compatibility with touch-aware application + * implementations such as @ref Sdl2Application, returns always + * @cpp 0 @ce. + */ + Long id() const { return 0; } + /** * @brief Position * diff --git a/src/Magnum/Platform/GlfwApplication.h b/src/Magnum/Platform/GlfwApplication.h index f909c2c22..91487b9f0 100644 --- a/src/Magnum/Platform/GlfwApplication.h +++ b/src/Magnum/Platform/GlfwApplication.h @@ -190,6 +190,7 @@ class GlfwApplication { /* The damn thing cannot handle forward enum declarations */ #ifndef DOXYGEN_GENERATING_OUTPUT + enum class PointerEventSource: UnsignedByte; enum class Pointer: UnsignedByte; #endif @@ -937,6 +938,23 @@ class GlfwApplication { Vector2 _previousMouseMovePosition{Constants::nan()}; }; +/** +@brief Pointer event source +@m_since_latest + +@see @ref PointerEvent::source(), @ref PointerMoveEvent::source() +*/ +enum class GlfwApplication::PointerEventSource: UnsignedByte { + /** + * The event is coming from a mouse + * @see @ref Pointer::MouseLeft, @ref Pointer::MouseMiddle, + * @ref Pointer::MouseRight, @ref Pointer::MouseButton4, + * @ref Pointer::MouseButton5, @ref Pointer::MouseButton6, + * @ref Pointer::MouseButton7, @ref Pointer::MouseButton8 + */ + Mouse +}; + /** @brief Pointer type @m_since_latest @@ -948,41 +966,61 @@ enum class GlfwApplication::Pointer: UnsignedByte { /** * Left mouse button. Corresponds to `GLFW_MOUSE_BUTTON_LEFT` or * `GLFW_MOUSE_BUTTON_1`. + * @see @ref PointerEventSource::Mouse */ MouseLeft = 1 << 0, /** * Middle mouse button. Corresponds to `GLFW_MOUSE_BUTTON_MIDDLE` or * `GLFW_MOUSE_BUTTON_2`. + * @see @ref PointerEventSource::Mouse */ MouseMiddle = 1 << 1, /** * Right mouse button. Corresponds to `GLFW_MOUSE_BUTTON_RIGHT` or * `GLFW_MOUSE_BUTTON_3`. + * @see @ref PointerEventSource::Mouse */ MouseRight = 1 << 2, /** * Fourth mouse button, such as wheel left. Corresponds to * `GLFW_MOUSE_BUTTON_4`. + * @see @ref PointerEventSource::Mouse */ MouseButton4 = 1 << 3, /** * Fifth mouse button, such as wheel right. Corresponds to * `GLFW_MOUSE_BUTTON_5`. + * @see @ref PointerEventSource::Mouse */ MouseButton5 = 1 << 4, - /** Sixth mouse button. Corresponds to `GLFW_MOUSE_BUTTON_6`. */ + /** + * Sixth mouse button. Corresponds to `GLFW_MOUSE_BUTTON_6`. + * @see @ref PointerEventSource::Mouse + */ MouseButton6 = 1 << 5, - /** Seventh mouse button. Corresponds to `GLFW_MOUSE_BUTTON_7`. */ + /** + * Seventh mouse button. Corresponds to `GLFW_MOUSE_BUTTON_7`. + * @see @ref PointerEventSource::Mouse + */ MouseButton7 = 1 << 6, - /** Eighth mouse button. Corresponds to `GLFW_MOUSE_BUTTON_8`. */ + /** + * Eighth mouse button. Corresponds to `GLFW_MOUSE_BUTTON_8`. + * @see @ref PointerEventSource::Mouse + */ MouseButton8 = 1 << 7 + + /** @todo look into touch / pen input once anything from + https://github.com/glfw/glfw/issues/42 + https://github.com/glfw/glfw/issues/403 + https://github.com/glfw/glfw/pull/1445 + https://github.com/glfw/glfw/pull/1736 gets any updates */ }; CORRADE_ENUMSET_OPERATORS(GlfwApplication::Pointers) @@ -2132,9 +2170,36 @@ class GlfwApplication::PointerEvent: public InputEvent { /** @brief Moving is not allowed */ PointerEvent& operator=(PointerEvent&&) = delete; + /** + * @brief Pointer event source + * + * Included mainly for compatibility with touch-aware application + * implementations such as @ref Sdl2Application, returns always + * @ref PointerEventSource::Mouse. + */ + PointerEventSource source() const { return PointerEventSource::Mouse; } + /** @brief Pointer type that was pressed or released */ Pointer pointer() const { return _pointer; } + /** + * @brief Whether the pointer is primary + * + * Included mainly for compatibility with touch-aware application + * implementations such as @ref Sdl2Application, returns always + * @cpp true @ce. + */ + bool isPrimary() const { return true; } + + /** + * @brief Pointer ID + * + * Included mainly for compatibility with touch-aware application + * implementations such as @ref Sdl2Application, returns always + * @cpp 0 @ce. + */ + Long id() const { return 0; } + /** * @brief Position * @@ -2228,6 +2293,15 @@ class GlfwApplication::PointerMoveEvent: public InputEvent { /** @brief Moving is not allowed */ PointerMoveEvent& operator=(PointerMoveEvent&&) = delete; + /** + * @brief Pointer event source + * + * Included mainly for compatibility with touch-aware application + * implementations such as @ref Sdl2Application, returns always + * @ref PointerEventSource::Mouse. + */ + PointerEventSource source() const { return PointerEventSource::Mouse; } + /** * @brief Pointer type that was added or removed from the set of pressed pointers * @@ -2249,6 +2323,24 @@ class GlfwApplication::PointerMoveEvent: public InputEvent { */ Pointers pointers(); + /** + * @brief Whether the pointer is primary + * + * Included mainly for compatibility with touch-aware application + * implementations such as @ref Sdl2Application, returns always + * @cpp true @ce. + */ + bool isPrimary() const { return true; } + + /** + * @brief Pointer ID + * + * Included mainly for compatibility with touch-aware application + * implementations such as @ref Sdl2Application, returns always + * @cpp 0 @ce. + */ + Long id() const { return 0; } + /** * @brief Position * diff --git a/src/Magnum/Platform/Screen.h b/src/Magnum/Platform/Screen.h index b9289df5c..3d1d4c290 100644 --- a/src/Magnum/Platform/Screen.h +++ b/src/Magnum/Platform/Screen.h @@ -201,6 +201,12 @@ template class BasicScreen: typedef typename BasicScreenedApplication::KeyEvent KeyEvent; #endif + /** + * @brief Pointer event source + * @m_since_latest + */ + typedef typename BasicScreenedApplication::PointerEventSource PointerEventSource; + /** * @brief Pointer type * @m_since_latest