Skip to content

Commit

Permalink
Update enumerations to match SFML 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisThrasher committed Sep 27, 2024
1 parent fef1e09 commit c74378b
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 19 deletions.
8 changes: 4 additions & 4 deletions include/CSFML/Window/Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions include/CSFML/Window/Mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
4 changes: 2 additions & 2 deletions include/CSFML/Window/Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/CSFML/Window/Keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
#include <cstring>


////////////////////////////////////////////////////////////
const unsigned int sfKeyCount = sfKeyPause + 1;
const unsigned int sfScancodeCount = sfScanLaunchMediaSelect + 1;


////////////////////////////////////////////////////////////
bool sfKeyboard_isKeyPressed(sfKeyCode key)
{
Expand Down
4 changes: 4 additions & 0 deletions src/CSFML/Window/Mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#include <SFML/Window/Mouse.hpp>


////////////////////////////////////////////////////////////
const unsigned int sfMouseButtonCount = sfMouseButtonExtra2 + 1;


////////////////////////////////////////////////////////////
bool sfMouse_isButtonPressed(sfMouseButton button)
{
Expand Down
4 changes: 4 additions & 0 deletions src/CSFML/Window/Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#include <SFML/Window/Sensor.hpp>


////////////////////////////////////////////////////////////
const unsigned int sfSensorCount = sfSensorOrientation + 1;


////////////////////////////////////////////////////////////
bool sfSensor_isAvailable(sfSensorType sensor)
{
Expand Down
4 changes: 2 additions & 2 deletions test/Window/Keyboard.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TEST_CASE("[Window] sfKeyboard")
STATIC_CHECK(sfKeyC == static_cast<int>(sf::Keyboard::Key::C));
STATIC_CHECK(sfKeyD == static_cast<int>(sf::Keyboard::Key::D));
STATIC_CHECK(sfKeyPause == static_cast<int>(sf::Keyboard::Key::Pause));
STATIC_CHECK(sfKeyCount == sf::Keyboard::KeyCount);
CHECK(sfKeyCount == sf::Keyboard::KeyCount);
}

SECTION("sfScancode")
Expand All @@ -24,6 +24,6 @@ TEST_CASE("[Window] sfKeyboard")
STATIC_CHECK(sfScanB == static_cast<int>(sf::Keyboard::Scan::B));
STATIC_CHECK(sfScanC == static_cast<int>(sf::Keyboard::Scan::C));
STATIC_CHECK(sfScanD == static_cast<int>(sf::Keyboard::Scan::D));
STATIC_CHECK(sfScancodeCount == sf::Keyboard::ScancodeCount);
CHECK(sfScancodeCount == sf::Keyboard::ScancodeCount);
}
}
6 changes: 3 additions & 3 deletions test/Window/Mouse.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ TEST_CASE("[Window] sfMouse")
STATIC_CHECK(sfMouseLeft == static_cast<int>(sf::Mouse::Button::Left));
STATIC_CHECK(sfMouseRight == static_cast<int>(sf::Mouse::Button::Right));
STATIC_CHECK(sfMouseMiddle == static_cast<int>(sf::Mouse::Button::Middle));
STATIC_CHECK(sfMouseXButton1 == static_cast<int>(sf::Mouse::Button::Extra1));
STATIC_CHECK(sfMouseXButton2 == static_cast<int>(sf::Mouse::Button::Extra2));
STATIC_CHECK(sfMouseButtonCount == sf::Mouse::ButtonCount);
STATIC_CHECK(sfMouseButtonExtra1 == static_cast<int>(sf::Mouse::Button::Extra1));
STATIC_CHECK(sfMouseButtonExtra2 == static_cast<int>(sf::Mouse::Button::Extra2));
CHECK(sfMouseButtonCount == sf::Mouse::ButtonCount);
}

SECTION("sfMouseWheel")
Expand Down
2 changes: 1 addition & 1 deletion test/Window/Sensor.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ TEST_CASE("[Window] sfSensor")
STATIC_CHECK(sfSensorGravity == static_cast<int>(sf::Sensor::Type::Gravity));
STATIC_CHECK(sfSensorUserAcceleration == static_cast<int>(sf::Sensor::Type::UserAcceleration));
STATIC_CHECK(sfSensorOrientation == static_cast<int>(sf::Sensor::Type::Orientation));
STATIC_CHECK(sfSensorCount == sf::Sensor::Count);
CHECK(sfSensorCount == sf::Sensor::Count);
}
}

0 comments on commit c74378b

Please sign in to comment.