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
44 class InputContext
45 {
48
49 public:
51 InputContext();
52
53 ~InputContext();
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
108 void process_messages();
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
clan::InputContext::add_mouse
void add_mouse(const InputDevice mouse)
Adds a new mouse to the input context.
clan
Definition: clanapp.h:35
clan::InputContext::InputContext
InputContext()
Constructs an input context.
clan::InputContext::get_keyboard
InputDevice & get_keyboard(int keyboard=0)
Returns the input device for the specified keyboard.
clan::InputContext::get_keyboard_count
int get_keyboard_count() const
Returns the number of keyboards available.
clan::InputContext::is_disposed
bool is_disposed() const
Has dispose() been called on this input context.
clan::InputContext::get_mouse_count
int get_mouse_count() const
Returns the number of mice available.
clan::InputContext::add_keyboard
void add_keyboard(const InputDevice keyboard)
Adds a new keyboard to the input context.
clan::InputContext::clear
void clear()
Removes all devices from this input context.
clan::InputContext::get_device
InputDevice & get_device(const std::string &device_name)
Returns the input device with the given devicename.
clan::InputDevice
InputDevice.
Definition: input_device.h:47
clan::InputContext::get_tablet_count
int get_tablet_count() const
Returns the number of tablets available.
clan::InputContext::dispose
void dispose()
Stop anyone accessing this input context.
clan::StyleTokenType::string
@ keyword
clan::InputContext::process_messages
void process_messages()
Process and dispatch messages to signals.
clan::InputContext::add_joystick
void add_joystick(const InputDevice joystick)
Adds a new joystick to the input context.
clan::InputContext::add_tablet
void add_tablet(const InputDevice tablet)
Adds a new tablet to the input context.
clan::InputContext::get_joystick
InputDevice & get_joystick(int joystick=0)
Returns the input device for the specified joystick.
clan::InputContext::get_joystick_count
int get_joystick_count() const
Returns the number of joysticks available.
clan::InputContext::~InputContext
~InputContext()
clan::InputContext
InputContext.
Definition: input_context.h:44
clan::InputContext::get_tablet
InputDevice & get_tablet(int tablet=0)
Returns the input device for the specified tablet.
clan::InputContext::get_mouse
InputDevice & get_mouse(int mouse=0)
Returns the input device for the specified mouse.