diff --git a/include/CSFML/Window/Keyboard.h b/include/CSFML/Window/Keyboard.h index 1c24474..3cf5ee3 100644 --- a/include/CSFML/Window/Keyboard.h +++ b/include/CSFML/Window/Keyboard.h @@ -142,10 +142,10 @@ typedef enum sfKeyF14, ///< The F14 key sfKeyF15, ///< The F15 key sfKeyPause, ///< The Pause key - - sfKeyCount, ///< Keep last -- the total number of keyboard keys } sfKeyCode; +CSFML_WINDOW_API const unsigned int sfKeyCount; ///< The total number of keyboard keys + //////////////////////////////////////////////////////////// /// \brief Scancodes @@ -310,10 +310,10 @@ typedef enum sfScanLaunchApplication2, //!< Keyboard Launch Application 2 key sfScanLaunchMail, //!< Keyboard Launch Mail key sfScanLaunchMediaSelect, //!< Keyboard Launch Media Select key - - sfScancodeCount //!< Keep last -- the total number of scancodes } sfScancode; +CSFML_WINDOW_API const unsigned int sfScancodeCount; //!< The total number of scancodes + //////////////////////////////////////////////////////////// /// \brief Check if a key is pressed diff --git a/include/CSFML/Window/Mouse.h b/include/CSFML/Window/Mouse.h index 9c200d1..098d2e5 100644 --- a/include/CSFML/Window/Mouse.h +++ b/include/CSFML/Window/Mouse.h @@ -39,15 +39,15 @@ //////////////////////////////////////////////////////////// typedef enum { - sfMouseLeft, ///< The left mouse button - sfMouseRight, ///< The right mouse button - sfMouseMiddle, ///< The middle (wheel) mouse button - sfMouseXButton1, ///< The first extra mouse button - sfMouseXButton2, ///< The second extra mouse button - - sfMouseButtonCount ///< Keep last -- the total number of mouse buttons + sfMouseLeft, ///< The left mouse button + sfMouseRight, ///< The right mouse button + sfMouseMiddle, ///< The middle (wheel) mouse button + sfMouseButtonExtra1, ///< The first extra mouse button + sfMouseButtonExtra2, ///< The second extra mouse button } sfMouseButton; +CSFML_WINDOW_API const unsigned int sfMouseButtonCount; ///< The total number of mouse buttons + //////////////////////////////////////////////////////////// /// \brief Mouse wheels /// diff --git a/include/CSFML/Window/Sensor.h b/include/CSFML/Window/Sensor.h index 34d1ce5..fda6dec 100644 --- a/include/CSFML/Window/Sensor.h +++ b/include/CSFML/Window/Sensor.h @@ -45,10 +45,10 @@ typedef enum sfSensorGravity, ///< Measures the direction and intensity of gravity, independent of device acceleration (m/s^2) sfSensorUserAcceleration, ///< Measures the direction and intensity of device acceleration, independent of the gravity (m/s^2) sfSensorOrientation, ///< Measures the absolute 3D orientation (degrees) - - sfSensorCount ///< Keep last -- the total number of sensor types } sfSensorType; +CSFML_WINDOW_API const unsigned int sfSensorCount; ///< The total number of sensor types + //////////////////////////////////////////////////////////// /// \brief Check if a sensor is available on the underlying platform diff --git a/src/CSFML/Window/Keyboard.cpp b/src/CSFML/Window/Keyboard.cpp index c66b96f..1d05071 100644 --- a/src/CSFML/Window/Keyboard.cpp +++ b/src/CSFML/Window/Keyboard.cpp @@ -33,6 +33,11 @@ #include +//////////////////////////////////////////////////////////// +const unsigned int sfKeyCount = sfKeyPause + 1; +const unsigned int sfScancodeCount = sfScanLaunchMediaSelect + 1; + + //////////////////////////////////////////////////////////// bool sfKeyboard_isKeyPressed(sfKeyCode key) { diff --git a/src/CSFML/Window/Mouse.cpp b/src/CSFML/Window/Mouse.cpp index 45e61c6..b794bb1 100644 --- a/src/CSFML/Window/Mouse.cpp +++ b/src/CSFML/Window/Mouse.cpp @@ -33,6 +33,10 @@ #include +//////////////////////////////////////////////////////////// +const unsigned int sfMouseButtonCount = sfMouseButtonExtra2 + 1; + + //////////////////////////////////////////////////////////// bool sfMouse_isButtonPressed(sfMouseButton button) { diff --git a/src/CSFML/Window/Sensor.cpp b/src/CSFML/Window/Sensor.cpp index 5c5f2db..255af27 100644 --- a/src/CSFML/Window/Sensor.cpp +++ b/src/CSFML/Window/Sensor.cpp @@ -31,6 +31,10 @@ #include +//////////////////////////////////////////////////////////// +const unsigned int sfSensorCount = sfSensorOrientation + 1; + + //////////////////////////////////////////////////////////// bool sfSensor_isAvailable(sfSensorType sensor) { diff --git a/test/Window/Keyboard.test.cpp b/test/Window/Keyboard.test.cpp index 812520e..5adfc39 100644 --- a/test/Window/Keyboard.test.cpp +++ b/test/Window/Keyboard.test.cpp @@ -14,7 +14,7 @@ TEST_CASE("[Window] sfKeyboard") STATIC_CHECK(sfKeyC == static_cast(sf::Keyboard::Key::C)); STATIC_CHECK(sfKeyD == static_cast(sf::Keyboard::Key::D)); STATIC_CHECK(sfKeyPause == static_cast(sf::Keyboard::Key::Pause)); - STATIC_CHECK(sfKeyCount == sf::Keyboard::KeyCount); + CHECK(sfKeyCount == sf::Keyboard::KeyCount); } SECTION("sfScancode") @@ -24,6 +24,6 @@ TEST_CASE("[Window] sfKeyboard") STATIC_CHECK(sfScanB == static_cast(sf::Keyboard::Scan::B)); STATIC_CHECK(sfScanC == static_cast(sf::Keyboard::Scan::C)); STATIC_CHECK(sfScanD == static_cast(sf::Keyboard::Scan::D)); - STATIC_CHECK(sfScancodeCount == sf::Keyboard::ScancodeCount); + CHECK(sfScancodeCount == sf::Keyboard::ScancodeCount); } } diff --git a/test/Window/Mouse.test.cpp b/test/Window/Mouse.test.cpp index 1bfd041..d627a22 100644 --- a/test/Window/Mouse.test.cpp +++ b/test/Window/Mouse.test.cpp @@ -11,9 +11,9 @@ TEST_CASE("[Window] sfMouse") STATIC_CHECK(sfMouseLeft == static_cast(sf::Mouse::Button::Left)); STATIC_CHECK(sfMouseRight == static_cast(sf::Mouse::Button::Right)); STATIC_CHECK(sfMouseMiddle == static_cast(sf::Mouse::Button::Middle)); - STATIC_CHECK(sfMouseXButton1 == static_cast(sf::Mouse::Button::Extra1)); - STATIC_CHECK(sfMouseXButton2 == static_cast(sf::Mouse::Button::Extra2)); - STATIC_CHECK(sfMouseButtonCount == sf::Mouse::ButtonCount); + STATIC_CHECK(sfMouseButtonExtra1 == static_cast(sf::Mouse::Button::Extra1)); + STATIC_CHECK(sfMouseButtonExtra2 == static_cast(sf::Mouse::Button::Extra2)); + CHECK(sfMouseButtonCount == sf::Mouse::ButtonCount); } SECTION("sfMouseWheel") diff --git a/test/Window/Sensor.test.cpp b/test/Window/Sensor.test.cpp index bbce5e3..29340bc 100644 --- a/test/Window/Sensor.test.cpp +++ b/test/Window/Sensor.test.cpp @@ -14,6 +14,6 @@ TEST_CASE("[Window] sfSensor") STATIC_CHECK(sfSensorGravity == static_cast(sf::Sensor::Type::Gravity)); STATIC_CHECK(sfSensorUserAcceleration == static_cast(sf::Sensor::Type::UserAcceleration)); STATIC_CHECK(sfSensorOrientation == static_cast(sf::Sensor::Type::Orientation)); - STATIC_CHECK(sfSensorCount == sf::Sensor::Count); + CHECK(sfSensorCount == sf::Sensor::Count); } }