xoreos  0.0.5
joystick.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef EVENTS_JOYSTICK_H
26 #define EVENTS_JOYSTICK_H
27 
28 #include "src/common/fallthrough.h"
30 #include <SDL_joystick.h>
32 
33 #include <boost/noncopyable.hpp>
34 
35 #include "src/common/deallocator.h"
36 #include "src/common/ustring.h"
37 
38 namespace Events {
39 
40 class Joystick : boost::noncopyable {
41 public:
43  const Common::UString &getName() const;
44 
46  int getIndex() const;
47 
49  bool isEnabled() const;
50 
52  bool enable();
54  void disable();
55 
56  // Properties, only available when the joystick is enabled.
57 
59  int getAxisCount () const;
61  int getBallCount () const;
63  int getHatCount () const;
65  int getButtonCount() const;
66 
67 private:
68  int _index;
70  SDL_Joystick *_sdlJoy;
71 
72 
73  Joystick(int index);
74  ~Joystick();
75 
76  friend class EventsManager;
77 
78  template<typename T>
79  friend void Common::DeallocatorDefault::destroy(T *);
80 };
81 
82 } // End of namespace Events
83 
84 #endif // EVENTS_JOYSTICK_H
int getHatCount() const
Return the number of hats the joystick has.
Definition: joystick.cpp:83
#define START_IGNORE_IMPLICIT_FALLTHROUGH
Definition: fallthrough.h:79
int getButtonCount() const
Return the number of buttons the joystick has.
Definition: joystick.cpp:90
A class holding an UTF-8 string.
Definition: ustring.h:48
SDL_Joystick * _sdlJoy
Definition: joystick.h:70
bool enable()
Enable the joystick.
Definition: joystick.cpp:51
static void destroy(T *x)
Definition: deallocator.h:40
int getAxisCount() const
Return the number of axes the joystick has.
Definition: joystick.cpp:69
The events manager.
Definition: events.h:48
bool isEnabled() const
Is the joystick currently enabled?
Definition: joystick.cpp:47
Joystick(int index)
Definition: joystick.cpp:31
#define STOP_IGNORE_IMPLICIT_FALLTHROUGH
Definition: fallthrough.h:80
Unicode string handling.
Common::UString _name
Definition: joystick.h:69
Simple deallocator concept.
int getIndex() const
Return the joystick&#39;s index within the available joysticks.
Definition: joystick.cpp:39
Compiler-specific defines to mark an implicit switch-case fallthrough.
void disable()
Disable the joystick.
Definition: joystick.cpp:64
const Common::UString & getName() const
Return the joystick&#39;s name.
Definition: joystick.cpp:43
int getBallCount() const
Return the number of balls the joystick has.
Definition: joystick.cpp:76