You.i Engine
YiGamePad.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_GAME_PAD_H_
3 #define _YI_GAME_PAD_H_
4 
10 #include "YiGamePadButton.h"
12 
13 #include <glm/vec2.hpp>
14 
15 /*
16  \brief Contains state data about all buttons and axis on a standard gamepad.
17 
18  \details This class represents a standard gamepad. It contains the current state information for the buttons and axis on the gamepad.
19 
20  \sa CYIGamePadButton
21 */
23 {
24 friend class CYIGamePadPriv;
25 
26 public:
27  /*
28  \details Returns the current gamepad instance.
29  */
30  static const CYIGamePad &GetUserGamePad();
31 
32  /*
33  \details Returns a button representing the state of the left directional pad button of the gamepad.
34  */
35  const CYIGamePadButton &GetDPadLeftButton() const;
36 
37  /*
38  \details Returns a button representing the state of the right directional pad button of the gamepad.
39  */
40  const CYIGamePadButton &GetDPadRightButton() const;
41 
42  /*
43  \details Returns a button representing the state of the up directional pad button of the gamepad.
44  */
45  const CYIGamePadButton &GetDPadUpButton() const;
46 
47  /*
48  \details Returns a button representing the state of the down directional pad button of the gamepad.
49  */
50  const CYIGamePadButton &GetDPadDownButton() const;
51 
52  /*
53  \details Returns a button representing the state of button 0 of the gamepad.
54 
55  \note On Playstation consoles this is the Cross button and on Xbox consoles this is the A button.
56  */
57  const CYIGamePadButton &GetButton0() const;
58 
59  /*
60  \details Returns a button representing the state of button 1 of the gamepad.
61 
62  \note On Playstation consoles this is the Circle button and on Xbox consoles this is the B button.
63  */
64  const CYIGamePadButton &GetButton1() const;
65 
66  /*
67  \details Returns a button representing the state of button 2 of the gamepad.
68 
69  \note On Playstation consoles this is the Square button and on Xbox consoles this is the X button.
70  */
71  const CYIGamePadButton &GetButton2() const; // XB: X, PS: Square
72 
73  /*
74  \details Returns a button representing the state of button 3 of the gamepad.
75 
76  \note On Playstation consoles this is the Triangle button and on Xbox consoles this is the Y button.
77  */
78  const CYIGamePadButton &GetButton3() const;
79 
80  /*
81  \details Returns a button representing the state of the select button of the gamepad.
82  */
83  const CYIGamePadButton &GetSelectButton() const;
84 
85  /*
86  \details Returns a button representing the state of the start button of the gamepad.
87  */
88  const CYIGamePadButton &GetStartButton() const;
89 
90  /*
91  \details Returns a button representing the state of the left thumb stick button of the gamepad.
92 
93  \note This is the button accessed by pressing down on the left thumb stick. On Playstation consoles this is also known as L3.
94  */
96 
97  /*
98  \details Returns a button representing the state of the right thumb stick button of the gamepad.
99 
100  \note This is the button accessed by pressing down on the right thumb stick. On Playstation consoles this is also known as R3.
101  */
103 
104  /*
105  \details Returns a button representing the state of the left bumper button of the gamepad.
106 
107  \note On Playstation consoles this is also known as L1.
108  */
109  const CYIGamePadButton &GetLeftBumperButton() const;
110 
111  /*
112  \details Returns a button representing the state of the left bumper button of the gamepad.
113 
114  \note On Playstation consoles this is also known as R1.
115  */
116  const CYIGamePadButton &GetRightBumperButton() const;
117 
118  /*
119  \details Returns a button representing the state of the left trigger button of the gamepad.
120 
121  \note On Playstation consoles this is also known as L2.
122  */
123  const CYIGamePadButton &GetLeftTriggerButton() const;
124 
125  /*
126  \details Returns a button representing the state of the right trigger button of the gamepad.
127 
128  \note On Playstation consoles this is also known as R2.
129  */
131 
132  /*
133  \details Returns a button representing the state of the left direction of the left thumbstick. This is a digital representation of the analog directional stick.
134  */
136 
137  /*
138  \details Returns a button representing the state of the right direction of the left thumbstick. This is a digital representation of the analog directional stick.
139  */
140 
142  /*
143  \details Returns a button representing the state of the up direction of the left thumbstick. This is a digital representation of the analog directional stick.
144  */
146 
147  /*
148  \details Returns a button representing the state of the down direction of the left thumbstick. This is a digital representation of the analog directional stick.
149  */
151 
152  /*
153  \details Returns a button representing the state of the left direction of the right thumbstick. This is a digital representation of the analog directional stick.
154  */
156 
157  /*
158  \details Returns a button representing the state of the right direction of the right thumbstick. This is a digital representation of the analog directional stick.
159  */
161 
162  /*
163  \details Returns a button representing the state of the up direction of the right thumbstick. This is a digital representation of the analog directional stick.
164  */
166 
167  /*
168  \details Returns a button representing the state of the down direction of the right thumbstick. This is a digital representation of the analog directional stick.
169  */
171 
172  /*
173  \details Returns a set of extended buttons not found on a typical gamepad.
174 
175  \note If the current gamepad does not have extended buttons nullptr will be returned.
176  */
178 
179  /*
180  \details Returns the current analog x and y position of the left thumbstick.
181  */
182  const glm::vec2 &GetLeftThumbStickAxes() const;
183 
184  /*
185  \details Returns the current analog x and y position of the right thumbstick.
186  */
187  const glm::vec2 &GetRightThumbStickAxes() const;
188 
189  /*
190  \details Returns the current analog position of the left trigger.
191 
192  \note On Playstation consoles this is also known as L2.
193  */
194  float GetLeftTriggerAxis() const;
195 
196  /*
197  \details Returns the current analog position of the right trigger.
198 
199  \note On Playstation consoles this is also known as R2.
200  */
201  float GetRightTriggerAxis() const;
202 
203  /*
204  \details Returns true if auto repeat is enabled.
205 
206  \sa SetAutoRepeatEnabled
207  */
208  bool IsAutoRepeatEnabled() const;
209 
210  /*
211  \details Enabled the auto-repeat feature if \a bEnabled is true. Auto-repeat will repeat directional input while a directional button/stick is held down.
212  */
213  void SetAutoRepeatEnabled(bool bEnabled);
214 
215 private:
216  CYIGamePad();
217  ~CYIGamePad();
218 
219  CYIGamePadButton m_dPadLeftButton;
220  CYIGamePadButton m_dPadRightButton;
221  CYIGamePadButton m_dPadUpButton;
222  CYIGamePadButton m_dPadDownButton;
223  CYIGamePadButton m_button0;
224  CYIGamePadButton m_button1;
225  CYIGamePadButton m_button2;
226  CYIGamePadButton m_button3;
227  CYIGamePadButton m_selectButton;
228  CYIGamePadButton m_startButton;
229  CYIGamePadButton m_leftThumbStickButton;
230  CYIGamePadButton m_rightThumbStickButton;
231  CYIGamePadButton m_leftBumperButton;
232  CYIGamePadButton m_rightBumperButton;
233 
234  CYIGamePadButton m_leftTriggerButton;
235  CYIGamePadButton m_rightTriggerButton;
236  CYIGamePadButton m_leftThumbStickLeftButton;
237  CYIGamePadButton m_leftThumbStickRightButton;
238  CYIGamePadButton m_leftThumbStickUpButton;
239  CYIGamePadButton m_leftThumbStickDownButton;
240  CYIGamePadButton m_rightThumbStickLeftButton;
241  CYIGamePadButton m_rightThumbStickRightButton;
242  CYIGamePadButton m_rightThumbStickUpButton;
243  CYIGamePadButton m_rightThumbStickDownButton;
244 
245  CYIGamePadExtendedButtons *m_pExtendedButtons;
246 
247  glm::vec2 m_leftThumbStickAxes;
248  glm::vec2 m_rightThumbStickAxes;
249  float m_leftTriggerAxis;
250  float m_rightTriggerAxis;
251 
252  bool m_bAutoRepeat;
253 };
254 
259 #endif // _YI_GAME_PAD_H_
const CYIGamePadButton & GetDPadLeftButton() const
static const CYIGamePad & GetUserGamePad()
const CYIGamePadButton & GetLeftThumbStickButton() const
const CYIGamePadButton & GetStartButton() const
const CYIGamePadButton & GetRightThumbStickButton() const
const CYIGamePadButton & GetLeftThumbStickUpButton() const
const glm::vec2 & GetLeftThumbStickAxes() const
const CYIGamePadButton & GetButton1() const
const CYIGamePadButton & GetLeftTriggerButton() const
const CYIGamePadButton & GetRightBumperButton() const
Definition: YiGamePadExtendedButtons.h:20
float GetLeftTriggerAxis() const
const CYIGamePadButton & GetLeftBumperButton() const
friend class CYIGamePadPriv
Definition: YiGamePad.h:24
const CYIGamePadButton & GetDPadRightButton() const
const CYIGamePadButton & GetButton0() const
const glm::vec2 & GetRightThumbStickAxes() const
float GetRightTriggerAxis() const
Definition: YiGamePad.h:22
const CYIGamePadButton & GetRightThumbStickLeftButton() const
const CYIGamePadButton & GetSelectButton() const
const CYIGamePadButton & GetRightThumbStickUpButton() const
Definition: YiGamePadButton.h:17
const CYIGamePadButton & GetLeftThumbStickLeftButton() const
const CYIGamePadButton & GetLeftThumbStickDownButton() const
const CYIGamePadButton & GetRightThumbStickRightButton() const
const CYIGamePadButton & GetDPadUpButton() const
const CYIGamePadButton & GetRightThumbStickDownButton() const
const CYIGamePadButton & GetButton3() const
const CYIGamePadButton & GetButton2() const
void SetAutoRepeatEnabled(bool bEnabled)
const CYIGamePadExtendedButtons * GetExtendedButtons() const
const CYIGamePadButton & GetDPadDownButton() const
bool IsAutoRepeatEnabled() const
const CYIGamePadButton & GetLeftThumbStickRightButton() const
const CYIGamePadButton & GetRightTriggerButton() const