]> git.sesse.net Git - casparcg/blob - SFML-1.6/include/SFML/Window/Input.hpp
(no commit message)
[casparcg] / SFML-1.6 / include / SFML / Window / Input.hpp
1 ////////////////////////////////////////////////////////////\r
2 //\r
3 // SFML - Simple and Fast Multimedia Library\r
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\r
5 //\r
6 // This software is provided 'as-is', without any express or implied warranty.\r
7 // In no event will the authors be held liable for any damages arising from the use of this software.\r
8 //\r
9 // Permission is granted to anyone to use this software for any purpose,\r
10 // including commercial applications, and to alter it and redistribute it freely,\r
11 // subject to the following restrictions:\r
12 //\r
13 // 1. The origin of this software must not be misrepresented;\r
14 //    you must not claim that you wrote the original software.\r
15 //    If you use this software in a product, an acknowledgment\r
16 //    in the product documentation would be appreciated but is not required.\r
17 //\r
18 // 2. Altered source versions must be plainly marked as such,\r
19 //    and must not be misrepresented as being the original software.\r
20 //\r
21 // 3. This notice may not be removed or altered from any source distribution.\r
22 //\r
23 ////////////////////////////////////////////////////////////\r
24 \r
25 #ifndef SFML_INPUT_HPP\r
26 #define SFML_INPUT_HPP\r
27 \r
28 ////////////////////////////////////////////////////////////\r
29 // Headers\r
30 ////////////////////////////////////////////////////////////\r
31 #include <SFML/Config.hpp>\r
32 #include <SFML/System/NonCopyable.hpp>\r
33 #include <SFML/Window/Event.hpp>\r
34 #include <SFML/Window/WindowListener.hpp>\r
35 \r
36 \r
37 namespace sf\r
38 {\r
39 ////////////////////////////////////////////////////////////\r
40 /// Input handles real-time input from keyboard and mouse.\r
41 /// Use it instead of events to handle continuous moves and more\r
42 /// game-friendly inputs\r
43 ////////////////////////////////////////////////////////////\r
44 class SFML_API Input : public WindowListener, NonCopyable\r
45 {\r
46 public :\r
47 \r
48     ////////////////////////////////////////////////////////////\r
49     /// Default constructor\r
50     ///\r
51     ////////////////////////////////////////////////////////////\r
52     Input();\r
53 \r
54     ////////////////////////////////////////////////////////////\r
55     /// Get the state of a key\r
56     ///\r
57     /// \param KeyCode : Key to check\r
58     ///\r
59     /// \return True if key is down, false if key is up\r
60     ///\r
61     ////////////////////////////////////////////////////////////\r
62     bool IsKeyDown(Key::Code KeyCode) const;\r
63 \r
64     ////////////////////////////////////////////////////////////\r
65     /// Get the state of a mouse button\r
66     ///\r
67     /// \param Button : Button to check\r
68     ///\r
69     /// \return True if button is down, false if button is up\r
70     ///\r
71     ////////////////////////////////////////////////////////////\r
72     bool IsMouseButtonDown(Mouse::Button Button) const;\r
73 \r
74     ////////////////////////////////////////////////////////////\r
75     /// Get the state of a joystick button\r
76     ///\r
77     /// \param JoyId :  Identifier of the joystick to check (0 or 1)\r
78     /// \param Button : Button to check\r
79     ///\r
80     /// \return True if button is down, false if button is up\r
81     ///\r
82     ////////////////////////////////////////////////////////////\r
83     bool IsJoystickButtonDown(unsigned int JoyId, unsigned int Button) const;\r
84 \r
85     ////////////////////////////////////////////////////////////\r
86     /// Get the mouse X position\r
87     ///\r
88     /// \return Current mouse left position, relative to owner window\r
89     ///\r
90     ////////////////////////////////////////////////////////////\r
91     int GetMouseX() const;\r
92 \r
93     ////////////////////////////////////////////////////////////\r
94     /// Get the mouse Y position\r
95     ///\r
96     /// \return Current mouse top position, relative to owner window\r
97     ///\r
98     ////////////////////////////////////////////////////////////\r
99     int GetMouseY() const;\r
100 \r
101     ////////////////////////////////////////////////////////////\r
102     /// Get a joystick axis position\r
103     ///\r
104     /// \param JoyId : Identifier of the joystick to check (0 or 1)\r
105     /// \param Axis :  Axis to get\r
106     ///\r
107     /// \return Current axis position, in the range [-100, 100] (except for POV, which is [0, 360])\r
108     ///\r
109     ////////////////////////////////////////////////////////////\r
110     float GetJoystickAxis(unsigned int JoyId, Joy::Axis Axis) const;\r
111 \r
112 private :\r
113 \r
114     ////////////////////////////////////////////////////////////\r
115     /// /see WindowListener::OnEvent\r
116     ///\r
117     ////////////////////////////////////////////////////////////\r
118     virtual void OnEvent(const Event& EventReceived);\r
119 \r
120     ////////////////////////////////////////////////////////////\r
121     /// Reset all the states\r
122     ///\r
123     ////////////////////////////////////////////////////////////\r
124     void ResetStates();\r
125 \r
126     ////////////////////////////////////////////////////////////\r
127     // Member data\r
128     ////////////////////////////////////////////////////////////\r
129     bool  myKeys[Key::Count];                              ///< Array containing the state of all keyboard keys\r
130     bool  myMouseButtons[Mouse::ButtonCount];              ///< Array containing the state of all mouse buttons\r
131     int   myMouseX;                                        ///< Mouse position on X\r
132     int   myMouseY;                                        ///< Mouse position on Y\r
133     bool  myJoystickButtons[Joy::Count][Joy::ButtonCount]; ///< Array containing the state of all joysticks buttons\r
134     float myJoystickAxis[Joy::Count][Joy::AxisCount];      ///< Joysticks position on each axis\r
135 };\r
136 \r
137 } // namespace sf\r
138 \r
139 \r
140 #endif // SFML_INPUT_HPP\r