Implemented global inputs (sf::Keyboard, sf::Mouse, sf::Joystick) and removed the event-based sf::Input.
Window::WaitEvent now works with joystick events as well. Added Event::JoystickConnected and Event::JoystickDisconnected. Added Window::GetCursorPosition.
This commit is contained in:
parent
5469eaa8c0
commit
8621e45960
48 changed files with 2969 additions and 1517 deletions
|
@ -250,8 +250,9 @@ bool operator !=(const Vector2<T>& left, const Vector2<T>& right);
|
|||
#include <SFML/System/Vector2.inl>
|
||||
|
||||
// Define the most common types
|
||||
typedef Vector2<int> Vector2i;
|
||||
typedef Vector2<float> Vector2f;
|
||||
typedef Vector2<int> Vector2i;
|
||||
typedef Vector2<unsigned int> Vector2u;
|
||||
typedef Vector2<float> Vector2f;
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
|
|
@ -33,7 +33,9 @@
|
|||
#include <SFML/Window/Context.hpp>
|
||||
#include <SFML/Window/ContextSettings.hpp>
|
||||
#include <SFML/Window/Event.hpp>
|
||||
#include <SFML/Window/Input.hpp>
|
||||
#include <SFML/Window/Joystick.hpp>
|
||||
#include <SFML/Window/Keyboard.hpp>
|
||||
#include <SFML/Window/Mouse.hpp>
|
||||
#include <SFML/Window/VideoMode.hpp>
|
||||
#include <SFML/Window/Window.hpp>
|
||||
#include <SFML/Window/WindowStyle.hpp>
|
||||
|
|
|
@ -29,174 +29,13 @@
|
|||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Config.hpp>
|
||||
#include <SFML/Window/Joystick.hpp>
|
||||
#include <SFML/Window/Keyboard.hpp>
|
||||
#include <SFML/Window/Mouse.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace Key
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \ingroup window
|
||||
/// \brief Definition of key codes for keyboard events
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Code
|
||||
{
|
||||
A = 'a', ///< The A key
|
||||
B = 'b', ///< The B key
|
||||
C = 'c', ///< The C key
|
||||
D = 'd', ///< The D key
|
||||
E = 'e', ///< The E key
|
||||
F = 'f', ///< The F key
|
||||
G = 'g', ///< The G key
|
||||
H = 'h', ///< The H key
|
||||
I = 'i', ///< The I key
|
||||
J = 'j', ///< The J key
|
||||
K = 'k', ///< The K key
|
||||
L = 'l', ///< The L key
|
||||
M = 'm', ///< The M key
|
||||
N = 'n', ///< The N key
|
||||
O = 'o', ///< The O key
|
||||
P = 'p', ///< The P key
|
||||
Q = 'q', ///< The Q key
|
||||
R = 'r', ///< The R key
|
||||
S = 's', ///< The S key
|
||||
T = 't', ///< The T key
|
||||
U = 'u', ///< The U key
|
||||
V = 'v', ///< The V key
|
||||
W = 'w', ///< The W key
|
||||
X = 'x', ///< The X key
|
||||
Y = 'y', ///< The Y key
|
||||
Z = 'z', ///< The Z key
|
||||
Num0 = '0', ///< The 0 key
|
||||
Num1 = '1', ///< The 1 key
|
||||
Num2 = '2', ///< The 2 key
|
||||
Num3 = '3', ///< The 3 key
|
||||
Num4 = '4', ///< The 4 key
|
||||
Num5 = '5', ///< The 5 key
|
||||
Num6 = '6', ///< The 6 key
|
||||
Num7 = '7', ///< The 7 key
|
||||
Num8 = '8', ///< The 8 key
|
||||
Num9 = '9', ///< The 9 key
|
||||
Escape = 256, ///< The Escape key
|
||||
LControl, ///< The left Control key
|
||||
LShift, ///< The left Shift key
|
||||
LAlt, ///< The left Alt key
|
||||
LSystem, ///< The left OS specific key : windows (Windows and Linux), apple (MacOS X), ...
|
||||
RControl, ///< The right Control key
|
||||
RShift, ///< The right Shift key
|
||||
RAlt, ///< The right Alt key
|
||||
RSystem, ///< The right OS specific key : windows (Windows and Linux), apple (MacOS X), ...
|
||||
Menu, ///< The Menu key
|
||||
LBracket, ///< The [ key
|
||||
RBracket, ///< The ] key
|
||||
SemiColon, ///< The ; key
|
||||
Comma, ///< The , key
|
||||
Period, ///< The . key
|
||||
Quote, ///< The ' key
|
||||
Slash, ///< The / key
|
||||
BackSlash, ///< The \ key
|
||||
Tilde, ///< The ~ key
|
||||
Equal, ///< The = key
|
||||
Dash, ///< The - key
|
||||
Space, ///< The Space key
|
||||
Return, ///< The Return key
|
||||
Back, ///< The Backspace key
|
||||
Tab, ///< The Tabulation key
|
||||
PageUp, ///< The Page up key
|
||||
PageDown, ///< The Page down key
|
||||
End, ///< The End key
|
||||
Home, ///< The Home key
|
||||
Insert, ///< The Insert key
|
||||
Delete, ///< The Delete key
|
||||
Add, ///< +
|
||||
Subtract, ///< -
|
||||
Multiply, ///< *
|
||||
Divide, ///< /
|
||||
Left, ///< Left arrow
|
||||
Right, ///< Right arrow
|
||||
Up, ///< Up arrow
|
||||
Down, ///< Down arrow
|
||||
Numpad0, ///< The numpad 0 key
|
||||
Numpad1, ///< The numpad 1 key
|
||||
Numpad2, ///< The numpad 2 key
|
||||
Numpad3, ///< The numpad 3 key
|
||||
Numpad4, ///< The numpad 4 key
|
||||
Numpad5, ///< The numpad 5 key
|
||||
Numpad6, ///< The numpad 6 key
|
||||
Numpad7, ///< The numpad 7 key
|
||||
Numpad8, ///< The numpad 8 key
|
||||
Numpad9, ///< The numpad 9 key
|
||||
F1, ///< The F1 key
|
||||
F2, ///< The F2 key
|
||||
F3, ///< The F3 key
|
||||
F4, ///< The F4 key
|
||||
F5, ///< The F5 key
|
||||
F6, ///< The F6 key
|
||||
F7, ///< The F7 key
|
||||
F8, ///< The F8 key
|
||||
F9, ///< The F8 key
|
||||
F10, ///< The F10 key
|
||||
F11, ///< The F11 key
|
||||
F12, ///< The F12 key
|
||||
F13, ///< The F13 key
|
||||
F14, ///< The F14 key
|
||||
F15, ///< The F15 key
|
||||
Pause, ///< The Pause key
|
||||
|
||||
Count ///< Keep last -- the total number of keyboard keys
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace Mouse
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \ingroup window
|
||||
/// \brief Definition of button codes for mouse events
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Button
|
||||
{
|
||||
Left, ///< The left mouse button
|
||||
Right, ///< The right mouse button
|
||||
Middle, ///< The middle (wheel) mouse button
|
||||
XButton1, ///< The first extra mouse button
|
||||
XButton2, ///< The second extra mouse button
|
||||
|
||||
ButtonCount ///< Keep last -- the total number of mouse buttons
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace Joy
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \ingroup window
|
||||
/// \brief Definition of joystick axis for joystick events
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Axis
|
||||
{
|
||||
AxisX, ///< The X axis
|
||||
AxisY, ///< The Y axis
|
||||
AxisZ, ///< The Z axis
|
||||
AxisR, ///< The R axis
|
||||
AxisU, ///< The U axis
|
||||
AxisV, ///< The V axis
|
||||
AxisPOV, ///< The Point-Of-View axis (hat)
|
||||
|
||||
AxisCount // Keep last -- total number of joystick axis
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
Count = 8, ///< Total number of supported joysticks
|
||||
ButtonCount = 32 ///< Total number of supported joystick buttons
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Defines a system event and its parameters
|
||||
///
|
||||
|
@ -205,17 +44,27 @@ class Event
|
|||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Size events parameters (Resized)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct SizeEvent
|
||||
{
|
||||
unsigned int Width; ///< New width, in pixels
|
||||
unsigned int Height; ///< New height, in pixels
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Keyboard event parameters (KeyPressed, KeyReleased)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct KeyEvent
|
||||
{
|
||||
Key::Code Code; ///< Code of the key that has been pressed
|
||||
bool Alt; ///< Is the Alt key pressed?
|
||||
bool Control; ///< Is the Control key pressed?
|
||||
bool Shift; ///< Is the Shift key pressed?
|
||||
bool System; ///< Is the System key pressed?
|
||||
Keyboard::Key Code; ///< Code of the key that has been pressed
|
||||
bool Alt; ///< Is the Alt key pressed?
|
||||
bool Control; ///< Is the Control key pressed?
|
||||
bool Shift; ///< Is the Shift key pressed?
|
||||
bool System; ///< Is the System key pressed?
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -261,35 +110,35 @@ public :
|
|||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Joystick axis move event parameters (JoyMoved)
|
||||
/// \brief Joystick connection events parameters
|
||||
/// (JoystickConnected, JoystickDisconnected)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct JoyMoveEvent
|
||||
struct JoystickConnectEvent
|
||||
{
|
||||
unsigned int JoystickId; ///< Index of the joystick (in range [0 .. Joy::Count - 1])
|
||||
Joy::Axis Axis; ///< Axis on which the joystick moved
|
||||
float Position; ///< New position on the axis (in range [-100 .. 100])
|
||||
unsigned int JoystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Joystick axis move event parameters (JoystickMoved)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct JoystickMoveEvent
|
||||
{
|
||||
unsigned int JoystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])
|
||||
Joystick::Axis Axis; ///< Axis on which the joystick moved
|
||||
float Position; ///< New position on the axis (in range [-100 .. 100])
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Joystick buttons events parameters
|
||||
/// (JoyButtonPressed, JoyButtonReleased)
|
||||
/// (JoystickButtonPressed, JoystickButtonReleased)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct JoyButtonEvent
|
||||
struct JoystickButtonEvent
|
||||
{
|
||||
unsigned int JoystickId; ///< Index of the joystick (in range [0 .. Joy::Count - 1])
|
||||
unsigned int Button; ///< Index of the button that has been pressed (in range [0 .. Joy::ButtonCount - 1])
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Size events parameters (Resized)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct SizeEvent
|
||||
{
|
||||
unsigned int Width; ///< New width, in pixels
|
||||
unsigned int Height; ///< New height, in pixels
|
||||
unsigned int JoystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])
|
||||
unsigned int Button; ///< Index of the button that has been pressed (in range [0 .. Joystick::ButtonCount - 1])
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -298,24 +147,26 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
enum EventType
|
||||
{
|
||||
Closed, ///< The window requested to be closed
|
||||
Resized, ///< The window was resized
|
||||
LostFocus, ///< The window lost the focus
|
||||
GainedFocus, ///< The window gained the focus
|
||||
TextEntered, ///< A character was entered
|
||||
KeyPressed, ///< A key was pressed
|
||||
KeyReleased, ///< A key was released
|
||||
MouseWheelMoved, ///< The mouse wheel was scrolled
|
||||
MouseButtonPressed, ///< A mouse button was pressed
|
||||
MouseButtonReleased, ///< A mouse button was released
|
||||
MouseMoved, ///< The mouse cursor moved
|
||||
MouseEntered, ///< The mouse cursor entered the area of the window
|
||||
MouseLeft, ///< The mouse cursor left the area of the window
|
||||
JoyButtonPressed, ///< A joystick button was pressed
|
||||
JoyButtonReleased, ///< A joystick button was released
|
||||
JoyMoved, ///< The joystick moved along an axis
|
||||
Closed, ///< The window requested to be closed
|
||||
Resized, ///< The window was resized
|
||||
LostFocus, ///< The window lost the focus
|
||||
GainedFocus, ///< The window gained the focus
|
||||
TextEntered, ///< A character was entered
|
||||
KeyPressed, ///< A key was pressed
|
||||
KeyReleased, ///< A key was released
|
||||
MouseWheelMoved, ///< The mouse wheel was scrolled
|
||||
MouseButtonPressed, ///< A mouse button was pressed
|
||||
MouseButtonReleased, ///< A mouse button was released
|
||||
MouseMoved, ///< The mouse cursor moved
|
||||
MouseEntered, ///< The mouse cursor entered the area of the window
|
||||
MouseLeft, ///< The mouse cursor left the area of the window
|
||||
JoystickButtonPressed, ///< A joystick button was pressed
|
||||
JoystickButtonReleased, ///< A joystick button was released
|
||||
JoystickMoved, ///< The joystick moved along an axis
|
||||
JoystickConnected, ///< A joystick was connected
|
||||
JoystickDisconnected, ///< A joystick was disconnected
|
||||
|
||||
Count ///< Keep last -- the total number of event types
|
||||
Count ///< Keep last -- the total number of event types
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -325,14 +176,15 @@ public :
|
|||
|
||||
union
|
||||
{
|
||||
KeyEvent Key; ///< Key event parameters
|
||||
TextEvent Text; ///< Text event parameters
|
||||
MouseMoveEvent MouseMove; ///< Mouse move event parameters
|
||||
MouseButtonEvent MouseButton; ///< Mouse button event parameters
|
||||
MouseWheelEvent MouseWheel; ///< Mouse wheel event parameters
|
||||
JoyMoveEvent JoyMove; ///< Joystick move event parameters
|
||||
JoyButtonEvent JoyButton; ///< Joystick button event parameters
|
||||
SizeEvent Size; ///< Size event parameters
|
||||
SizeEvent Size; ///< Size event parameters
|
||||
KeyEvent Key; ///< Key event parameters
|
||||
TextEvent Text; ///< Text event parameters
|
||||
MouseMoveEvent MouseMove; ///< Mouse move event parameters
|
||||
MouseButtonEvent MouseButton; ///< Mouse button event parameters
|
||||
MouseWheelEvent MouseWheel; ///< Mouse wheel event parameters
|
||||
JoystickMoveEvent JoystickMove; ///< Joystick move event parameters
|
||||
JoystickButtonEvent JoystickButton; ///< Joystick button event parameters
|
||||
JoystickConnectEvent JoystickConnect; ///< Joystick (dis)connect event parameters
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -1,198 +0,0 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_INPUT_HPP
|
||||
#define SFML_INPUT_HPP
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Config.hpp>
|
||||
#include <SFML/System/NonCopyable.hpp>
|
||||
#include <SFML/Window/Event.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
class Window;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Give access to the real-time states of keyboard,
|
||||
/// mouse and joysticks
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API Input : NonCopyable
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Default constructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Input();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current state of a key (pressed or released)
|
||||
///
|
||||
/// \param key Code of the key to test
|
||||
///
|
||||
/// \return True if key is down, false if key is up
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsKeyDown(Key::Code key) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current state of a mouse button (pressed or released)
|
||||
///
|
||||
/// \param button Code of the mouse button to check
|
||||
///
|
||||
/// \return True if button is down, false if button is up
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsMouseButtonDown(Mouse::Button button) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current state of a joystick button (pressed or released)
|
||||
///
|
||||
/// \param joystick Index of the joystick to test (in range [0 .. Joy::Count - 1])
|
||||
/// \param button Index of the button to test (in range [0 .. Joy::ButtonCount - 1])
|
||||
///
|
||||
/// \return True if button is down, false if button is up
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsJoystickButtonDown(unsigned int joystick, unsigned int button) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current mouse X position
|
||||
///
|
||||
/// The returned position is relative to the left border
|
||||
/// of the owner window.
|
||||
///
|
||||
/// \return Current mouse left position
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
int GetMouseX() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current mouse Y position
|
||||
///
|
||||
/// The returned position is relative to the top border
|
||||
/// of the owner window.
|
||||
///
|
||||
/// \return Current mouse top position
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
int GetMouseY() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current position of a joystick axis
|
||||
///
|
||||
/// The returned position is in the range [-100 .. 100], except
|
||||
/// the POV which is an angle and is thus defined in [0 .. 360].
|
||||
///
|
||||
/// \param joystick Index of the joystick to test (in range [0 .. Joy::Count - 1])
|
||||
/// \param axis Axis to test
|
||||
///
|
||||
/// \return Current axis position
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetJoystickAxis(unsigned int joystick, Joy::Axis axis) const;
|
||||
|
||||
private :
|
||||
|
||||
friend class Window;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Notifies the input of a new event
|
||||
///
|
||||
/// This function is for internal use only, it is called by
|
||||
/// the owner window every time a new event has been triggered.
|
||||
///
|
||||
/// \param event Event received
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void OnEvent(const Event& event);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Reset all the states
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void ResetStates();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
bool myKeys[Key::Count]; ///< Array containing the state of all keyboard keys
|
||||
bool myMouseButtons[Mouse::ButtonCount]; ///< Array containing the state of all mouse buttons
|
||||
int myMouseX; ///< Mouse position on X
|
||||
int myMouseY; ///< Mouse position on Y
|
||||
bool myJoystickButtons[Joy::Count][Joy::ButtonCount]; ///< Array containing the state of all joysticks buttons
|
||||
float myJoystickAxis[Joy::Count][Joy::AxisCount]; ///< Joysticks position on each axis
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_INPUT_HPP
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \class sf::Input
|
||||
/// \ingroup window
|
||||
///
|
||||
/// sf::Input provides a way to access the state of keys,
|
||||
/// mouse buttons, mouse position, joystick buttons and
|
||||
/// jostick axis.
|
||||
///
|
||||
/// sf::Input provides the same informations as the event
|
||||
/// system, but these informations can be accessed at any time,
|
||||
/// which is more convenient in many situations.
|
||||
///
|
||||
/// For example, to move an entity you can decide to catch the
|
||||
/// sf::Event::KeyPressed event on arrow keys. But if you do so,
|
||||
/// you will only receive one event when the key gets pressed
|
||||
/// (or repeated events if you activated this feature), thus the
|
||||
/// entity will not move smoothly. The best solution here is to
|
||||
/// use sf::Input::IsKeyDown so that you can update your entity's
|
||||
/// position at every iteration of your game loop, not only when you
|
||||
/// catch a KeyPressed event.
|
||||
///
|
||||
/// Note that instances of sf::Input cannot be created directly,
|
||||
/// they must be retrieved from a window (sf::Window) with its
|
||||
/// GetInput() function.
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// // Retrieve the input object attached to our window
|
||||
/// const sf::Input& input = window.GetInput();
|
||||
///
|
||||
/// // Move an entity according to the current keys state
|
||||
/// float offset = 5.f * window.GetFrameTime(); // 5 pixels/sec
|
||||
/// if (input.IsKeyDown(sf::Key::Left)) entity.Move(-offset, 0);
|
||||
/// if (input.IsKeyDown(sf::Key::Right)) entity.Move( offset, 0);
|
||||
/// if (input.IsKeyDown(sf::Key::Up)) entity.Move(0, -offset);
|
||||
/// if (input.IsKeyDown(sf::Key::Down)) entity.Move(0, offset);
|
||||
/// \endcode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
203
include/SFML/Window/Joystick.hpp
Normal file
203
include/SFML/Window/Joystick.hpp
Normal file
|
@ -0,0 +1,203 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_JOYSTICK_HPP
|
||||
#define SFML_JOYSTICK_HPP
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Config.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Give access to the real-time state of the joysticks
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API Joystick
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Constants related to joysticks capabilities
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum
|
||||
{
|
||||
Count = 8, ///< Maximum number of supported joysticks
|
||||
ButtonCount = 32, ///< Maximum number of supported buttons
|
||||
AxisCount = 8 ///< Maximum number of supported axes
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Axes supported by SFML joysticks
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Axis
|
||||
{
|
||||
X, ///< The X axis
|
||||
Y, ///< The Y axis
|
||||
Z, ///< The Z axis
|
||||
R, ///< The R axis
|
||||
U, ///< The U axis
|
||||
V, ///< The V axis
|
||||
PovX, ///< The X axis of the point-of-view hat
|
||||
PovY ///< The Y axis of the point-of-view hat
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \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, 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 Update the states of all joysticks
|
||||
///
|
||||
/// This function is used internally by SFML, so you normally
|
||||
/// don't have to call it explicitely. However, you may need to
|
||||
/// call it if you have no window yet (or no window at all):
|
||||
/// in this case the joysticks states are not updated automatically.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void Update();
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_JOYSTICK_HPP
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \class sf::Joystick
|
||||
/// \ingroup window
|
||||
///
|
||||
/// sf::Joystick provides an interface to the state of the
|
||||
/// joysticks. It only contains static functions, so it's not
|
||||
/// meant to be instanciated. Instead, each joystick is identified
|
||||
/// by an index that is passed to the functions of this class.
|
||||
///
|
||||
/// This class allows users to query the state of joysticks at any
|
||||
/// time and directly, without having to deal with a window and
|
||||
/// its events. Compared to the JoystickMoved, JoystickButtonPressed
|
||||
/// and JoystickButtonReleased events, sf::Joystick can retrieve the
|
||||
/// state of axes and buttons of joysticks at any time
|
||||
/// (you don't need to store and update a boolean on your side
|
||||
/// in order to know if a button is pressed or released), and you
|
||||
/// always get the real state of joysticks, even if they are
|
||||
/// moved, pressed or released when your window is out of focus
|
||||
/// and no event is triggered.
|
||||
///
|
||||
/// SFML supports:
|
||||
/// \li 8 joysticks (sf::Joystick::Count)
|
||||
/// \li 32 buttons per joystick (sf::Joystick::ButtonCount)
|
||||
/// \li 8 axes per joystick (sf::Joystick::AxisCount)
|
||||
///
|
||||
/// Unlike the keyboard or mouse, the state of joysticks is sometimes
|
||||
/// not directly available (depending on the OS), therefore an Update()
|
||||
/// function must be called in order to update the current state of
|
||||
/// joysticks. When you have a window with event handling, this is done
|
||||
/// automatically, you don't need to call anything. But if you have no
|
||||
/// window, or if you want to check joysticks state before creating one,
|
||||
/// you must call sf::Joystick::Update explicitely.
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// // Is joystick #0 connected?
|
||||
/// bool connected = sf::Joystick::IsConnected(0);
|
||||
///
|
||||
/// // How many buttons does joystick #0 support?
|
||||
/// unsigned int buttons = sf::Joystick::GetButtonCount(0);
|
||||
///
|
||||
/// // Does joystick #0 define a X axis?
|
||||
/// bool hasX = sf::Joystick::HasAxis(0, sf::Joystick::X);
|
||||
///
|
||||
/// // Is button #2 pressed on joystick #0?
|
||||
/// bool pressed = sf::Joystick::IsButtonPressed(0, 2);
|
||||
///
|
||||
/// // What's the current position of the Y axis on joystick #0?
|
||||
/// float position = sf::Joystick::GetAxisPosition(0, sf::Joystick::Y);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Keyboard, sf::Mouse
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
208
include/SFML/Window/Keyboard.hpp
Normal file
208
include/SFML/Window/Keyboard.hpp
Normal file
|
@ -0,0 +1,208 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_KEYBOARD_HPP
|
||||
#define SFML_KEYBOARD_HPP
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Config.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Give access to the real-time state of the keyboard
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API Keyboard
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Key codes
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Key
|
||||
{
|
||||
A, ///< The A key
|
||||
B, ///< The B key
|
||||
C, ///< The C key
|
||||
D, ///< The D key
|
||||
E, ///< The E key
|
||||
F, ///< The F key
|
||||
G, ///< The G key
|
||||
H, ///< The H key
|
||||
I, ///< The I key
|
||||
J, ///< The J key
|
||||
K, ///< The K key
|
||||
L, ///< The L key
|
||||
M, ///< The M key
|
||||
N, ///< The N key
|
||||
O, ///< The O key
|
||||
P, ///< The P key
|
||||
Q, ///< The Q key
|
||||
R, ///< The R key
|
||||
S, ///< The S key
|
||||
T, ///< The T key
|
||||
U, ///< The U key
|
||||
V, ///< The V key
|
||||
W, ///< The W key
|
||||
X, ///< The X key
|
||||
Y, ///< The Y key
|
||||
Z, ///< The Z key
|
||||
Num0, ///< The 0 key
|
||||
Num1, ///< The 1 key
|
||||
Num2, ///< The 2 key
|
||||
Num3, ///< The 3 key
|
||||
Num4, ///< The 4 key
|
||||
Num5, ///< The 5 key
|
||||
Num6, ///< The 6 key
|
||||
Num7, ///< The 7 key
|
||||
Num8, ///< The 8 key
|
||||
Num9, ///< The 9 key
|
||||
Escape, ///< The Escape key
|
||||
LControl, ///< The left Control key
|
||||
LShift, ///< The left Shift key
|
||||
LAlt, ///< The left Alt key
|
||||
LSystem, ///< The left OS specific key: window (Windows and Linux), apple (MacOS X), ...
|
||||
RControl, ///< The right Control key
|
||||
RShift, ///< The right Shift key
|
||||
RAlt, ///< The right Alt key
|
||||
RSystem, ///< The right OS specific key: window (Windows and Linux), apple (MacOS X), ...
|
||||
Menu, ///< The Menu key
|
||||
LBracket, ///< The [ key
|
||||
RBracket, ///< The ] key
|
||||
SemiColon, ///< The ; key
|
||||
Comma, ///< The , key
|
||||
Period, ///< The . key
|
||||
Quote, ///< The ' key
|
||||
Slash, ///< The / key
|
||||
BackSlash, ///< The \ key
|
||||
Tilde, ///< The ~ key
|
||||
Equal, ///< The = key
|
||||
Dash, ///< The - key
|
||||
Space, ///< The Space key
|
||||
Return, ///< The Return key
|
||||
Back, ///< The Backspace key
|
||||
Tab, ///< The Tabulation key
|
||||
PageUp, ///< The Page up key
|
||||
PageDown, ///< The Page down key
|
||||
End, ///< The End key
|
||||
Home, ///< The Home key
|
||||
Insert, ///< The Insert key
|
||||
Delete, ///< The Delete key
|
||||
Add, ///< +
|
||||
Subtract, ///< -
|
||||
Multiply, ///< *
|
||||
Divide, ///< /
|
||||
Left, ///< Left arrow
|
||||
Right, ///< Right arrow
|
||||
Up, ///< Up arrow
|
||||
Down, ///< Down arrow
|
||||
Numpad0, ///< The numpad 0 key
|
||||
Numpad1, ///< The numpad 1 key
|
||||
Numpad2, ///< The numpad 2 key
|
||||
Numpad3, ///< The numpad 3 key
|
||||
Numpad4, ///< The numpad 4 key
|
||||
Numpad5, ///< The numpad 5 key
|
||||
Numpad6, ///< The numpad 6 key
|
||||
Numpad7, ///< The numpad 7 key
|
||||
Numpad8, ///< The numpad 8 key
|
||||
Numpad9, ///< The numpad 9 key
|
||||
F1, ///< The F1 key
|
||||
F2, ///< The F2 key
|
||||
F3, ///< The F3 key
|
||||
F4, ///< The F4 key
|
||||
F5, ///< The F5 key
|
||||
F6, ///< The F6 key
|
||||
F7, ///< The F7 key
|
||||
F8, ///< The F8 key
|
||||
F9, ///< The F8 key
|
||||
F10, ///< The F10 key
|
||||
F11, ///< The F11 key
|
||||
F12, ///< The F12 key
|
||||
F13, ///< The F13 key
|
||||
F14, ///< The F14 key
|
||||
F15, ///< The F15 key
|
||||
Pause, ///< The Pause key
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_KEYBOARD_HPP
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \class sf::Keyboard
|
||||
/// \ingroup window
|
||||
///
|
||||
/// sf::Keyboard provides an interface to the state of the
|
||||
/// keyboard. It only contains static functions (a single
|
||||
/// keyboard is assumed), so it's not meant to be instanciated.
|
||||
///
|
||||
/// This class allows users to query the keyboard state at any
|
||||
/// time and directly, without having to deal with a window and
|
||||
/// its events. Compared to the KeyPressed and KeyReleased events,
|
||||
/// sf::Keyboard can retrieve the state of a key at any time
|
||||
/// (you don't need to store and update a boolean on your side
|
||||
/// in order to know if a key is pressed or released), and you
|
||||
/// always get the real state of the keyboard, even if keys are
|
||||
/// pressed or released when your window is out of focus and no
|
||||
/// event is triggered.
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Left))
|
||||
/// {
|
||||
/// // move left...
|
||||
/// }
|
||||
/// else if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Right))
|
||||
/// {
|
||||
/// // move right...
|
||||
/// }
|
||||
/// else if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Escape))
|
||||
/// {
|
||||
/// // quit...
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Joystick, sf::Mouse
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
131
include/SFML/Window/Mouse.hpp
Normal file
131
include/SFML/Window/Mouse.hpp
Normal file
|
@ -0,0 +1,131 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_MOUSE_HPP
|
||||
#define SFML_MOUSE_HPP
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Config.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Give access to the real-time state of the mouse
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API Mouse
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Mouse buttons
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Button
|
||||
{
|
||||
Left, ///< The left mouse button
|
||||
Right, ///< The right mouse button
|
||||
Middle, ///< The middle (wheel) mouse button
|
||||
XButton1, ///< The first extra mouse button
|
||||
XButton2, ///< The second extra mouse button
|
||||
|
||||
ButtonCount ///< Keep last -- the total number of mouse buttons
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if a mouse button is pressed
|
||||
///
|
||||
/// \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
|
||||
///
|
||||
/// This function returns the current position of the mouse
|
||||
/// cursor.
|
||||
/// If the cursor is over a SFML window, the returned position
|
||||
/// is relative to this window. Otherwise, the returned position
|
||||
/// is in desktop coordinates.
|
||||
///
|
||||
/// \return Current position of the mouse
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Vector2i GetPosition();
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_MOUSE_HPP
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \class sf::Mouse
|
||||
/// \ingroup window
|
||||
///
|
||||
/// sf::Mouse provides an interface to the state of the
|
||||
/// mouse. It only contains static functions (a single
|
||||
/// mouse is assumed), so it's not meant to be instanciated.
|
||||
///
|
||||
/// This class allows users to query the mouse state at any
|
||||
/// time and directly, without having to deal with a window and
|
||||
/// its events. Compared to the MouseMoved, MouseButtonPressed
|
||||
/// and MouseButtonReleased events, sf::Mouse can retrieve the
|
||||
/// state of the cursor and the buttons at any time
|
||||
/// (you don't need to store and update a boolean on your side
|
||||
/// in order to know if a button is pressed or released), and you
|
||||
/// always get the real state of the mouse, even if it is
|
||||
/// moved, pressed or released when your window is out of focus
|
||||
/// and no event is triggered.
|
||||
///
|
||||
/// Note that the sf::Mouse::GetPosition function has a special
|
||||
/// behaviour: it returns the cursor position relative to the
|
||||
/// window which has the mouse focus (ie. the window on which
|
||||
/// the cursor is).
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// if (sf::Mouse::IsButtonPressed(sf::Mouse::Left))
|
||||
/// {
|
||||
/// // left click...
|
||||
/// }
|
||||
/// else if (sf::Mouse::IsButtonPressed(sf::Mouse::Right))
|
||||
/// {
|
||||
/// // right click...
|
||||
/// }
|
||||
///
|
||||
/// sf::Vector2i position = sf::Mouse::GetPosition();
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Joystick, sf::Keyboard
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
|
@ -29,12 +29,12 @@
|
|||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window/ContextSettings.hpp>
|
||||
#include <SFML/Window/Input.hpp>
|
||||
#include <SFML/Window/VideoMode.hpp>
|
||||
#include <SFML/Window/WindowHandle.hpp>
|
||||
#include <SFML/Window/WindowStyle.hpp>
|
||||
#include <SFML/Window/GlResource.hpp>
|
||||
#include <SFML/System/Clock.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <SFML/System/NonCopyable.hpp>
|
||||
#include <string>
|
||||
|
||||
|
@ -287,6 +287,14 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
void SetCursorPosition(unsigned int x, unsigned int y);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the position of the mouse cursor
|
||||
///
|
||||
/// \return Current mouse cursor position, relative to the window
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2i GetCursorPosition() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the position of the window on screen
|
||||
///
|
||||
|
@ -384,17 +392,6 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
void Display();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the input manager attached the window
|
||||
///
|
||||
/// This input gives access to the real-time state of
|
||||
/// keyboard, mouse and joysticks for this window.
|
||||
///
|
||||
/// \return Read-only reference to the input manager
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Input& GetInput() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Limit the framerate to a maximum fixed frequency
|
||||
///
|
||||
|
@ -447,6 +444,16 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
WindowHandle GetSystemHandle() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the window which is under the mouse cursor
|
||||
///
|
||||
/// This function is for internal use.
|
||||
///
|
||||
/// \return Pointer to the mouse focus window (NULL if not)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static const Window* GetMouseFocusWindow();
|
||||
|
||||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -493,7 +500,6 @@ private :
|
|||
////////////////////////////////////////////////////////////
|
||||
priv::WindowImpl* myWindow; ///< Platform-specific implementation of the window
|
||||
priv::GlContext* myContext; ///< Platform-specific implementation of the OpenGL context
|
||||
Input myInput; ///< Input manager connected to window
|
||||
Clock myClock; ///< Clock for measuring the elapsed time between frames
|
||||
Uint32 myLastFrameTime; ///< Time elapsed since last frame
|
||||
unsigned int myFramerateLimit; ///< Current framerate limit
|
||||
|
@ -523,8 +529,7 @@ private :
|
|||
/// The sf::Window class provides a simple interface for manipulating
|
||||
/// the window: move, resize, show/hide, control mouse cursor, etc.
|
||||
/// It also provides event handling through its PollEvent() and WaitEvent()
|
||||
/// functions, and real-time state handling with its attached sf::Input
|
||||
/// object (see GetInput()).
|
||||
/// functions.
|
||||
///
|
||||
/// Note that OpenGL experts can pass their own parameters (antialiasing
|
||||
/// level, bits for the depth and stencil buffers, etc.) to the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue