mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-24 21:53:37 +02:00
Merge pull request #79 from SFML/feature/precise_mouse_events
Added support for the MouseWheelScrolled event
This commit is contained in:
commit
f3153dc9c1
3 files changed
+36
-4
No files matched your search
@@ -48,7 +48,8 @@ typedef enum
|
||||
sfEvtTextEntered, ///< A character was entered (data in event.text)
|
||||
sfEvtKeyPressed, ///< A key was pressed (data in event.key)
|
||||
sfEvtKeyReleased, ///< A key was released (data in event.key)
|
||||
sfEvtMouseWheelMoved, ///< The mouse wheel was scrolled (data in event.mouseWheel)
|
||||
sfEvtMouseWheelMoved, ///< The mouse wheel was scrolled (data in event.mouseWheel) (deprecated)
|
||||
sfEvtMouseWheelScrolled, ///< The mouse wheel was scrolled (data in event.mouseWheelScroll)
|
||||
sfEvtMouseButtonPressed, ///< A mouse button was pressed (data in event.mouseButton)
|
||||
sfEvtMouseButtonReleased, ///< A mouse button was released (data in event.mouseButton)
|
||||
sfEvtMouseMoved, ///< The mouse cursor moved (data in event.mouseMove)
|
||||
@@ -116,7 +117,7 @@ typedef struct
|
||||
} sfMouseButtonEvent;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Mouse wheel events parameters
|
||||
/// \brief Mouse wheel events parameters (deprecated)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
typedef struct
|
||||
@@ -127,6 +128,19 @@ typedef struct
|
||||
int y;
|
||||
} sfMouseWheelEvent;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Mouse wheel events parameters
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
typedef struct
|
||||
{
|
||||
sfEventType type;
|
||||
sfMouseWheel wheel;
|
||||
float delta;
|
||||
int x;
|
||||
int y;
|
||||
} sfMouseWheelScrollEvent;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Joystick axis move event parameters
|
||||
///
|
||||
@@ -208,7 +222,8 @@ typedef union
|
||||
sfTextEvent text; ///< Text event parameters
|
||||
sfMouseMoveEvent mouseMove; ///< Mouse move event parameters
|
||||
sfMouseButtonEvent mouseButton; ///< Mouse button event parameters
|
||||
sfMouseWheelEvent mouseWheel; ///< Mouse wheel event parameters
|
||||
sfMouseWheelEvent mouseWheel; ///< Mouse wheel event parameters (deprecated)
|
||||
sfMouseWheelScrollEvent mouseWheelScroll; ///< Mouse wheel event parameters
|
||||
sfJoystickMoveEvent joystickMove; ///< Joystick move event parameters
|
||||
sfJoystickButtonEvent joystickButton; ///< Joystick button event parameters
|
||||
sfJoystickConnectEvent joystickConnect; ///< Joystick (dis)connect event parameters
|
||||
|
||||
@@ -48,6 +48,16 @@ typedef enum
|
||||
sfMouseButtonCount ///< Keep last -- the total number of mouse buttons
|
||||
} sfMouseButton;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Mouse wheels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
typedef enum
|
||||
{
|
||||
sfMouseVerticalWheel, ///< The vertical mouse wheel
|
||||
sfMouseHorizontalWheel ///< The horizontal mouse wheel
|
||||
} sfMouseWheel;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if a mouse button is pressed
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Define a function to convert a sf::Event ot a sfEvent
|
||||
// Define a function to convert a sf::Event to a sfEvent
|
||||
////////////////////////////////////////////////////////////
|
||||
inline void convertEvent(const sf::Event& SFMLEvent, sfEvent* event)
|
||||
{
|
||||
@@ -67,6 +67,13 @@ inline void convertEvent(const sf::Event& SFMLEvent, sfEvent* event)
|
||||
event->mouseWheel.y = SFMLEvent.mouseWheel.y;
|
||||
break;
|
||||
|
||||
case sfEvtMouseWheelScrolled :
|
||||
event->mouseWheelScroll.wheel = static_cast<sfMouseWheel>(SFMLEvent.mouseWheelScroll.wheel);
|
||||
event->mouseWheelScroll.delta = SFMLEvent.mouseWheelScroll.delta;
|
||||
event->mouseWheelScroll.x = SFMLEvent.mouseWheelScroll.x;
|
||||
event->mouseWheelScroll.y = SFMLEvent.mouseWheelScroll.y;
|
||||
break;
|
||||
|
||||
case sfEvtMouseButtonPressed :
|
||||
case sfEvtMouseButtonReleased :
|
||||
event->mouseButton.button = static_cast<sfMouseButton>(SFMLEvent.mouseButton.button);
|
||||
|
||||
Reference in new issue
Block a user