Serial Wombat Arduino Library

Loading...
Searching...
No Matches
SerialWombatPS2Keyboard.h
Go to the documentation of this file.
1#pragma once
2
3/*
4 Copyright 2023 Broadwell Consulting Inc.
5
6"Serial Wombat" is a registered trademark of Broadwell Consulting Inc. in
7 the United States. See SerialWombat.com for usage guidance.
8
9 Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26*/
27
28#include <stdint.h>
29#include "Stream.h"
30#include "SerialWombat.h"
33
34
35 typedef enum
36{
37 SCANCODE_OPENSINGLEQUOTE = 0x0E,
38 SCANCODE_1 = 0x16,
39 SCANCODE_2 = 0x1E,
40 SCANCODE_3 = 0x26,
41 SCANCODE_4 = 0x25,
42 SCANCODE_5 = 0x2E,
43 SCANCODE_6 = 0x36,
44 SCANCODE_7 = 0x3D,
45 SCANCODE_8 = 0x3E,
46 SCANCODE_9 = 0x46,
47 SCANCODE_0 = 0x45,
48 SCANCODE_DASH = 0x4E,
49 SCANCODE_EQUALS = 0x55,
50 SCANCODE_BACKSPACE = 0x66,
51 SCANCODE_TAB = 0x0D,
52 SCANCODE_Q = 0x15,
53 SCANCODE_W = 0x1D,
54 SCANCODE_E = 0x24,
55 SCANCODE_R = 0x2D,
56 SCANCODE_T = 0x2C,
57 SCANCODE_Y = 0x35,
58 SCANCODE_U = 0x3C,
59 SCANCODE_I = 0x43,
60 SCANCODE_O = 0x44,
61 SCANCODE_P = 0x4D,
62 SCANCODE_LEFTBRACKET = 0x54,
63 SCANCODE_RIGHTBRACKET = 0x5B,
64 SCANCODE_CAPSLOCK = 0x58,
65 SCANCODE_A = 0x1C,
66 SCANCODE_S = 0x1B,
67 SCANCODE_D = 0x23,
68 SCANCODE_G = 0x34,
69 SCANCODE_H = 0x33,
70 SCANCODE_J = 0x3B,
71 SCANCODE_K = 0x42,
72 SCANCODE_L = 0x4B,
73 SCANCODE_SEMICOLON = 0x4C,
74 SCANCODE_QUOTE = 0x52,
75 SCANCODE_ENTER = 0x5A,
76 SCANCODE_LEFTSHIFT = 0x12,
77 SCANCODE_Z = 0x1A,
78 SCANCODE_X = 0x22,
79 SCANCODE_C = 0x21,
80 SCANCODE_V = 0x2A,
81 SCANCODE_B = 0x32,
82 SCANCODE_N = 0x31,
83 SCANCODE_M = 0x3A,
84 SCANCODE_COMMA = 0x41,
85 SCANCODE_PERIOD = 0x49,
86 SCANCODE_SLASH = 0x4A,
87 SCANCODE_RIGHTSHIFT = 0x59,
88 SCANCODE_LEFTCTRL = 0x14,
89 SCANCODE_LEFTALT = 0x11,
90 SCANCODE_SPACEBAR = 0x29,
91 SCANCODE_RIGHTALT = 0x91,
92 SCANCODE_RIGHTCTRL = 0x94,
93 SCANCODE_INSERT = 0xF0,
94 SCANCODE_DELETE = 0xF1,
95 SCANCODE_LEFTARROW = 0xEB,
96 SCANCODE_HOME = 0xEC,
97 SCANCODE_END = 0xE9,
98 SCANCODE_UPARROW = 0xF5,
99 SCANCODE_DOWNARROW = 0xF2,
100 SCANCODE_PAGEUP = 0xFD,
101 SCANCODE_PAGEDOWN = 0xFA,
102 SCANCODE_RIGHTARROW = 0xF4,
103 SCANCODE_NUMLOCK = 0x76,
104 SCANCODE_KP7 = 0x6C,
105 SCANCODE_KP4 = 0x6B,
106 SCANCODE_KP1 = 0x69,
107 SCANCODE_KPSLASH = 0xCA,
108 SCANCODE_KP8 = 0x75,
109 SCANCODE_KP5 = 0x73,
110 SCANCODE_KP2 = 0x72,
111 SCANCODE_KP0 = 0x70,
112 SCANCODE_KPASTERISK = 0x7C,
113 SCANCODE_KP9 = 0x7D,
114 SCANCODE_KP6 = 0x74,
115 SCANCODE_KP3 = 0x7A,
116 SCANCODE_KPPERIOD = 0x71,
117 SCANCODE_KPMINUS = 0x7B,
118 SCANCODE_KPPLUS = 0x79,
119 SCANCODE_KPENTER = 0xDA,
120 SCANCODE_ESC = 0x76,
121 SCANCODE_F1 = 0x05,
122 SCANCODE_F2 = 0x06,
123 SCANCODE_F3 = 0x04,
124 SCANCODE_F4 = 0x0C,
125 SCANCODE_F5 = 0x03,
126 SCANCODE_F6 = 0x0B,
127 SCANCODE_F7 = 0x83,
128 SCANCODE_F8 = 0x0A,
129 SCANCODE_F9 = 0x01,
130 SCANCODE_F10 = 0x09,
131 SCANCODE_F11 = 0x78,
132 SCANCODE_F12 = 0x07,
133 SCANCODE_PRINTSCREEN = 0x92,
134 SCANCODE_SCROLLLOCK = 0x7E,
135 SCANCODE_BACKSLASH = 0x5D
136}PS2KeyboardScanCode;
137
138
180
181 class SerialWombatPS2Keyboard :
182 public Stream, public SerialWombatPin
183{
184 public:
189 SerialWombatPS2Keyboard(SerialWombatChip& serialWombat):SerialWombatPin(serialWombat){}
199 int16_t begin(uint8_t clockPin, uint8_t dataPin, uint8_t bufferMode = 0, uint8_t queueMode = 0, uint16_t queueAddress = 0xFFFF, uint8_t pullUpDown = 0)
200 {
201 _pin = clockPin;
202 _pinMode = (uint8_t)PIN_MODE_PS2KEYBOARD;
203
204 uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE0,
205 _pin,
206 (uint8_t)_pinMode ,
207 dataPin,
208 queueMode,
209 bufferMode,
210 0x55,
211 pullUpDown};
212 int16_t result = _sw.sendPacket(tx);
213 if (result < 0)
214 {
215 return result;
216 }
217
218 if (queueAddress != 0xFFFF)
219 {
220 uint8_t tx6[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE6,
221 _pin,
222 _pinMode,
223 SW_LE16(queueAddress),
224 0x55,
225 0x55,
226 0x55 };
227
228 return _sw.sendPacket(tx6);
229 }
230 return (result);
231 }
232
233
234
239 int available()
240 {
241 uint8_t tx[8] = { 201, _pin, _pinMode, 0,0x55,0x55,0x55,0x55 };
242 uint8_t rx[8];
243 _sw.sendPacket(tx, rx);
244 return (rx[4]);
245 }
246
250 int read()
251 {
252 uint8_t tx[8] = { 202, _pin,_pinMode, 1,0x55,0x55,0x55,0x55 };
253 uint8_t rx[8];
254 if (_sw.sendPacket(tx, rx) < 0)
255 {
256 return -1;
257 }
258
259 if (rx[3] != 0)
260 {
261 return (rx[4]);
262 }
263 else
264 {
265 return (-1);
266 }
267 }
268
271 void flush()
272 {
273
274 }
275
280 int peek()
281 {
282 uint8_t tx[8] = { 203, _pin,_pinMode,0x55,0x55,0x55,0x55,0x55 };
283 uint8_t rx[8];
284 _sw.sendPacket(tx, rx);
285 if (rx[4] > 0)
286 {
287 return (rx[5]);
288 }
289 else
290 {
291 return (-1);
292 }
293 }
294
302 size_t write(uint8_t data)
303{
304 (void)data; // Avoid compiler warning for unused parameter
305
306 return (1);
307}
308
317 size_t write(const uint8_t* buffer, size_t size)
318{
319 (void)buffer; // Avoid compiler warning for unused parameter
320 return(size);
321}
322
327 int availableForWrite()
328{
329 return(0);
330}
331
342 size_t readBytes(char* buffer, size_t length)
343 {
344 int index = 0;
345 int bytesAvailable = 0;
346 uint32_t timeoutMillis = millis() + timeout;
347 while (length > 0 && timeoutMillis > millis())
348 {
349 int bytecount = 4;
350 if (length < 4)
351 {
352 bytecount = length;
353 }
354 {
355
356 uint8_t tx[8] = { 202, _pin,_pinMode, (uint8_t)bytecount,0x55,0x55,0x55,0x55 };
357 uint8_t rx[8];
358 _sw.sendPacket(tx, rx);
359 bytesAvailable = rx[3];
360
361 if (bytesAvailable == 0)
362 {
363 continue;
364 }
365 else
366 {
367 timeoutMillis = millis() + timeout;
368 }
369 uint8_t bytesReturned = bytecount;
370 if (rx[3] < bytecount)
371 {
372 bytesReturned = rx[3];
373 }
374 for (int i = 0; i < bytesReturned; ++i)
375 {
376 buffer[index] = rx[i + 4];
377 ++index;
378 --bytesAvailable;
379 --length;
380
381 }
382 }
383
384 }
385 return (index);
386 }
387
388 int16_t readCurrentScanCodes(uint8_t* buffer, uint8_t startValue)
389 {
390 uint8_t tx[8] = { 207, _pin,_pinMode, startValue,0x55,0x55,0x55,0x55 };
391 uint8_t rx[8];
392
393 int16_t result = _sw.sendPacket(tx, rx);
394
395 if (result < 0)
396 {
397 return result;
398 }
399 int count = 0;
400 for (int i = 3; i < 8; ++i)
401 {
402 if (rx[i] != 0)
403 {
404 ++count;
405 }
406 buffer[i - 3] = rx[i];
407 }
408 return count;
409 }
410
414 void setTimeout(long timeout_mS)
415 {
416 if (timeout_mS == 0)
417 {
418 timeout = 0x80000000;
419 }
420 else
421 {
422 timeout = timeout_mS;
423 }
424 }
425
429 uint8_t scanCodeToAscii(uint8_t scanCode, bool shiftActive = false)
430 {
431
432 if (scanCode >= 0x80)
433 {
434 return 0;
435 }
436 //This array is used to convert PS2 Code set 2 codes to Ascii. The first column is unshfited data, the second if shift is active
437 const uint8_t KBSCSet2[][2] =
438 {
439 { ' ' , ' ' }, /* 0 */
440 { ' ' , ' ' }, /* 1 */
441 { ' ' , ' ' }, /* 2 */
442 { ' ' , ' ' }, /* 3 */
443 { ' ' , ' ' }, /* 4 */
444 { ' ' , ' ' }, /* 5 */
445 { ' ' , ' ' }, /* 6 */
446 { ' ' , ' ' }, /* 7 */
447 { ' ' , ' ' }, /* 8 */
448 { ' ' , ' ' }, /* 9 */
449 { ' ' , ' ' }, /* A */
450 { ' ' , ' ' }, /* B */
451 { ' ' , ' ' }, /* C */
452 { 9 , 9 }, /* D */
453 { '`' , '~' }, /* E */
454 { ' ' , ' ' }, /* F */
455 { ' ' , ' ' }, /* 10 */
456 { ' ' , ' ' }, /* 11 */
457 { 0 , 0 }, /* 12 */
458 { ' ' , ' ' }, /* 13 */
459 { ' ' , ' ' }, /* 14 */
460 { 'q' , 'Q' }, /* 15 */
461 { '1' , '!' }, /* 16 */
462 { ' ' , ' ' }, /* 17 */
463 { ' ' , ' ' }, /* 18 */
464 { ' ' , ' ' }, /* 19 */
465 { 'z' , 'Z' }, /* 1A */
466 { 's' , 'S' }, /* 1B */
467 { 'a' , 'A' }, /* 1C */
468 { 'w' , 'W' }, /* 1D */
469 { '2' , '@' }, /* 1E */
470 { ' ' , ' ' }, /* 1F */
471 { ' ' , ' ' }, /* 20 */
472 { 'c' , 'C' }, /* 21 */
473 { 'x' , 'X' }, /* 22 */
474 { 'd' , 'D' }, /* 23 */
475 { 'e' , 'E' }, /* 24 */
476 { '4' , '$' }, /* 25 */
477 { '3' , '#' }, /* 26 */
478 { ' ' , ' ' }, /* 27 */
479 { ' ' , ' ' }, /* 28 */
480 { ' ' , ' ' }, /* 29 - SPACE */
481 { 'v' , 'V' }, /* 2A */
482 { 'f' , 'F' }, /* 2B */
483 { 't' , 'T' }, /* 2C */
484 { 'r' , 'R' }, /* 2D */
485 { '5' , '%' }, /* 2E */
486 { ' ' , ' ' }, /* 2F */
487 { ' ' , ' ' }, /* 30 */
488 { 'n' , 'N' }, /* 31 */
489 { 'b' , 'B' }, /* 32 */
490 { 'h' , 'H' }, /* 33 */
491 { 'g' , 'G' }, /* 34 */
492 { 'y' , 'Y' }, /* 35 */
493 { '6' , '^' }, /* 36 */
494 { ' ' , ' ' }, /* 37 */
495 { ' ' , ' ' }, /* 38 */
496 { ' ' , ' ' }, /* 39 */
497 { 'm' , 'M' }, /* 3A */
498 { 'j' , 'J' }, /* 3B */
499 { 'u' , 'U' }, /* 3C */
500 { '7' , '&' }, /* 3D */
501 { '8' , '*' }, /* 3E */
502 { ' ' , ' ' }, /* 3F */
503 { ' ' , ' ' }, /* 40 */
504 { ',' , '>' }, /* 41 */
505 { 'k' , 'K' }, /* 42 */
506 { 'i' , 'I' }, /* 43 */
507 { 'o' , 'O' }, /* 44 */
508 { '0' , ')' }, /* 45 */
509 { '9' , '(' }, /* 46 */
510 { ' ' , ' ' }, /* 47 */
511 { ' ' , ' ' }, /* 48 */
512 { '.' , '<' }, /* 49 */
513 { '/' , '?' }, /* 4A */
514 { 'l' , 'L' }, /* 4B */
515 { ';' , ':' }, /* 4C */
516 { 'p' , 'P' }, /* 4D */
517 { '-' , '_' }, /* 4E */
518 { ' ' , ' ' }, /* 4F */
519 { ' ' , ' ' }, /* 50 */
520 { ' ' , ' ' }, /* 51 */
521 { '\'' , '"' }, /* 52 */
522 { ' ' , ' ' }, /* 53 */
523 { '[' , '{' }, /* 54 */
524 { '=' , '+' }, /* 55 */
525 { ' ' , ' ' }, /* 56 */
526 { ' ' , ' ' }, /* 57 */
527 { ' ' , ' ' }, /* 58 */
528 { 0 , 0 }, /* 59 */
529 { 0xD , 0xD }, /* 5A */
530 { ']' , '}' }, /* 5B */
531 { ' ' , ' ' }, /* 5C */
532 { '\\' , '|' }, /* 5D */
533 { ' ' , ' ' }, /* 5E */
534 { ' ' , ' ' }, /* 5F */
535 { ' ' , ' ' }, /* 60 */
536 { ' ' , ' ' }, /* 61 */
537 { ' ' , ' ' }, /* 62 */
538 { ' ' , ' ' }, /* 63 */
539 { ' ' , ' ' }, /* 64 */
540 { ' ' , ' ' }, /* 65 */
541 { 8 , 8 }, /* 66 */
542 { ' ' , ' ' }, /* 67 */
543 { ' ' , ' ' }, /* 68 */
544 { '1' , '1' }, /* 69 */
545 { ' ' , ' ' }, /* 6A */
546 { '4' , '4' }, /* 6B */
547 { '7' , '7' }, /* 6C */
548 { ' ' , ' ' }, /* 6D */
549 { ' ' , ' ' }, /* 6E */
550 { ' ' , ' ' }, /* 6F */
551 { '0' , '0' }, /* 70 */
552 { ' ' , ' ' }, /* 71 */
553 { '2' , '2' }, /* 72 */
554 { '5' , '5' }, /* 73 */
555 { '6' , '6' }, /* 74 */
556 { '8' , '8' }, /* 75 */
557 { 0x1B , 0x1B }, /* 76 */
558 { ' ' , ' ' }, /* 77 */
559 { ' ' , ' ' }, /* 78 */
560 { ' ' , ' ' }, /* 79 */
561 { '3' , '3' }, /* 7A */
562 { ' ' , ' ' }, /* 7B */
563 { ' ' , ' ' }, /* 7C */
564 { '9' , '9' }, /* 7D */
565 { ' ' , ' ' }, /* 7E */
566 { ' ' , ' ' }, /* 7F */
567 };
568
569 if (shiftActive)
570 {
571 return ( KBSCSet2[scanCode][ 1]);
572 }
573
574 return ( KBSCSet2[scanCode][0]);
575 }
576
582 bool isKeyPressed(uint8_t scanCode)
583{
584 uint8_t buffer[5];
585 int16_t result = readCurrentScanCodes(buffer, scanCode);
586
587 if (result < 0)
588 {
589 return false;
590 }
591
592 if (buffer[0] == scanCode)
593 {
594 return true;
595 }
596
597 return false;
598
599}
600
601 bool isKeyPressed(PS2KeyboardScanCode scanCode)
602{
603 return isKeyPressed((uint8_t) scanCode);
604}
605
606 uint8_t _pin = 255;
607 protected:
608 uint32_t timeout = 1;
609};
610
611
612
613
SerialWombat.h
SW_LE16
#define SW_LE16(_a)
Convert a uint16_t to two bytes in little endian format for array initialization.
Definition SerialWombat.h:46
SerialWombatCommands::CONFIGURE_PIN_MODE0
@ CONFIGURE_PIN_MODE0
(200)
Definition SerialWombat.h:237
SerialWombatCommands::CONFIGURE_PIN_MODE6
@ CONFIGURE_PIN_MODE6
(206)
Definition SerialWombat.h:243
PIN_MODE_PS2KEYBOARD
@ PIN_MODE_PS2KEYBOARD
(32)
Definition SerialWombat.h:290
PS2KeyboardScanCode
PS2KeyboardScanCode
Definition SerialWombatPS2Keyboard.h:36
SCANCODE_F11
@ SCANCODE_F11
Definition SerialWombatPS2Keyboard.h:131
SCANCODE_KP4
@ SCANCODE_KP4
Definition SerialWombatPS2Keyboard.h:105
SCANCODE_KP7
@ SCANCODE_KP7
Definition SerialWombatPS2Keyboard.h:104
SCANCODE_9
@ SCANCODE_9
Definition SerialWombatPS2Keyboard.h:46
SCANCODE_UPARROW
@ SCANCODE_UPARROW
Definition SerialWombatPS2Keyboard.h:98
SCANCODE_3
@ SCANCODE_3
Definition SerialWombatPS2Keyboard.h:40
SCANCODE_A
@ SCANCODE_A
Definition SerialWombatPS2Keyboard.h:65
SCANCODE_F4
@ SCANCODE_F4
Definition SerialWombatPS2Keyboard.h:124
SCANCODE_2
@ SCANCODE_2
Definition SerialWombatPS2Keyboard.h:39
SCANCODE_RIGHTALT
@ SCANCODE_RIGHTALT
Definition SerialWombatPS2Keyboard.h:91
SCANCODE_S
@ SCANCODE_S
Definition SerialWombatPS2Keyboard.h:66
SCANCODE_SEMICOLON
@ SCANCODE_SEMICOLON
Definition SerialWombatPS2Keyboard.h:73
SCANCODE_NUMLOCK
@ SCANCODE_NUMLOCK
Definition SerialWombatPS2Keyboard.h:103
SCANCODE_OPENSINGLEQUOTE
@ SCANCODE_OPENSINGLEQUOTE
Definition SerialWombatPS2Keyboard.h:37
SCANCODE_F3
@ SCANCODE_F3
Definition SerialWombatPS2Keyboard.h:123
SCANCODE_Z
@ SCANCODE_Z
Definition SerialWombatPS2Keyboard.h:77
SCANCODE_ENTER
@ SCANCODE_ENTER
Definition SerialWombatPS2Keyboard.h:75
SCANCODE_F7
@ SCANCODE_F7
Definition SerialWombatPS2Keyboard.h:127
SCANCODE_COMMA
@ SCANCODE_COMMA
Definition SerialWombatPS2Keyboard.h:84
SCANCODE_DASH
@ SCANCODE_DASH
Definition SerialWombatPS2Keyboard.h:48
SCANCODE_U
@ SCANCODE_U
Definition SerialWombatPS2Keyboard.h:58
SCANCODE_KP3
@ SCANCODE_KP3
Definition SerialWombatPS2Keyboard.h:115
SCANCODE_KPPLUS
@ SCANCODE_KPPLUS
Definition SerialWombatPS2Keyboard.h:118
SCANCODE_6
@ SCANCODE_6
Definition SerialWombatPS2Keyboard.h:43
SCANCODE_D
@ SCANCODE_D
Definition SerialWombatPS2Keyboard.h:67
SCANCODE_RIGHTBRACKET
@ SCANCODE_RIGHTBRACKET
Definition SerialWombatPS2Keyboard.h:63
SCANCODE_INSERT
@ SCANCODE_INSERT
Definition SerialWombatPS2Keyboard.h:93
SCANCODE_F1
@ SCANCODE_F1
Definition SerialWombatPS2Keyboard.h:121
SCANCODE_M
@ SCANCODE_M
Definition SerialWombatPS2Keyboard.h:83
SCANCODE_K
@ SCANCODE_K
Definition SerialWombatPS2Keyboard.h:71
SCANCODE_KPENTER
@ SCANCODE_KPENTER
Definition SerialWombatPS2Keyboard.h:119
SCANCODE_J
@ SCANCODE_J
Definition SerialWombatPS2Keyboard.h:70
SCANCODE_F9
@ SCANCODE_F9
Definition SerialWombatPS2Keyboard.h:129
SCANCODE_KPSLASH
@ SCANCODE_KPSLASH
Definition SerialWombatPS2Keyboard.h:107
SCANCODE_1
@ SCANCODE_1
Definition SerialWombatPS2Keyboard.h:38
SCANCODE_END
@ SCANCODE_END
Definition SerialWombatPS2Keyboard.h:97
SCANCODE_RIGHTCTRL
@ SCANCODE_RIGHTCTRL
Definition SerialWombatPS2Keyboard.h:92
SCANCODE_5
@ SCANCODE_5
Definition SerialWombatPS2Keyboard.h:42
SCANCODE_F8
@ SCANCODE_F8
Definition SerialWombatPS2Keyboard.h:128
SCANCODE_DOWNARROW
@ SCANCODE_DOWNARROW
Definition SerialWombatPS2Keyboard.h:99
SCANCODE_SPACEBAR
@ SCANCODE_SPACEBAR
Definition SerialWombatPS2Keyboard.h:90
SCANCODE_R
@ SCANCODE_R
Definition SerialWombatPS2Keyboard.h:55
SCANCODE_T
@ SCANCODE_T
Definition SerialWombatPS2Keyboard.h:56
SCANCODE_E
@ SCANCODE_E
Definition SerialWombatPS2Keyboard.h:54
SCANCODE_G
@ SCANCODE_G
Definition SerialWombatPS2Keyboard.h:68
SCANCODE_LEFTBRACKET
@ SCANCODE_LEFTBRACKET
Definition SerialWombatPS2Keyboard.h:62
SCANCODE_W
@ SCANCODE_W
Definition SerialWombatPS2Keyboard.h:53
SCANCODE_KP5
@ SCANCODE_KP5
Definition SerialWombatPS2Keyboard.h:109
SCANCODE_H
@ SCANCODE_H
Definition SerialWombatPS2Keyboard.h:69
SCANCODE_KP8
@ SCANCODE_KP8
Definition SerialWombatPS2Keyboard.h:108
SCANCODE_KP9
@ SCANCODE_KP9
Definition SerialWombatPS2Keyboard.h:113
SCANCODE_F12
@ SCANCODE_F12
Definition SerialWombatPS2Keyboard.h:132
SCANCODE_8
@ SCANCODE_8
Definition SerialWombatPS2Keyboard.h:45
SCANCODE_KPMINUS
@ SCANCODE_KPMINUS
Definition SerialWombatPS2Keyboard.h:117
SCANCODE_Q
@ SCANCODE_Q
Definition SerialWombatPS2Keyboard.h:52
SCANCODE_PAGEDOWN
@ SCANCODE_PAGEDOWN
Definition SerialWombatPS2Keyboard.h:101
SCANCODE_PERIOD
@ SCANCODE_PERIOD
Definition SerialWombatPS2Keyboard.h:85
SCANCODE_P
@ SCANCODE_P
Definition SerialWombatPS2Keyboard.h:61
SCANCODE_B
@ SCANCODE_B
Definition SerialWombatPS2Keyboard.h:81
SCANCODE_KP6
@ SCANCODE_KP6
Definition SerialWombatPS2Keyboard.h:114
SCANCODE_KPASTERISK
@ SCANCODE_KPASTERISK
Definition SerialWombatPS2Keyboard.h:112
SCANCODE_4
@ SCANCODE_4
Definition SerialWombatPS2Keyboard.h:41
SCANCODE_PRINTSCREEN
@ SCANCODE_PRINTSCREEN
Definition SerialWombatPS2Keyboard.h:133
SCANCODE_LEFTSHIFT
@ SCANCODE_LEFTSHIFT
Definition SerialWombatPS2Keyboard.h:76
SCANCODE_QUOTE
@ SCANCODE_QUOTE
Definition SerialWombatPS2Keyboard.h:74
SCANCODE_O
@ SCANCODE_O
Definition SerialWombatPS2Keyboard.h:60
SCANCODE_SLASH
@ SCANCODE_SLASH
Definition SerialWombatPS2Keyboard.h:86
SCANCODE_I
@ SCANCODE_I
Definition SerialWombatPS2Keyboard.h:59
SCANCODE_RIGHTSHIFT
@ SCANCODE_RIGHTSHIFT
Definition SerialWombatPS2Keyboard.h:87
SCANCODE_7
@ SCANCODE_7
Definition SerialWombatPS2Keyboard.h:44
SCANCODE_KP1
@ SCANCODE_KP1
Definition SerialWombatPS2Keyboard.h:106
SCANCODE_KP0
@ SCANCODE_KP0
Definition SerialWombatPS2Keyboard.h:111
SCANCODE_L
@ SCANCODE_L
Definition SerialWombatPS2Keyboard.h:72
SCANCODE_HOME
@ SCANCODE_HOME
Definition SerialWombatPS2Keyboard.h:96
SCANCODE_BACKSPACE
@ SCANCODE_BACKSPACE
Definition SerialWombatPS2Keyboard.h:50
SCANCODE_F5
@ SCANCODE_F5
Definition SerialWombatPS2Keyboard.h:125
SCANCODE_F6
@ SCANCODE_F6
Definition SerialWombatPS2Keyboard.h:126
SCANCODE_KP2
@ SCANCODE_KP2
Definition SerialWombatPS2Keyboard.h:110
SCANCODE_TAB
@ SCANCODE_TAB
Definition SerialWombatPS2Keyboard.h:51
SCANCODE_BACKSLASH
@ SCANCODE_BACKSLASH
Definition SerialWombatPS2Keyboard.h:135
SCANCODE_V
@ SCANCODE_V
Definition SerialWombatPS2Keyboard.h:80
SCANCODE_DELETE
@ SCANCODE_DELETE
Definition SerialWombatPS2Keyboard.h:94
SCANCODE_Y
@ SCANCODE_Y
Definition SerialWombatPS2Keyboard.h:57
SCANCODE_CAPSLOCK
@ SCANCODE_CAPSLOCK
Definition SerialWombatPS2Keyboard.h:64
SCANCODE_F10
@ SCANCODE_F10
Definition SerialWombatPS2Keyboard.h:130
SCANCODE_ESC
@ SCANCODE_ESC
Definition SerialWombatPS2Keyboard.h:120
SCANCODE_F2
@ SCANCODE_F2
Definition SerialWombatPS2Keyboard.h:122
SCANCODE_PAGEUP
@ SCANCODE_PAGEUP
Definition SerialWombatPS2Keyboard.h:100
SCANCODE_KPPERIOD
@ SCANCODE_KPPERIOD
Definition SerialWombatPS2Keyboard.h:116
SCANCODE_LEFTALT
@ SCANCODE_LEFTALT
Definition SerialWombatPS2Keyboard.h:89
SCANCODE_C
@ SCANCODE_C
Definition SerialWombatPS2Keyboard.h:79
SCANCODE_N
@ SCANCODE_N
Definition SerialWombatPS2Keyboard.h:82
SCANCODE_EQUALS
@ SCANCODE_EQUALS
Definition SerialWombatPS2Keyboard.h:49
SCANCODE_X
@ SCANCODE_X
Definition SerialWombatPS2Keyboard.h:78
SCANCODE_SCROLLLOCK
@ SCANCODE_SCROLLLOCK
Definition SerialWombatPS2Keyboard.h:134
SCANCODE_LEFTCTRL
@ SCANCODE_LEFTCTRL
Definition SerialWombatPS2Keyboard.h:88
SCANCODE_0
@ SCANCODE_0
Definition SerialWombatPS2Keyboard.h:47
SCANCODE_LEFTARROW
@ SCANCODE_LEFTARROW
Definition SerialWombatPS2Keyboard.h:95
SCANCODE_RIGHTARROW
@ SCANCODE_RIGHTARROW
Definition SerialWombatPS2Keyboard.h:102
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition SerialWombat.h:313
SerialWombatPS2Keyboard::peek
int peek()
Query the SerialWombatPS2Keyboard queue for the next avaialble byte, but don't remove it from the que...
Definition SerialWombatPS2Keyboard.h:280
SerialWombatPS2Keyboard::isKeyPressed
bool isKeyPressed(uint8_t scanCode)
Check to see if a key is currently pressed (pin mode must be configured for bitfield mode)
Definition SerialWombatPS2Keyboard.h:582
SerialWombatPS2Keyboard::readCurrentScanCodes
int16_t readCurrentScanCodes(uint8_t *buffer, uint8_t startValue)
Definition SerialWombatPS2Keyboard.h:388
SerialWombatPS2Keyboard::timeout
uint32_t timeout
Definition SerialWombatPS2Keyboard.h:608
SerialWombatPS2Keyboard::write
size_t write(uint8_t data)
Write a byte to the SerialWombatPS2Keyboard queue (Does Nothing)
Definition SerialWombatPS2Keyboard.h:302
SerialWombatPS2Keyboard::available
int available()
Queries the SerialWombatPS2Keyboard for number bytes available to read.
Definition SerialWombatPS2Keyboard.h:239
SerialWombatPS2Keyboard::write
size_t write(const uint8_t *buffer, size_t size)
Write bytes to the SerialWombatPS2Keyboard queue (Does nothing)
Definition SerialWombatPS2Keyboard.h:317
SerialWombatPS2Keyboard::read
int read()
Reads a byte from the SerialWombatPS2Keyboard queue.
Definition SerialWombatPS2Keyboard.h:250
SerialWombatPS2Keyboard::setTimeout
void setTimeout(long timeout_mS)
implemented to fulfill Stream requirement.
Definition SerialWombatPS2Keyboard.h:414
SerialWombatPS2Keyboard::_pin
uint8_t _pin
Definition SerialWombatPS2Keyboard.h:606
SerialWombatPS2Keyboard::isKeyPressed
bool isKeyPressed(PS2KeyboardScanCode scanCode)
Definition SerialWombatPS2Keyboard.h:601
SerialWombatPS2Keyboard::readBytes
size_t readBytes(char *buffer, size_t length)
Reads a specified number of bytes from the SerialWombatPS2Keyboard queue queue.
Definition SerialWombatPS2Keyboard.h:342
SerialWombatPS2Keyboard::availableForWrite
int availableForWrite()
Number of bytes avaialble to write to SerialWombatPS2Keyboard queue. Returns 0.
Definition SerialWombatPS2Keyboard.h:327
SerialWombatPS2Keyboard::flush
void flush()
Discard all bytes from the SerialWombatPS2Keyboard queue.
Definition SerialWombatPS2Keyboard.h:271
SerialWombatPS2Keyboard::scanCodeToAscii
uint8_t scanCodeToAscii(uint8_t scanCode, bool shiftActive=false)
convernts a set 2 Scan Code to Ascii
Definition SerialWombatPS2Keyboard.h:429
SerialWombatPS2Keyboard::SerialWombatPS2Keyboard
SerialWombatPS2Keyboard(SerialWombatChip &serialWombat)
Constructor for the SerialWombatPS2Keyboard class.
Definition SerialWombatPS2Keyboard.h:189
SerialWombatPS2Keyboard::begin
int16_t begin(uint8_t clockPin, uint8_t dataPin, uint8_t bufferMode=0, uint8_t queueMode=0, uint16_t queueAddress=0xFFFF, uint8_t pullUpDown=0)
Initalize the SerialWombatPS2Keyboard.
Definition SerialWombatPS2Keyboard.h:199
SerialWombatPin::_sw
SerialWombatChip & _sw
Definition SerialWombatPin.h:214
SerialWombatPin::SerialWombatPin
SerialWombatPin(SerialWombatChip &serialWombatChip)
Instantiates a Serial Wombat Pin.
Definition SerialWombatPin.h:45
SerialWombatPin::_pinMode
uint8_t _pinMode
Definition SerialWombatPin.h:215