Gainput  v1.0.0
GainputInputDeviceKeyboard.h
1 
2 #ifndef GAINPUTINPUTDEVICEKEYBOARD_H_
3 #define GAINPUTINPUTDEVICEKEYBOARD_H_
4 
5 namespace gainput
6 {
7 
9 enum Key
10 {
11  KeyEscape,
12  KeyF1,
13  KeyF2,
14  KeyF3,
15  KeyF4,
16  KeyF5,
17  KeyF6,
18  KeyF7,
19  KeyF8,
20  KeyF9,
21  KeyF10,
22  KeyF11,
23  KeyF12,
24  KeyF13,
25  KeyF14,
26  KeyF15,
27  KeyF16,
28  KeyF17,
29  KeyF18,
30  KeyF19,
31  KeyPrint,
32  KeyScrollLock,
33  KeyBreak,
34 
35  KeySpace = 0x0020,
36 
37  KeyApostrophe = 0x0027,
38  KeyComma = 0x002c,
39  KeyMinus = 0x002d,
40  KeyPeriod = 0x002e,
41  KeySlash = 0x002f,
42 
43  Key0 = 0x0030,
44  Key1 = 0x0031,
45  Key2 = 0x0032,
46  Key3 = 0x0033,
47  Key4 = 0x0034,
48  Key5 = 0x0035,
49  Key6 = 0x0036,
50  Key7 = 0x0037,
51  Key8 = 0x0038,
52  Key9 = 0x0039,
53 
54  KeySemicolon = 0x003b,
55  KeyLess = 0x003c,
56  KeyEqual = 0x003d,
57 
58  KeyA = 0x0041,
59  KeyB = 0x0042,
60  KeyC = 0x0043,
61  KeyD = 0x0044,
62  KeyE = 0x0045,
63  KeyF = 0x0046,
64  KeyG = 0x0047,
65  KeyH = 0x0048,
66  KeyI = 0x0049,
67  KeyJ = 0x004a,
68  KeyK = 0x004b,
69  KeyL = 0x004c,
70  KeyM = 0x004d,
71  KeyN = 0x004e,
72  KeyO = 0x004f,
73  KeyP = 0x0050,
74  KeyQ = 0x0051,
75  KeyR = 0x0052,
76  KeyS = 0x0053,
77  KeyT = 0x0054,
78  KeyU = 0x0055,
79  KeyV = 0x0056,
80  KeyW = 0x0057,
81  KeyX = 0x0058,
82  KeyY = 0x0059,
83  KeyZ = 0x005a,
84 
85  KeyBracketLeft = 0x005b,
86  KeyBackslash = 0x005c,
87  KeyBracketRight = 0x005d,
88 
89  KeyGrave = 0x0060,
90 
91  KeyLeft,
92  KeyRight,
93  KeyUp,
94  KeyDown,
95  KeyInsert,
96  KeyHome,
97  KeyDelete,
98  KeyEnd,
99  KeyPageUp,
100  KeyPageDown,
101 
102  KeyNumLock,
103  KeyKpEqual,
104  KeyKpDivide,
105  KeyKpMultiply,
106  KeyKpSubtract,
107  KeyKpAdd,
108  KeyKpEnter,
109  KeyKpInsert, // 0
110  KeyKpEnd, // 1
111  KeyKpDown, // 2
112  KeyKpPageDown, // 3
113  KeyKpLeft, // 4
114  KeyKpBegin, // 5
115  KeyKpRight, // 6
116  KeyKpHome, // 7
117  KeyKpUp, // 8
118  KeyKpPageUp, // 9
119  KeyKpDelete, // ,
120 
121  KeyBackSpace,
122  KeyTab,
123  KeyReturn,
124  KeyCapsLock,
125  KeyShiftL,
126  KeyCtrlL,
127  KeySuperL,
128  KeyAltL,
129  KeyAltR,
130  KeySuperR,
131  KeyMenu,
132  KeyCtrlR,
133  KeyShiftR,
134 
135  KeyBack,
136  KeySoftLeft,
137  KeySoftRight,
138  KeyCall,
139  KeyEndcall,
140  KeyStar,
141  KeyPound,
142  KeyDpadCenter,
143  KeyVolumeUp,
144  KeyVolumeDown,
145  KeyPower,
146  KeyCamera,
147  KeyClear,
148  KeySymbol,
149  KeyExplorer,
150  KeyEnvelope,
151  KeyEquals,
152  KeyAt,
153  KeyHeadsethook,
154  KeyFocus,
155  KeyPlus,
156  KeyNotification,
157  KeySearch,
158  KeyMediaPlayPause,
159  KeyMediaStop,
160  KeyMediaNext,
161  KeyMediaPrevious,
162  KeyMediaRewind,
163  KeyMediaFastForward,
164  KeyMute,
165  KeyPictsymbols,
166  KeySwitchCharset,
167 
168  KeyForward,
169  KeyExtra1,
170  KeyExtra2,
171  KeyExtra3,
172  KeyExtra4,
173  KeyExtra5,
174  KeyExtra6,
175  KeyFn,
176 
177  KeyCircumflex,
178  KeySsharp,
179  KeyAcute,
180  KeyAltGr,
181  KeyNumbersign,
182  KeyUdiaeresis,
183  KeyAdiaeresis,
184  KeyOdiaeresis,
185  KeySection,
186  KeyAring,
187  KeyDiaeresis,
188  KeyTwosuperior,
189  KeyRightParenthesis,
190  KeyDollar,
191  KeyUgrave,
192  KeyAsterisk,
193  KeyColon,
194  KeyExclam,
195 
196  KeyBraceLeft,
197  KeyBraceRight,
198  KeySysRq,
199 
200  KeyCount_
201 };
202 
203 
204 class InputDeviceKeyboardImpl;
205 
207 
216 class GAINPUT_LIBEXPORT InputDeviceKeyboard : public InputDevice
217 {
218 public:
220 
226  InputDeviceKeyboard(InputManager& manager, DeviceId device, unsigned index, DeviceVariant variant);
229 
231  DeviceType GetType() const { return DT_KEYBOARD; }
232  DeviceVariant GetVariant() const;
233  const char* GetTypeName() const { return "keyboard"; }
234  bool IsValidButtonId(DeviceButtonId deviceButton) const { return deviceButton < KeyCount_; }
235 
236  size_t GetAnyButtonDown(DeviceButtonSpec* outButtons, size_t maxButtonCount) const;
237 
238  size_t GetButtonName(DeviceButtonId deviceButton, char* buffer, size_t bufferLength) const;
239  ButtonType GetButtonType(DeviceButtonId deviceButton) const;
240  DeviceButtonId GetButtonByName(const char* name) const;
241 
242  InputState* GetNextInputState();
243 
245  bool IsTextInputEnabled() const;
247  void SetTextInputEnabled(bool enabled);
249  char GetNextCharacter();
250 
252  InputDeviceKeyboardImpl* GetPimpl() { return impl_; }
253 
254 protected:
255  void InternalUpdate(InputDeltaState* delta);
256  DeviceState InternalGetState() const;
257 
258 private:
259  InputDeviceKeyboardImpl* impl_;
260 
261  HashMap<Key, const char*> keyNames_;
262 };
263 
264 }
265 
266 #endif
267 
Key
All valid device buttons for InputDeviceKeyboard.
Definition: GainputInputDeviceKeyboard.h:9
Manages all input devices and some other helpful stuff.
Definition: GainputInputManager.h:24
A keyboard input device.
Definition: GainputInputDeviceKeyboard.h:216
InputDeviceKeyboardImpl * GetPimpl()
Returns the platform-specific implementation of this device (internal use only).
Definition: GainputInputDeviceKeyboard.h:252
ButtonType
Type of an input device button.
Definition: GainputInputDevice.h:10
Stores a list of input state changes.
Definition: GainputInputDeltaState.h:9
Describes a device button on a specific device.
Definition: gainput.h:112
A hash table mapping keys to POD-type values.
Definition: GainputContainers.h:232
unsigned int DeviceId
ID of an input device.
Definition: gainput.h:107
DeviceState
State of an input device.
Definition: GainputInputDevice.h:59
DeviceVariant
Variant of an input device type.
Definition: GainputInputDevice.h:51
DeviceType
Type of an input device.
Definition: GainputInputDevice.h:37
Interface for anything that provides device inputs.
Definition: GainputInputDevice.h:33
const char * GetTypeName() const
Returns the device type&#39;s name.
Definition: GainputInputDeviceKeyboard.h:233
DeviceType GetType() const
Returns DT_KEYBOARD.
Definition: GainputInputDeviceKeyboard.h:231
bool IsValidButtonId(DeviceButtonId deviceButton) const
Returns if the given button is valid for this device.
Definition: GainputInputDeviceKeyboard.h:234
unsigned int DeviceButtonId
ID of a specific button unique to an input device.
Definition: gainput.h:109
State of an input device.
Definition: GainputInputState.h:9
Contains all Gainput related classes, types, and functions.
Definition: gainput.h:103