UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
joystick.h
Go to the documentation of this file.
1 #ifndef UGDK_INPUT_JOYSTICK_H_
2 #define UGDK_INPUT_JOYSTICK_H_
3 
4 #include <ugdk/system.h>
6 #include <ugdk/math/integer2D.h>
8 
9 #include <set>
10 #include <memory>
11 
12 struct _SDL_Joystick;
13 
14 namespace ugdk {
15 namespace input {
16 
17 class Joystick {
18  public:
19  ~Joystick();
20 
22  bool IsConnected() const;
23 
25  int NumAxes() const;
26 
28 
31  int NumTrackballs() const;
32 
34  int NumHats() const;
35 
37  int NumButtons() const;
38 
40  bool IsDown(int button) const;
41 
43  bool IsUp(int button) const;
44 
46  math::Integer2D GetBallDelta(int ballid) const;
47 
49  HatStatus GetHatStatus(int hat) const;
50 
52  AxisStatus GetAxisStatus(int axis) const;
53 
55  system::EventHandler& event_handler() { return event_handler_; }
56 
57  private:
58  Joystick(_SDL_Joystick*);
59 
60  _SDL_Joystick* sdljoystick_;
61  system::EventHandler event_handler_;
62 
63  friend class Manager;
64 };
65 
66 } // namespace input
67 } // namespace ugdk
68 
69 #endif // UGDK_INPUT_JOYSTICK_H_
HatStatus GetHatStatus(int hat) const
Get the current state of a POV hat.
bool IsConnected() const
Checks if the joystick is currently connected.
system::EventHandler & event_handler()
An event handler for events that matching this joystick.
Definition: joystick.h:55
int NumButtons() const
Get the number of buttons.
Definition: integer2D.h:20
Definition: joystickstatus.h:22
Definition: animation.h:11
bool IsDown(int button) const
Checks if the given button is currently being held.
int NumTrackballs() const
Get the number of trackballs.
Definition: joystick.h:17
Definition: eventhandler.h:40
int NumAxes() const
Get the number of general axis controls.
Definition: joystickstatus.h:9
Definition: manager.h:18
int NumHats() const
Get the number of POV hats.
bool IsUp(int button) const
Checks if there's currently no interaction with the given button.
math::Integer2D GetBallDelta(int ballid) const
Get the ball axis changes since last frame.
AxisStatus GetAxisStatus(int axis) const
Get the current state of an axis control.