Ps2KeyboardHost  1.0.1
Allows you to read from one or more PS2-style keyboards on an Arduino.
ps2_KeyboardOutput.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2017 Steve Benz <s8878992@hotmail.com>
3 
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8 
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13 
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 USA
18 */
19 #pragma once
20 
21 namespace ps2 {
31  enum class KeyboardOutput : uint8_t {
32  // These are codes returned from this API, rather than from the keyboard itself.
33  none = 0x0,
34  garbled = 0xfe,
35 
36  batSuccessful = 0xaa, // Reset or power-up successful
37  batFailure = 0xfc, // Not so fortunate
38 
39  ack = 0xfa,
40  echo = 0xee,
41  nack = 0xfe,
42 
43  unmake = 0xf0,
44 
45  extend = 0xe0,
46  extend1 = 0xe1,
47 
48  // "sc2" is short for "ScanCode Set 2". Similarly for "sc3"
49  // "sc2ex" is ScanCode set 2, prefixed by an 'extend' byte
50 
51  // There are lots of sources for scancode values; some more complete than others. This set
52  // is, at best, an approximation.
53  sc2_numLock = 0x77,
54  sc2_scrollLock = 0x7e,
55  sc2_capsLock = 0x58,
56  sc2_leftShift = 0x12,
57  sc2_rightShift = 0x59,
58  sc2_leftCtrl = 0x14,
59  sc2_leftAlt = 0x11,
60  sc2_sysRequest = 0x84, /* Generated by some keyboards by ALT and PRTSCR */
61  sc2_esc = 0x76,
62  sc2_backspace = 0x66,
63  sc2_tab = 0x0d,
64  sc2_enter = 0x5a,
65  sc2_space = 0x29,
66  sc2_keypad0 = 0x70,
67  sc2_keypad1 = 0x69,
68  sc2_keypad2 = 0x72,
69  sc2_keypad3 = 0x7a,
70  sc2_keypad4 = 0x6b,
71  sc2_keypad5 = 0x73,
72  sc2_keypad6 = 0x74,
73  sc2_keypad7 = 0x6c,
74  sc2_keypad8 = 0x75,
75  sc2_keypad9 = 0x7d,
76  sc2_keypadPeriod = 0x71,
77  sc2_keypadPlus = 0x79,
78  sc2_keypadDash = 0x7b,
79  sc2_keypadAsterisk = 0x7c,
80  sc2ex_keypadEnter = 0x5a,
81  sc2_KeypadEquals = 0x0f,
82  sc2_keypadComma = 0x6d,
84  sc2_0 = 0x45,
85  sc2_1 = 0x16,
86  sc2_2 = 0x1e,
87  sc2_3 = 0x26,
88  sc2_4 = 0x25,
89  sc2_5 = 0x2e,
90  sc2_6 = 0x36,
91  sc2_7 = 0x3d,
92  sc2_8 = 0x3e,
93  sc2_9 = 0x46,
94  sc2_apostrophe = 0x52, // ' "
95  sc2_comma = 0x41,
96  sc2_dash = 0x4e,
97  sc2_period = 0x49,
98  sc2_forwardSlash = 0x4a,
99  sc2_openQuote = 0x0e, // ` ~
100  sc2_a = 0x1c,
101  sc2_b = 0x32,
102  sc2_c = 0x21,
103  sc2_d = 0x23,
104  sc2_e = 0x24,
105  sc2_f = 0x2b,
106  sc2_g = 0x34,
107  sc2_h = 0x33,
108  sc2_i = 0x43,
109  sc2_j = 0x3b,
110  sc2_k = 0x42,
111  sc2_l = 0x4b,
112  sc2_m = 0x3a,
113  sc2_n = 0x31,
114  sc2_o = 0x44,
115  sc2_p = 0x4d,
116  sc2_q = 0x15,
117  sc2_r = 0x2d,
118  sc2_s = 0x1b,
119  sc2_t = 0x2c,
120  sc2_u = 0x3c,
121  sc2_v = 0x2a,
122  sc2_w = 0x1d,
123  sc2_x = 0x22,
124  sc2_y = 0x35,
125  sc2_z = 0x1a,
126  sc2_semicolon = 0x4c,
127  sc2_backslash = 0x5d,
128  sc2_europe2 = 0x61, // Extra key left of Z on 102 keyboards
129  sc2_openSquareBracket = 0x54,
130  sc2_closeSquareBracket = 0x5b,
131  sc2_equal = 0x55,
132  sc2_f1 = 0x05,
133  sc2_f2 = 0x06,
134  sc2_f3 = 0x04,
135  sc2_f4 = 0x0c,
136  sc2_f5 = 0x03,
137  sc2_f6 = 0x0b,
138  sc2_f7 = 0x83,
139  sc2_f8 = 0x0a,
140  sc2_f9 = 0x01,
141  sc2_f10 = 0x09,
142  sc2_f11 = 0x78,
143  sc2_f12 = 0x07,
144  sc2_f13 = 0x08,
145  sc2_f14 = 0x10,
146  sc2_f15 = 0x18,
147  sc2_f16 = 0x20,
148  sc2_f17 = 0x28,
149  sc2_f18 = 0x30,
150  sc2_f19 = 0x38,
151  sc2_f20 = 0x40,
152  sc2_f21 = 0x48,
153  sc2_f22 = 0x50,
154  sc2_f23 = 0x57,
155  sc2_f24 = 0x5f,
156  sc2_intl1 = 0x51,
157  sc2_intl2 = 0x13,
158  sc2_intl3 = 0x6a,
159  sc2_intl4 = 0x64,
160  sc2_intl5 = 0x67,
161  sc2_lang1 = 0xF2,
162  sc2_lang2 = 0xF1,
163  sc2_lang3 = 0x63,
164  sc2_lang4 = 0x62,
165  sc2_lang5 = 0x5f,
166 
167  sc2ex_pauseBreak= 0x5f,
168  sc2ex_rightCtrl = 0x14, // same as sc2_leftCtrl
169  sc2ex_rightAlt = 0x11, // same as sc2_leftAlt
170  // Note that rightShift is not in the extended space.
171  sc2ex_leftGui = 0x1f,
172  sc2ex_leftWindows = 0x1f,
173  sc2ex_rightGui = 0x27,
174  sc2ex_rightWindows = 0x27,
175 
176  sc2ex_printScreen = 0x7c, // Note that PS2 keyboards generate a shift keyup&keydown artificially for this keystroke, usually.
177  sc2ex_menu = 0x2f, // "Apps" key in some circles
178 
179  sc2ex_home = 0x6c,
180  sc2ex_end = 0x69,
181  sc2ex_pageUp = 0x7d,
182  sc2ex_pageDown = 0x7a,
183  sc2ex_leftArrow = 0x6b,
184  sc2ex_rightArrow = 0x74,
185  sc2ex_upArrow = 0x75,
186  sc2ex_downArrow = 0x72,
187  sc2ex_insert = 0x70,
188  sc2ex_delete = 0x71,
189  sc2ex_nextTrack = 0x4d,
190  sc2ex_prevTrack = 0x15,
191  sc2ex_stop = 0x3b,
192  sc2ex_play = 0x34,
193  sc2ex_mute = 0x23,
194  sc2ex_volumeUp = 0x32,
195  sc2ex_volumeDown = 0x21,
196  sc2ex_mediaSelect = 0x50,
197  sc2ex_email = 0x48,
198  sc2ex_calculator = 0x2b,
199  sc2ex_myComputer = 0x40,
200  sc2ex_webSearch = 0x10,
201  sc2ex_webHome = 0x3a,
202  sc2ex_webBack = 0x38,
203  sc2ex_webForward = 0x30,
204  sc2ex_webStop = 0x28,
205  sc2ex_webRefresh = 0x20,
206  sc2ex_webFavorites = 0x18,
207  sc2ex_power = 0x37,
208  sc2ex_sleep = 0x3f,
209  sc2ex_wake = 0X5e,
210 
211  // All the sc3 values come from http://www.computer-engineering.org/ps2keyboard/scancodes3.html
212  sc3_a = 0x1c,
213  sc3_b = 0x32,
214  sc3_c = 0x21,
215  sc3_d = 0x23,
216  sc3_e = 0x24,
217  sc3_f = 0x2b,
218  sc3_g = 0x34,
219  sc3_h = 0x33,
220  sc3_i = 0x43,
221  sc3_j = 0x3b,
222  sc3_k = 0x42,
223  sc3_l = 0x4b,
224  sc3_m = 0x3a,
225  sc3_n = 0x31,
226  sc3_o = 0x44,
227  sc3_p = 0x4d,
228  sc3_q = 0x15,
229  sc3_r = 0x2d,
230  sc3_s = 0x1b,
231  sc3_t = 0x2c,
232  sc3_u = 0x3c,
233  sc3_v = 0x2a,
234  sc3_w = 0x1d,
235  sc3_x = 0x22,
236  sc3_y = 0x35,
237  sc3_z = 0x1a,
238 
239  sc3_0 = 0x45,
240  sc3_1 = 0x16,
241  sc3_2 = 0x1e,
242  sc3_3 = 0x26,
243  sc3_4 = 0x25,
244  sc3_5 = 0x2e,
245  sc3_6 = 0x36,
246  sc3_7 = 0x3d,
247  sc3_8 = 0x3e,
248  sc3_9 = 0x46,
249 
250  sc3_keypadSlash = 0x4a,
251  sc3_keypadAsterisk = 0x7e,
252  sc3_keypadDash = 0x4e,
253  sc3_keypadPlus = 0x7c,
254  sc3_keypadEnter = 0x79,
255  sc3_keypadPeriod = 0x71,
256  sc3_keypad0 = 0x70,
257  sc3_keypad1 = 0x69,
258  sc3_keypad2 = 0x72,
259  sc3_keypad3 = 0x7a,
260  sc3_keypad4 = 0x6b,
261  sc3_keypad5 = 0x73,
262  sc3_keypad6 = 0x74,
263  sc3_keypad7 = 0x6c,
264  sc3_keypad8 = 0x75,
265  sc3_keypad9 = 0x7d,
266 
267  sc3_f1 = 0x07,
268  sc3_f2 = 0x0f,
269  sc3_f3 = 0x17,
270  sc3_f4 = 0x1f,
271  sc3_f5 = 0x27,
272  sc3_f6 = 0x2f,
273  sc3_f7 = 0x37,
274  sc3_f8 = 0x3f,
275  sc3_f9 = 0x47,
276  sc3_f10 = 0x4f,
277  sc3_f11 = 0x56,
278  sc3_f12 = 0x5e,
279 
280  sc3_openSquareBracket = 0x54,
281  sc3_openQuote = 0x0e,
282  sc3_dash = 0x4e,
283 
284  sc3_insert = 0x67,
285  sc3_home = 0x6e,
286  sc3_pageUp = 0x6f,
287  sc3_delete = 0x64,
288  sc3_end = 0x65,
289  sc3_pageDown = 0x6d,
290  sc3_upArrow = 0x63,
291  sc3_leftArrow = 0x61,
292  sc3_downArrow = 0x60,
293  sc3_rightArrow = 0x6a,
294 
295  sc3_numLock = 0x76,
296  sc3_capsLock = 0x14,
297 
298  sc3_leftShift = 0x12,
299  sc3_leftCtrl = 0x11,
300  sc3_leftGui = 0x8b,
301  sc3_leftWindows = 0x8b,
302  sc3_leftAlt = 0x19,
303  sc3_rightShift = 0x59,
304  sc3_rightCtrl = 0x58,
305  sc3_rightGui = 0x8c,
306  sc3_rightWindows = 0x8c,
307  sc3_rightAlt = 0x39,
308 
309  sc3_backspace = 0x66,
310  sc3_tab = 0x0d,
311  sc3_space = 0x29,
312  sc3_enter = 0x5a,
313 
314  sc3_equal = 0x55,
315  sc3_backslash = 0x5c,
316  sc3_escape = 0x08,
317  sc3_closeSquareBracket = 0x5b,
318  sc3_semicolon = 0x4c,
319  sc3_apostrophe = 0x52,
320  sc3_comma = 0x41,
321  sc3_period = 0x49,
322  sc3_slash = 0x4a,
323 
324  sc3_printScreen = 0x57,
325  sc3_scrollLock = 0x5f,
326  sc3_pause = 0x62,
327 
328  sc3_apps = 0x8d,
329  sc3_menu = 0x8d,
330  };
331 }
Definition: ps2_AnsiTranslator.h:24
KeyboardOutput
Byte-codes sent back from the Ps2 keyboard to the host.
Definition: ps2_KeyboardOutput.h:31