Joystick.hpp
1 #ifndef CPP3DS_JOYSTICK_HPP
2 #define CPP3DS_JOYSTICK_HPP
3 
4 #include <cpp3ds/System/String.hpp>
5 
6 namespace cpp3ds {
11 class Joystick {
12 public :
13 
18  enum {
19  Count = 8,
20  ButtonCount = 32,
21  AxisCount = 8
22  };
23 
28  enum Axis {
29  X,
30  Y,
31  Z,
32  R,
33  U,
34  V,
35  PovX,
37  };
38 
43  struct Identification {
45 
47  unsigned int vendorId;
48  unsigned int productId;
49  };
50 
59  static bool isConnected(unsigned int joystick);
60 
71  static unsigned int getButtonCount(unsigned int joystick);
72 
84  static bool hasAxis(unsigned int joystick, Axis axis);
85 
97  static bool isButtonPressed(unsigned int joystick, unsigned int button);
98 
110  static float getAxisPosition(unsigned int joystick, Axis axis);
111 
120  static Identification getIdentification(unsigned int joystick);
121 
131  static void update();
132 };
133 
134 }
135 
136 
137 #endif
138 
139 
The Y axis.
Definition: Joystick.hpp:30
static Identification getIdentification(unsigned int joystick)
Get the joystick information.
Utility string class that automatically handles conversions between types and encodings.
Definition: String.hpp:42
static unsigned int getButtonCount(unsigned int joystick)
Return the number of buttons supported by a joystick.
Maximum number of supported axes.
Definition: Joystick.hpp:21
Structure holding a joystick's identification.
Definition: Joystick.hpp:43
cpp3ds::String name
Name of the joystick.
Definition: Joystick.hpp:46
static bool isButtonPressed(unsigned int joystick, unsigned int button)
Check if a joystick button is pressed.
The X axis.
Definition: Joystick.hpp:29
The R axis.
Definition: Joystick.hpp:32
static bool hasAxis(unsigned int joystick, Axis axis)
Check if a joystick supports a given axis.
Axis
Axes supported by SFML joysticks.
Definition: Joystick.hpp:28
static bool isConnected(unsigned int joystick)
Check if a joystick is connected.
Maximum number of supported buttons.
Definition: Joystick.hpp:20
The Z axis.
Definition: Joystick.hpp:31
Maximum number of supported joysticks.
Definition: Joystick.hpp:19
unsigned int productId
Product identifier.
Definition: Joystick.hpp:48
The U axis.
Definition: Joystick.hpp:33
The Y axis of the point-of-view hat.
Definition: Joystick.hpp:36
The V axis.
Definition: Joystick.hpp:34
static float getAxisPosition(unsigned int joystick, Axis axis)
Get the current position of a joystick axis.
unsigned int vendorId
Manufacturer identifier.
Definition: Joystick.hpp:47
Give access to the real-time state of the joysticks.
Definition: Joystick.hpp:11
The X axis of the point-of-view hat.
Definition: Joystick.hpp:35
static void update()
Update the states of all joysticks.