input_context.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 The ClanLib Team
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 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 ** Harry Storbacka
28 */
29 
30 
31 #pragma once
32 
33 #include <memory>
34 
35 namespace clan
36 {
39 
40 class InputDevice;
41 class InputContext_Impl;
42 
45 {
48 
49 public:
52 
54 
58 
59 public:
61  int get_keyboard_count() const;
62 
64  int get_mouse_count() const;
65 
67  int get_joystick_count() const;
68 
70  int get_tablet_count() const;
71 
73  InputDevice &get_keyboard(int keyboard = 0);
74 
76  InputDevice &get_mouse(int mouse = 0);
77 
79  InputDevice &get_joystick(int joystick = 0);
80 
82  InputDevice &get_tablet(int tablet = 0);
83 
85  InputDevice &get_device(const std::string &device_name);
86 
90 
91 public:
93  void clear();
94 
96  void add_keyboard(const InputDevice keyboard);
97 
99  void add_mouse(const InputDevice mouse);
100 
102  void add_joystick(const InputDevice joystick);
103 
105  void add_tablet(const InputDevice tablet);
106 
109 
113  void dispose();
114 
118  bool is_disposed() const;
119 
123 
124 private:
125  std::shared_ptr<InputContext_Impl> impl;
126 
128 };
129 
130 }
131 
void process_messages()
Process and dispatch messages to signals.
void add_joystick(const InputDevice joystick)
Adds a new joystick to the input context.
void add_mouse(const InputDevice mouse)
Adds a new mouse to the input context.
void add_tablet(const InputDevice tablet)
Adds a new tablet to the input context.
InputDevice.
Definition: input_device.h:48
void dispose()
Stop anyone accessing this input context.
int get_keyboard_count() const
Returns the number of keyboards available.
InputDevice & get_tablet(int tablet=0)
Returns the input device for the specified tablet.
InputDevice & get_mouse(int mouse=0)
Returns the input device for the specified mouse.
InputContext.
Definition: input_context.h:45
int get_joystick_count() const
Returns the number of joysticks available.
int get_mouse_count() const
Returns the number of mice available.
void clear()
Removes all devices from this input context.
int get_tablet_count() const
Returns the number of tablets available.
Definition: clanapp.h:36
InputDevice & get_joystick(int joystick=0)
Returns the input device for the specified joystick.
InputContext()
Constructs an input context.
InputDevice & get_keyboard(int keyboard=0)
Returns the input device for the specified keyboard.
bool is_disposed() const
Has dispose() been called on this input context.
void add_keyboard(const InputDevice keyboard)
Adds a new keyboard to the input context.
InputDevice & get_device(const std::string &device_name)
Returns the input device with the given devicename.