UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
manager.h
Go to the documentation of this file.
1 #ifndef UGDK_INPUT_MANAGER_H_
2 #define UGDK_INPUT_MANAGER_H_
3 
4 #include <ugdk/input/keyboard.h>
5 #include <ugdk/input/mouse.h>
6 #include <ugdk/input/joystick.h>
7 #include <ugdk/input/textinput.h>
8 #include <ugdk/structure/types.h>
9 #include <ugdk/system.h>
10 
11 #include <memory>
12 #include <unordered_map>
13 #include <forward_list>
14 
15 namespace ugdk {
16 namespace input {
17 
18 class Manager {
19  public:
20  Manager();
21  ~Manager();
22 
24 
26  bool Initialize();
27  void Release();
28 
30  const Keyboard& keyboard() const { return keyboard_; }
31 
33  const Mouse& mouse() const { return mouse_; }
34 
36  TextInput& text_input() { return text_input_; }
37 
39  std::forward_list<std::shared_ptr<Joystick>> CurrentJoysticks() const {
40  std::forward_list<std::shared_ptr<Joystick>> result;
41  for (const auto& it : joysticks_)
42  result.push_front(it.second);
43  return result;
44  }
45 
46  void Update();
47 
48  private:
49  std::shared_ptr<Joystick> CreateJoystick(int device);
50 
51  Keyboard keyboard_;
52  Mouse mouse_;
53  TextInput text_input_;
54  std::unordered_map<int32, std::shared_ptr<Joystick>> joysticks_;
55  std::unique_ptr<system::SDLEventHandler> event_handler_;
56 
57  friend class InputSDLEventHandler;
58 };
59 
60 } // namespace input
61 } // namespace ugdk
62 
63 #endif
Definition: mouse.h:13
Definition: textinput.h:12
friend class InputSDLEventHandler
Definition: manager.h:57
Definition: animation.h:11
const Keyboard & keyboard() const
A virtual keyboard that represents all physical keyboards.
Definition: manager.h:30
std::forward_list< std::shared_ptr< Joystick > > CurrentJoysticks() const
Returns a list with the current joysticks.
Definition: manager.h:39
Definition: manager.h:18
TextInput & text_input()
Handles the IME.
Definition: manager.h:36
bool Initialize()
Initializes input libraries.
Definition: keyboard.h:13
const Mouse & mouse() const
A virtual mouse that represents all physical mice.
Definition: manager.h:33