Gamedev Framework (gf)  0.7.0
A C++14 framework for 2D games
Gamepad.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2018 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_GAMEPAD_H
22 #define GF_GAMEPAD_H
23 
24 #include <cstdint>
25 
26 #include "Portability.h"
27 
28 namespace gf {
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 inline namespace v1 {
31 #endif
32 
42  enum class GamepadButton {
43  Invalid,
44  A,
45  B,
46  X,
47  Y,
48  Back,
49  Guide,
50  Start,
51  LeftStick,
52  RightStick,
53  LeftBumper,
54  RightBumper,
55  DPadUp,
56  DPadDown,
57  DPadLeft,
58  DPadRight,
59  };
60 
70  enum class GamepadAxis {
71  Invalid,
72  LeftX,
73  LeftY,
74  RightX,
75  RightY,
76  TriggerLeft,
77  TriggerRight,
78  };
79 
88  enum class GamepadAxisDirection {
89  Positive,
90  Negative,
91  };
92 
93 
103  enum class GamepadHwId : int
104  #ifdef DOXYGEN_SHOULD_SKIP_THIS
105  {
106  }
107  #endif
108  ;
109 
120  enum class GamepadId : int32_t
121  #ifdef DOXYGEN_SHOULD_SKIP_THIS
122  {
123  }
124  #endif
125  ;
126 
131  class GF_API Gamepad {
132  public:
139  static const char *getAxisName(GamepadAxis axis);
140 
147  static const char *getButtonName(GamepadButton button);
148 
172  static GamepadId open(GamepadHwId hwid);
173 
180  static bool isAttached(GamepadId id);
181 
198  static void close(GamepadId id);
199 
206  static const char *getName(GamepadId id);
207 
213  static void initialize();
214 
218  Gamepad() = delete;
219  };
220 
221 #ifndef DOXYGEN_SHOULD_SKIP_THIS
222 }
223 #endif
224 }
225 
226 #endif // GF_GAMEPAD_H
GamepadAxisDirection
A gamepad axis direction.
Definition: Gamepad.h:88
GamepadButton
The gamepad buttons.
Definition: Gamepad.h:42
The Guide button.
The right bumper button.
The left stick Y axis.
Some gamepad related functions.
Definition: Gamepad.h:131
The left trigger axis.
The right trigger axis.
The B button.
The left stick button.
The left bumper button.
GamepadHwId
A gamepad hardware identifier.
Definition: Gamepad.h:103
The Start button.
The right stick button.
GamepadAxis
The gamepad axis.
Definition: Gamepad.h:70
The Y button.
Negative direction of the axis.
The namespace for gf classes.
Definition: Action.h:34
The left stick X axis.
GamepadId
A gamepad identifier.
Definition: Gamepad.h:120
The directional pad right button.
The X button.
The directional pad up button.
The right stick X axis.
Positive direction of the axis.
The directional pad left button.
The Back button.
The A button.
The directional pad down button.
The right stick Y axis.