Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_core
Basics
Input.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <string>
4
5
#include "
glm_alias.hpp
"
6
#include "
hash.hpp
"
7
#include "
StringIO_Table.hpp
"
8
9
namespace
iv
10
{
11
12
13
class
Input
14
{
15
public
:
16
enum class
Key
17
{
18
None
= 0,
19
20
Character
,
21
22
//---------------- KEYBOARD -------------------------
23
KEYBOARD_BEGIN
,
24
Space
=
KEYBOARD_BEGIN
,
25
Apostrophe
,
26
Comma
,
27
Minus
,
28
Period
,
29
Slash
,
30
Num_0
,
31
Num_1
,
32
Num_2
,
33
Num_3
,
34
Num_4
,
35
Num_5
,
36
Num_6
,
37
Num_7
,
38
Num_8
,
39
Num_9
,
40
Semicolon
,
41
Equal
,
42
Char_A
,
43
Char_B
,
44
Char_C
,
45
Char_D
,
46
Char_E
,
47
Char_F
,
48
Char_G
,
49
Char_H
,
50
Char_I
,
51
Char_J
,
52
Char_K
,
53
Char_L
,
54
Char_M
,
55
Char_N
,
56
Char_O
,
57
Char_P
,
58
Char_Q
,
59
Char_R
,
60
Char_S
,
61
Char_T
,
62
Char_U
,
63
Char_V
,
64
Char_W
,
65
Char_X
,
66
Char_Y
,
67
Char_Z
,
68
Left_Bracket
,
69
Backslash
,
70
Right_Bracket
,
71
Grave_Accent
,
72
World_1
,
73
World_2
,
74
Escape
,
75
Enter
,
76
Tab
,
77
Backspace
,
78
Insert
,
79
Delete
,
80
Right
,
81
Left
,
82
Down
,
83
Up
,
84
Page_Up
,
85
Page_Down
,
86
Home
,
87
End
,
88
Caps_Lock
,
89
Scroll_Lock
,
90
Num_Lock
,
91
Print_Screen
,
92
Pause
,
93
F1
,
94
F2
,
95
F3
,
96
F4
,
97
F5
,
98
F6
,
99
F7
,
100
F8
,
101
F9
,
102
F10
,
103
F11
,
104
F12
,
105
F13
,
106
F14
,
107
F15
,
108
F16
,
109
F17
,
110
F18
,
111
F19
,
112
F20
,
113
F21
,
114
F22
,
115
F23
,
116
F24
,
117
F25
,
118
KeyPad_0
,
119
KeyPad_1
,
120
KeyPad_2
,
121
KeyPad_3
,
122
KeyPad_4
,
123
KeyPad_5
,
124
KeyPad_6
,
125
KeyPad_7
,
126
KeyPad_8
,
127
KeyPad_9
,
128
KeyPad_Decimal
,
129
KeyPad_Divide
,
130
KeyPad_Multiply
,
131
KeyPad_Subtract
,
132
KeyPad_Add
,
133
KeyPad_Enter
,
134
KeyPad_Equal
,
135
Left_Shift
,
136
Left_Control
,
137
Left_Alt
,
138
Left_Super
,
139
Right_Shift
,
140
Right_Control
,
141
Right_Alt
,
142
Right_Super
,
143
Menu
,
144
145
KEYBOARD_END
,
146
147
//-------------- MOUSE ---------------------
148
MOUSE_BEGIN
,
149
150
Mouse
=
MOUSE_BEGIN
,
151
152
MouseLeft
,
153
MouseRight
,
154
MouseMiddle
,
155
MouseBack
,
156
MouseForward
,
157
158
MouseScrollUp
,
159
MouseScrollDown
,
160
MouseScrollLeft
,
161
MouseScrollRight
,
162
163
MOUSE_END
,
164
165
//-------------- TOUCH ---------------------
166
Touch
,
167
};
168
169
170
enum class
Type
171
{
172
Press
,
173
Release
,
174
Trigger
,
175
};
176
177
178
Input
(
Type
type
,
Input::Key
key
,
int
device_id
,
bool
real
) :
179
_type(
type
),
180
_key(
key
),
181
_device_id(
device_id
),
182
_real(
real
)
183
{
184
}
185
186
using
DeviceKey
= std::pair< Input::Key, int >;
187
using
DeviceKey_Hash
=
iv::hash< std::pair< Input::Key, int >
>;
188
189
Type
type
()
const
190
{
191
return
this->_type;
192
}
193
194
Input::Key
key
()
const
195
{
196
return
this->_key;
197
}
198
199
int
device_id
()
const
200
{
201
return
this->_device_id;
202
}
203
204
bool
real
()
const
205
{
206
return
this->_real;
207
}
208
209
private
:
210
Type
_type;
211
Input::Key
_key;
212
int
_device_id;
213
bool
_real;
214
};
215
216
217
class
InputSource
218
{
219
public
:
223
virtual
int2
input_position
(
Input::Key
key,
int
device_id ) = 0;
224
228
virtual
float
input_value
(
Input::Key
key,
int
device_id ) = 0;
229
233
virtual
unsigned
input_character
() = 0;
234
};
235
236
237
//----------------- StringIO ------------------------------
238
template
<>
239
struct
StringIO
<
Input
::Key > :
public
StringIO_Table
< Input::Key >
240
{
241
static
const
ValuesType
Values
;
242
};
243
244
template
<>
245
struct
StringIO
<
Input
::Type > :
public
StringIO_Table
< Input::Type >
246
{
247
static
const
ValuesType
Values
;
248
};
249
250
251
}