Changed to namespace

This commit is contained in:
Jim-Marsden 2022-12-27 10:14:15 -08:00 committed by Chris Thrasher
parent bf9f59d3e3
commit 34b6323929
9 changed files with 606 additions and 639 deletions

View File

@ -32,122 +32,117 @@
#include <SFML/System/Vector3.hpp> #include <SFML/System/Vector3.hpp>
namespace sf
{
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief The audio listener is the point in the scene /// \brief The audio listener is the point in the scene
/// from where all the sounds are heard /// from where all the sounds are heard
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_AUDIO_API Listener namespace sf::Listener
{ {
public: ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// /// \brief Change the global volume of all the sounds and musics
/// \brief Change the global volume of all the sounds and musics ///
/// /// The volume is a number between 0 and 100; it is combined with
/// The volume is a number between 0 and 100; it is combined with /// the individual volume of each sound / music.
/// the individual volume of each sound / music. /// The default value for the volume is 100 (maximum).
/// The default value for the volume is 100 (maximum). ///
/// /// \param volume New global volume, in the range [0, 100]
/// \param volume New global volume, in the range [0, 100] ///
/// /// \see getGlobalVolume
/// \see getGlobalVolume ///
/// ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// SFML_AUDIO_API void setGlobalVolume(float volume);
static void setGlobalVolume(float volume);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the current value of the global volume /// \brief Get the current value of the global volume
/// ///
/// \return Current global volume, in the range [0, 100] /// \return Current global volume, in the range [0, 100]
/// ///
/// \see setGlobalVolume /// \see setGlobalVolume
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static float getGlobalVolume(); SFML_AUDIO_API float getGlobalVolume();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set the position of the listener in the scene /// \brief Set the position of the listener in the scene
/// ///
/// The default listener's position is (0, 0, 0). /// The default listener's position is (0, 0, 0).
/// ///
/// \param position New listener's position /// \param position New listener's position
/// ///
/// \see getPosition, setDirection /// \see getPosition, setDirection
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static void setPosition(const Vector3f& position); SFML_AUDIO_API void setPosition(const Vector3f& position);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the current position of the listener in the scene /// \brief Get the current position of the listener in the scene
/// ///
/// \return Listener's position /// \return Listener's position
/// ///
/// \see setPosition /// \see setPosition
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Vector3f getPosition(); SFML_AUDIO_API Vector3f getPosition();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set the forward vector of the listener in the scene /// \brief Set the forward vector of the listener in the scene
/// ///
/// The direction (also called "at vector") is the vector /// The direction (also called "at vector") is the vector
/// pointing forward from the listener's perspective. Together /// pointing forward from the listener's perspective. Together
/// with the up vector, it defines the 3D orientation of the /// with the up vector, it defines the 3D orientation of the
/// listener in the scene. The direction vector doesn't /// listener in the scene. The direction vector doesn't
/// have to be normalized. /// have to be normalized.
/// The default listener's direction is (0, 0, -1). /// The default listener's direction is (0, 0, -1).
/// ///
/// \param direction New listener's direction /// \param direction New listener's direction
/// ///
/// \see getDirection, setUpVector, setPosition /// \see getDirection, setUpVector, setPosition
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static void setDirection(const Vector3f& direction); SFML_AUDIO_API void setDirection(const Vector3f& direction);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the current forward vector of the listener in the scene /// \brief Get the current forward vector of the listener in the scene
/// ///
/// \return Listener's forward vector (not normalized) /// \return Listener's forward vector (not normalized)
/// ///
/// \see setDirection /// \see setDirection
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Vector3f getDirection(); SFML_AUDIO_API Vector3f getDirection();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set the upward vector of the listener in the scene /// \brief Set the upward vector of the listener in the scene
/// ///
/// The up vector is the vector that points upward from the /// The up vector is the vector that points upward from the
/// listener's perspective. Together with the direction, it /// listener's perspective. Together with the direction, it
/// defines the 3D orientation of the listener in the scene. /// defines the 3D orientation of the listener in the scene.
/// The up vector doesn't have to be normalized. /// The up vector doesn't have to be normalized.
/// The default listener's up vector is (0, 1, 0). It is usually /// The default listener's up vector is (0, 1, 0). It is usually
/// not necessary to change it, especially in 2D scenarios. /// not necessary to change it, especially in 2D scenarios.
/// ///
/// \param upVector New listener's up vector /// \param upVector New listener's up vector
/// ///
/// \see getUpVector, setDirection, setPosition /// \see getUpVector, setDirection, setPosition
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static void setUpVector(const Vector3f& upVector); SFML_AUDIO_API void setUpVector(const Vector3f& upVector);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the current upward vector of the listener in the scene /// \brief Get the current upward vector of the listener in the scene
/// ///
/// \return Listener's upward vector (not normalized) /// \return Listener's upward vector (not normalized)
/// ///
/// \see setUpVector /// \see setUpVector
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Vector3f getUpVector(); SFML_AUDIO_API Vector3f getUpVector();
}; } // namespace sf::Listener
} // namespace sf
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \class sf::Listener /// \namespace sf::Listener
/// \ingroup audio /// \ingroup audio
/// ///
/// The audio listener defines the global properties of the /// The audio listener defines the global properties of the
@ -160,9 +155,6 @@ public:
/// listener in the 3D audio environment (position, direction and /// listener in the 3D audio environment (position, direction and
/// up vector), and to adjust the global volume. /// up vector), and to adjust the global volume.
/// ///
/// Because the listener is unique in the scene, sf::Listener only
/// contains static functions and doesn't have to be instantiated.
///
/// Usage example: /// Usage example:
/// \code /// \code
/// // Move the listener to the position (1, 0, -5) /// // Move the listener to the position (1, 0, -5)

View File

@ -38,44 +38,43 @@ class String;
/// \brief Give access to the system clipboard /// \brief Give access to the system clipboard
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_WINDOW_API Clipboard namespace Clipboard
{ {
public: ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// /// \brief Get the content of the clipboard as string data
/// \brief Get the content of the clipboard as string data ///
/// /// This function returns the content of the clipboard
/// This function returns the content of the clipboard /// as a string. If the clipboard does not contain string
/// as a string. If the clipboard does not contain string /// it returns an empty sf::String object.
/// it returns an empty sf::String object. ///
/// /// \return Clipboard contents as sf::String object
/// \return Clipboard contents as sf::String object ///
/// ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// SFML_WINDOW_API String getString();
static String getString();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set the content of the clipboard as string data /// \brief Set the content of the clipboard as string data
/// ///
/// This function sets the content of the clipboard as a /// This function sets the content of the clipboard as a
/// string. /// string.
/// ///
/// \warning Due to limitations on some operating systems, /// \warning Due to limitations on some operating systems,
/// setting the clipboard contents is only /// setting the clipboard contents is only
/// guaranteed to work if there is currently an /// guaranteed to work if there is currently an
/// open window for which events are being handled. /// open window for which events are being handled.
/// ///
/// \param text sf::String containing the data to be sent /// \param text sf::String containing the data to be sent
/// to the clipboard /// to the clipboard
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static void setString(const String& text); SFML_WINDOW_API void setString(const String& text);
}; } // namespace Clipboard
} // namespace sf } // namespace sf
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \class sf::Clipboard /// \namespace sf::Clipboard
/// \ingroup window /// \ingroup window
/// ///
/// sf::Clipboard provides an interface for getting and /// sf::Clipboard provides an interface for getting and

View File

@ -31,33 +31,29 @@
#include <SFML/System/String.hpp> #include <SFML/System/String.hpp>
namespace sf
{
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Give access to the real-time state of the joysticks /// \brief Give access to the real-time state of the joysticks
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_WINDOW_API Joystick namespace sf::Joystick
{
////////////////////////////////////////////////////////////
/// \brief Constants related to joysticks capabilities
///
////////////////////////////////////////////////////////////
enum
{ {
public:
////////////////////////////////////////////////////////////
/// \brief Constants related to joysticks capabilities
///
////////////////////////////////////////////////////////////
enum
{
Count = 8, //!< Maximum number of supported joysticks Count = 8, //!< Maximum number of supported joysticks
ButtonCount = 32, //!< Maximum number of supported buttons ButtonCount = 32, //!< Maximum number of supported buttons
AxisCount = 8 //!< Maximum number of supported axes AxisCount = 8 //!< Maximum number of supported axes
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Axes supported by SFML joysticks /// \brief Axes supported by SFML joysticks
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
enum Axis enum Axis
{ {
X, //!< The X axis X, //!< The X axis
Y, //!< The Y axis Y, //!< The Y axis
Z, //!< The Z axis Z, //!< The Z axis
@ -66,115 +62,112 @@ public:
V, //!< The V axis V, //!< The V axis
PovX, //!< The X axis of the point-of-view hat PovX, //!< The X axis of the point-of-view hat
PovY //!< The Y axis of the point-of-view hat PovY //!< The Y axis of the point-of-view hat
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Structure holding a joystick's identification /// \brief Structure holding a joystick's identification
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct SFML_WINDOW_API Identification struct SFML_WINDOW_API Identification
{ {
String name{"No Joystick"}; //!< Name of the joystick String name{"No Joystick"}; //!< Name of the joystick
unsigned int vendorId{0}; //!< Manufacturer identifier unsigned int vendorId{0}; //!< Manufacturer identifier
unsigned int productId{0}; //!< Product identifier unsigned int productId{0}; //!< Product identifier
};
////////////////////////////////////////////////////////////
/// \brief Check if a joystick is connected
///
/// \param joystick Index of the joystick to check
///
/// \return True if the joystick is connected, false otherwise
///
////////////////////////////////////////////////////////////
static bool isConnected(unsigned int joystick);
////////////////////////////////////////////////////////////
/// \brief Return the number of buttons supported by a joystick
///
/// If the joystick is not connected, this function returns 0.
///
/// \param joystick Index of the joystick
///
/// \return Number of buttons supported by the joystick
///
////////////////////////////////////////////////////////////
static unsigned int getButtonCount(unsigned int joystick);
////////////////////////////////////////////////////////////
/// \brief Check if a joystick supports a given axis
///
/// If the joystick is not connected, this function returns false.
///
/// \param joystick Index of the joystick
/// \param axis Axis to check
///
/// \return True if the joystick supports the axis, false otherwise
///
////////////////////////////////////////////////////////////
static bool hasAxis(unsigned int joystick, Axis axis);
////////////////////////////////////////////////////////////
/// \brief Check if a joystick button is pressed
///
/// If the joystick is not connected, this function returns false.
///
/// \param joystick Index of the joystick
/// \param button Button to check
///
/// \return True if the button is pressed, false otherwise
///
////////////////////////////////////////////////////////////
static bool isButtonPressed(unsigned int joystick, unsigned int button);
////////////////////////////////////////////////////////////
/// \brief Get the current position of a joystick axis
///
/// If the joystick is not connected, this function returns 0.
///
/// \param joystick Index of the joystick
/// \param axis Axis to check
///
/// \return Current position of the axis, in range [-100 .. 100]
///
////////////////////////////////////////////////////////////
static float getAxisPosition(unsigned int joystick, Axis axis);
////////////////////////////////////////////////////////////
/// \brief Get the joystick information
///
/// \param joystick Index of the joystick
///
/// \return Structure containing joystick information.
///
////////////////////////////////////////////////////////////
static Identification getIdentification(unsigned int joystick);
////////////////////////////////////////////////////////////
/// \brief Update the states of all joysticks
///
/// This function is used internally by SFML, so you normally
/// don't have to call it explicitly. However, you may need to
/// call it if you have no window yet (or no window at all):
/// in this case the joystick states are not updated automatically.
///
////////////////////////////////////////////////////////////
static void update();
}; };
} // namespace sf ////////////////////////////////////////////////////////////
/// \brief Check if a joystick is connected
///
/// \param joystick Index of the joystick to check
///
/// \return True if the joystick is connected, false otherwise
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API bool isConnected(unsigned int joystick);
////////////////////////////////////////////////////////////
/// \brief Return the number of buttons supported by a joystick
///
/// If the joystick is not connected, this function returns 0.
///
/// \param joystick Index of the joystick
///
/// \return Number of buttons supported by the joystick
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API unsigned int getButtonCount(unsigned int joystick);
////////////////////////////////////////////////////////////
/// \brief Check if a joystick supports a given axis
///
/// If the joystick is not connected, this function returns false.
///
/// \param joystick Index of the joystick
/// \param axis Axis to check
///
/// \return True if the joystick supports the axis, false otherwise
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API bool hasAxis(unsigned int joystick, Axis axis);
////////////////////////////////////////////////////////////
/// \brief Check if a joystick button is pressed
///
/// If the joystick is not connected, this function returns false.
///
/// \param joystick Index of the joystick
/// \param button Button to check
///
/// \return True if the button is pressed, false otherwise
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API bool isButtonPressed(unsigned int joystick, unsigned int button);
////////////////////////////////////////////////////////////
/// \brief Get the current position of a joystick axis
///
/// If the joystick is not connected, this function returns 0.
///
/// \param joystick Index of the joystick
/// \param axis Axis to check
///
/// \return Current position of the axis, in range [-100 .. 100]
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API float getAxisPosition(unsigned int joystick, Axis axis);
////////////////////////////////////////////////////////////
/// \brief Get the joystick information
///
/// \param joystick Index of the joystick
///
/// \return Structure containing joystick information.
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API Identification getIdentification(unsigned int joystick);
////////////////////////////////////////////////////////////
/// \brief Update the states of all joysticks
///
/// This function is used internally by SFML, so you normally
/// don't have to call it explicitly. However, you may need to
/// call it if you have no window yet (or no window at all):
/// in this case the joystick states are not updated automatically.
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API void update();
} // namespace sf::Joystick
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \class sf::Joystick /// \namespace sf::Joystick
/// \ingroup window /// \ingroup window
/// ///
/// sf::Joystick provides an interface to the state of the /// sf::Joystick provides an interface to the state of the
/// joysticks. It only contains static functions, so it's not /// joysticks. Each joystick is identified by an index that
/// meant to be instantiated. Instead, each joystick is identified /// is passed to the functions in this namespace.
/// by an index that is passed to the functions of this class.
/// ///
/// This class allows users to query the state of joysticks at any /// This namespace allows users to query the state of joysticks at any
/// time and directly, without having to deal with a window and /// time and directly, without having to deal with a window and
/// its events. Compared to the JoystickMoved, JoystickButtonPressed /// its events. Compared to the JoystickMoved, JoystickButtonPressed
/// and JoystickButtonReleased events, sf::Joystick can retrieve the /// and JoystickButtonReleased events, sf::Joystick can retrieve the

View File

@ -30,21 +30,18 @@
#include <SFML/Window/Export.hpp> #include <SFML/Window/Export.hpp>
namespace sf
{
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Give access to the real-time state of the keyboard /// \brief Give access to the real-time state of the keyboard
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_WINDOW_API Keyboard namespace sf::Keyboard
{
////////////////////////////////////////////////////////////
/// \brief Key codes
///
////////////////////////////////////////////////////////////
enum Key
{ {
public:
////////////////////////////////////////////////////////////
/// \brief Key codes
///
////////////////////////////////////////////////////////////
enum Key
{
Unknown = -1, //!< Unhandled key Unknown = -1, //!< Unhandled key
A = 0, //!< The A key A = 0, //!< The A key
B, //!< The B key B, //!< The B key
@ -149,46 +146,43 @@ public:
Pause, //!< The Pause key Pause, //!< The Pause key
KeyCount //!< Keep last -- the total number of keyboard keys KeyCount //!< Keep last -- the total number of keyboard keys
};
////////////////////////////////////////////////////////////
/// \brief Check if a key is pressed
///
/// \param key Key to check
///
/// \return True if the key is pressed, false otherwise
///
////////////////////////////////////////////////////////////
static bool isKeyPressed(Key key);
////////////////////////////////////////////////////////////
/// \brief Show or hide the virtual keyboard
///
/// Warning: the virtual keyboard is not supported on all
/// systems. It will typically be implemented on mobile OSes
/// (Android, iOS) but not on desktop OSes (Windows, Linux, ...).
///
/// If the virtual keyboard is not available, this function does
/// nothing.
///
/// \param visible True to show, false to hide
///
////////////////////////////////////////////////////////////
static void setVirtualKeyboardVisible(bool visible);
}; };
} // namespace sf ////////////////////////////////////////////////////////////
/// \brief Check if a key is pressed
///
/// \param key Key to check
///
/// \return True if the key is pressed, false otherwise
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API bool isKeyPressed(Key key);
////////////////////////////////////////////////////////////
/// \brief Show or hide the virtual keyboard
///
/// Warning: the virtual keyboard is not supported on all
/// systems. It will typically be implemented on mobile OSes
/// (Android, iOS) but not on desktop OSes (Windows, Linux, ...).
///
/// If the virtual keyboard is not available, this function does
/// nothing.
///
/// \param visible True to show, false to hide
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API void setVirtualKeyboardVisible(bool visible);
} // namespace sf::Keyboard
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \class sf::Keyboard /// \namespace sf::Keyboard
/// \ingroup window /// \ingroup window
/// ///
/// sf::Keyboard provides an interface to the state of the /// sf::Keyboard provides an interface to the state of the
/// keyboard. It only contains static functions (a single /// keyboard.
/// keyboard is assumed), so it's not meant to be instantiated.
/// ///
/// This class allows users to query the keyboard state at any /// This namespace allows users to query the keyboard state at any
/// time and directly, without having to deal with a window and /// time and directly, without having to deal with a window and
/// its events. Compared to the KeyPressed and KeyReleased events, /// its events. Compared to the KeyPressed and KeyReleased events,
/// sf::Keyboard can retrieve the state of a key at any time /// sf::Keyboard can retrieve the state of a key at any time

View File

@ -40,15 +40,14 @@ class WindowBase;
/// \brief Give access to the real-time state of the mouse /// \brief Give access to the real-time state of the mouse
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_WINDOW_API Mouse namespace Mouse
{
////////////////////////////////////////////////////////////
/// \brief Mouse buttons
///
////////////////////////////////////////////////////////////
enum Button
{ {
public:
////////////////////////////////////////////////////////////
/// \brief Mouse buttons
///
////////////////////////////////////////////////////////////
enum Button
{
Left, //!< The left mouse button Left, //!< The left mouse button
Right, //!< The right mouse button Right, //!< The right mouse button
Middle, //!< The middle (wheel) mouse button Middle, //!< The middle (wheel) mouse button
@ -56,91 +55,90 @@ public:
XButton2, //!< The second extra mouse button XButton2, //!< The second extra mouse button
ButtonCount //!< Keep last -- the total number of mouse buttons ButtonCount //!< Keep last -- the total number of mouse buttons
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Mouse wheels /// \brief Mouse wheels
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
enum Wheel enum Wheel
{ {
VerticalWheel, //!< The vertical mouse wheel VerticalWheel, //!< The vertical mouse wheel
HorizontalWheel //!< The horizontal mouse wheel HorizontalWheel //!< The horizontal mouse wheel
};
////////////////////////////////////////////////////////////
/// \brief Check if a mouse button is pressed
///
/// \warning Checking the state of buttons Mouse::XButton1 and
/// Mouse::XButton2 is not supported on Linux with X11.
///
/// \param button Button to check
///
/// \return True if the button is pressed, false otherwise
///
////////////////////////////////////////////////////////////
static bool isButtonPressed(Button button);
////////////////////////////////////////////////////////////
/// \brief Get the current position of the mouse in desktop coordinates
///
/// This function returns the global position of the mouse
/// cursor on the desktop.
///
/// \return Current position of the mouse
///
////////////////////////////////////////////////////////////
static Vector2i getPosition();
////////////////////////////////////////////////////////////
/// \brief Get the current position of the mouse in window coordinates
///
/// This function returns the current position of the mouse
/// cursor, relative to the given window.
///
/// \param relativeTo Reference window
///
/// \return Current position of the mouse
///
////////////////////////////////////////////////////////////
static Vector2i getPosition(const WindowBase& relativeTo);
////////////////////////////////////////////////////////////
/// \brief Set the current position of the mouse in desktop coordinates
///
/// This function sets the global position of the mouse
/// cursor on the desktop.
///
/// \param position New position of the mouse
///
////////////////////////////////////////////////////////////
static void setPosition(const Vector2i& position);
////////////////////////////////////////////////////////////
/// \brief Set the current position of the mouse in window coordinates
///
/// This function sets the current position of the mouse
/// cursor, relative to the given window.
///
/// \param position New position of the mouse
/// \param relativeTo Reference window
///
////////////////////////////////////////////////////////////
static void setPosition(const Vector2i& position, const WindowBase& relativeTo);
}; };
////////////////////////////////////////////////////////////
/// \brief Check if a mouse button is pressed
///
/// \warning Checking the state of buttons Mouse::XButton1 and
/// Mouse::XButton2 is not supported on Linux with X11.
///
/// \param button Button to check
///
/// \return True if the button is pressed, false otherwise
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API bool isButtonPressed(Button button);
////////////////////////////////////////////////////////////
/// \brief Get the current position of the mouse in desktop coordinates
///
/// This function returns the global position of the mouse
/// cursor on the desktop.
///
/// \return Current position of the mouse
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API Vector2i getPosition();
////////////////////////////////////////////////////////////
/// \brief Get the current position of the mouse in window coordinates
///
/// This function returns the current position of the mouse
/// cursor, relative to the given window.
///
/// \param relativeTo Reference window
///
/// \return Current position of the mouse
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API Vector2i getPosition(const WindowBase& relativeTo);
////////////////////////////////////////////////////////////
/// \brief Set the current position of the mouse in desktop coordinates
///
/// This function sets the global position of the mouse
/// cursor on the desktop.
///
/// \param position New position of the mouse
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API void setPosition(const Vector2i& position);
////////////////////////////////////////////////////////////
/// \brief Set the current position of the mouse in window coordinates
///
/// This function sets the current position of the mouse
/// cursor, relative to the given window.
///
/// \param position New position of the mouse
/// \param relativeTo Reference window
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API void setPosition(const Vector2i& position, const WindowBase& relativeTo);
} // namespace Mouse
} // namespace sf } // namespace sf
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \class sf::Mouse /// \namespace sf::Mouse
/// \ingroup window /// \ingroup window
/// ///
/// sf::Mouse provides an interface to the state of the /// sf::Mouse provides an interface to the state of the
/// mouse. It only contains static functions (a single /// mouse. A single mouse is assumed.
/// mouse is assumed), so it's not meant to be instantiated.
/// ///
/// This class allows users to query the mouse state at any /// This namespace allows users to query the mouse state at any
/// time and directly, without having to deal with a window and /// time and directly, without having to deal with a window and
/// its events. Compared to the MouseMoved, MouseButtonPressed /// its events. Compared to the MouseMoved, MouseButtonPressed
/// and MouseButtonReleased events, sf::Mouse can retrieve the /// and MouseButtonReleased events, sf::Mouse can retrieve the

View File

@ -31,22 +31,18 @@
#include <SFML/System/Vector3.hpp> #include <SFML/System/Vector3.hpp>
namespace sf
{
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Give access to the real-time state of the sensors /// \brief Give access to the real-time state of the sensors
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_WINDOW_API Sensor namespace sf::Sensor
{
////////////////////////////////////////////////////////////
/// \brief Sensor type
///
////////////////////////////////////////////////////////////
enum Type
{ {
public:
////////////////////////////////////////////////////////////
/// \brief Sensor type
///
////////////////////////////////////////////////////////////
enum Type
{
Accelerometer, //!< Measures the raw acceleration (m/s^2) Accelerometer, //!< Measures the raw acceleration (m/s^2)
Gyroscope, //!< Measures the raw rotation rates (degrees/s) Gyroscope, //!< Measures the raw rotation rates (degrees/s)
Magnetometer, //!< Measures the ambient magnetic field (micro-teslas) Magnetometer, //!< Measures the ambient magnetic field (micro-teslas)
@ -55,56 +51,53 @@ public:
Orientation, //!< Measures the absolute 3D orientation (degrees) Orientation, //!< Measures the absolute 3D orientation (degrees)
Count //!< Keep last -- the total number of sensor types Count //!< Keep last -- the total number of sensor types
};
////////////////////////////////////////////////////////////
/// \brief Check if a sensor is available on the underlying platform
///
/// \param sensor Sensor to check
///
/// \return True if the sensor is available, false otherwise
///
////////////////////////////////////////////////////////////
static bool isAvailable(Type sensor);
////////////////////////////////////////////////////////////
/// \brief Enable or disable a sensor
///
/// All sensors are disabled by default, to avoid consuming too
/// much battery power. Once a sensor is enabled, it starts
/// sending events of the corresponding type.
///
/// This function does nothing if the sensor is unavailable.
///
/// \param sensor Sensor to enable
/// \param enabled True to enable, false to disable
///
////////////////////////////////////////////////////////////
static void setEnabled(Type sensor, bool enabled);
////////////////////////////////////////////////////////////
/// \brief Get the current sensor value
///
/// \param sensor Sensor to read
///
/// \return The current sensor value
///
////////////////////////////////////////////////////////////
static Vector3f getValue(Type sensor);
}; };
} // namespace sf ////////////////////////////////////////////////////////////
/// \brief Check if a sensor is available on the underlying platform
///
/// \param sensor Sensor to check
///
/// \return True if the sensor is available, false otherwise
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API bool isAvailable(Type sensor);
////////////////////////////////////////////////////////////
/// \brief Enable or disable a sensor
///
/// All sensors are disabled by default, to avoid consuming too
/// much battery power. Once a sensor is enabled, it starts
/// sending events of the corresponding type.
///
/// This function does nothing if the sensor is unavailable.
///
/// \param sensor Sensor to enable
/// \param enabled True to enable, false to disable
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API void setEnabled(Type sensor, bool enabled);
////////////////////////////////////////////////////////////
/// \brief Get the current sensor value
///
/// \param sensor Sensor to read
///
/// \return The current sensor value
///
////////////////////////////////////////////////////////////
SFML_WINDOW_API Vector3f getValue(Type sensor);
} // namespace sf::Sensor
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \class sf::Sensor /// \namespace sf::Sensor
/// \ingroup window /// \ingroup window
/// ///
/// sf::Sensor provides an interface to the state of the /// sf::Sensor provides an interface to the state of the
/// various sensors that a device provides. It only contains static /// various sensors that a device provides.
/// functions, so it's not meant to be instantiated.
/// ///
/// This class allows users to query the sensors values at any /// This namespace allows users to query the sensors values at any
/// time and directly, without having to deal with a window and /// time and directly, without having to deal with a window and
/// its events. Compared to the SensorChanged event, sf::Sensor /// its events. Compared to the SensorChanged event, sf::Sensor
/// can retrieve the state of a sensor at any time (you don't need to /// can retrieve the state of a sensor at any time (you don't need to

View File

@ -40,59 +40,57 @@ class WindowBase;
/// \brief Give access to the real-time state of the touches /// \brief Give access to the real-time state of the touches
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_WINDOW_API Touch namespace Touch
{ {
public: ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// /// \brief Check if a touch event is currently down
/// \brief Check if a touch event is currently down ///
/// /// \param finger Finger index
/// \param finger Finger index ///
/// /// \return True if \a finger is currently touching the screen, false otherwise
/// \return True if \a finger is currently touching the screen, false otherwise ///
/// ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// SFML_WINDOW_API bool isDown(unsigned int finger);
static bool isDown(unsigned int finger);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the current position of a touch in desktop coordinates /// \brief Get the current position of a touch in desktop coordinates
/// ///
/// This function returns the current touch position /// This function returns the current touch position
/// in global (desktop) coordinates. /// in global (desktop) coordinates.
/// ///
/// \param finger Finger index /// \param finger Finger index
/// ///
/// \return Current position of \a finger, or undefined if it's not down /// \return Current position of \a finger, or undefined if it's not down
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Vector2i getPosition(unsigned int finger); SFML_WINDOW_API Vector2i getPosition(unsigned int finger);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the current position of a touch in window coordinates /// \brief Get the current position of a touch in window coordinates
/// ///
/// This function returns the current touch position /// This function returns the current touch position
/// relative to the given window. /// relative to the given window.
/// ///
/// \param finger Finger index /// \param finger Finger index
/// \param relativeTo Reference window /// \param relativeTo Reference window
/// ///
/// \return Current position of \a finger, or undefined if it's not down /// \return Current position of \a finger, or undefined if it's not down
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Vector2i getPosition(unsigned int finger, const WindowBase& relativeTo); SFML_WINDOW_API Vector2i getPosition(unsigned int finger, const WindowBase& relativeTo);
}; } // namespace Touch
} // namespace sf } // namespace sf
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \class sf::Touch /// \namespace sf::Touch
/// \ingroup window /// \ingroup window
/// ///
/// sf::Touch provides an interface to the state of the /// sf::Touch provides an interface to the state of the
/// touches. It only contains static functions, so it's not /// touches.
/// meant to be instantiated.
/// ///
/// This class allows users to query the touches state at any /// This namespace allows users to query the touches state at any
/// time and directly, without having to deal with a window and /// time and directly, without having to deal with a window and
/// its events. Compared to the TouchBegan, TouchMoved /// its events. Compared to the TouchBegan, TouchMoved
/// and TouchEnded events, sf::Touch can retrieve the /// and TouchEnded events, sf::Touch can retrieve the

View File

@ -58,53 +58,53 @@ using VulkanFunctionPointer = void (*)();
/// \brief Vulkan helper functions /// \brief Vulkan helper functions
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_WINDOW_API Vulkan namespace Vulkan
{ {
public: ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// /// \brief Tell whether or not the system supports Vulkan
/// \brief Tell whether or not the system supports Vulkan ///
/// /// This function should always be called before using
/// This function should always be called before using /// the Vulkan features. If it returns false, then
/// the Vulkan features. If it returns false, then /// any attempt to use Vulkan will fail.
/// any attempt to use Vulkan will fail. ///
/// /// If only compute is required, set \a requireGraphics
/// If only compute is required, set \a requireGraphics /// to false to skip checking for the extensions necessary
/// to false to skip checking for the extensions necessary /// for graphics rendering.
/// for graphics rendering. ///
/// /// \param requireGraphics
/// \param requireGraphics ///
/// /// \return True if Vulkan is supported, false otherwise
/// \return True if Vulkan is supported, false otherwise ///
/// ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// SFML_WINDOW_API bool isAvailable(bool requireGraphics = true);
static bool isAvailable(bool requireGraphics = true);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the address of a Vulkan function /// \brief Get the address of a Vulkan function
/// ///
/// \param name Name of the function to get the address of /// \param name Name of the function to get the address of
/// ///
/// \return Address of the Vulkan function, 0 on failure /// \return Address of the Vulkan function, 0 on failure
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static VulkanFunctionPointer getFunction(const char* name); SFML_WINDOW_API VulkanFunctionPointer getFunction(const char* name);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get Vulkan instance extensions required for graphics /// \brief Get Vulkan instance extensions required for graphics
/// ///
/// \return Vulkan instance extensions required for graphics /// \return Vulkan instance extensions required for graphics
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static const std::vector<const char*>& getGraphicsRequiredInstanceExtensions(); SFML_WINDOW_API const std::vector<const char*>& getGraphicsRequiredInstanceExtensions();
}; } // namespace Vulkan
} // namespace sf } // namespace sf
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \class sf::Vulkan /// \namespace sf::Vulkan
/// \ingroup window /// \ingroup window
/// ///
/// /// This namespace contains functions to help you use SFML
/// for windowing and write your own Vulkan code for graphics
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -7,7 +7,7 @@ int main()
{ {
// Audio // Audio
[[maybe_unused]] sf::InputSoundFile inputSoundFile; [[maybe_unused]] sf::InputSoundFile inputSoundFile;
[[maybe_unused]] sf::Listener listener; [[maybe_unused]] sf::SoundBufferRecorder soundBufferRecorder;
[[maybe_unused]] sf::Music music; [[maybe_unused]] sf::Music music;
[[maybe_unused]] sf::Sound sound; [[maybe_unused]] sf::Sound sound;