diff --git a/physicalkeyboard.h b/physicalkeyboard.h index 01c4810..cd19c16 100644 --- a/physicalkeyboard.h +++ b/physicalkeyboard.h @@ -22,6 +22,9 @@ #define PK_LA 0x85 // left (open) apple, aka paddle0 button #define PK_RA 0x86 // right (closed) apple aka paddle1 button +#define PK_NONE 0xFF // not a key; but 0x00 is used internally by the + // library, and I don't want to harsh its buzz + class PhysicalKeyboard { public: PhysicalKeyboard(VMKeyboard *k) { this->vmkeyboard = k; } diff --git a/teensy/teensy-keyboard.cpp b/teensy/teensy-keyboard.cpp index 96b83f9..5f48936 100644 --- a/teensy/teensy-keyboard.cpp +++ b/teensy/teensy-keyboard.cpp @@ -13,8 +13,8 @@ char keys[ROWS][COLS] = { { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', PK_DEL }, { PK_ESC, 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']' }, { PK_CTRL, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', PK_RET }, - { PK_LSHFT, 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', PK_RSHFT, 0 }, - { PK_LOCK, '`', PK_TAB, '\\', PK_LA, ' ', PK_RA, PK_LARR, PK_RARR, PK_DARR, PK_UARR, 0, 0 } + { PK_LSHFT, 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', PK_RSHFT, PK_NONE }, + { PK_LOCK, '`', PK_TAB, '\\', PK_LA, ' ', PK_RA, PK_LARR, PK_RARR, PK_DARR, PK_UARR, PK_NONE, PK_NONE } }; uint8_t rowsPins[ROWS] = { 33, 34, 35, 36, 37 }; @@ -81,8 +81,8 @@ static uint8_t shiftedNumber[] = { '<', // , TeensyKeyboard::TeensyKeyboard(VMKeyboard *k) : PhysicalKeyboard(k) { - keypad.setDebounceTime(5); - + keypad.setDebounceTime(10); + leftShiftPressed = false; rightShiftPressed = false; ctrlPressed = false; @@ -100,7 +100,6 @@ TeensyKeyboard::~TeensyKeyboard() void TeensyKeyboard::pressedKey(uint8_t key) { numPressed++; - if (key & 0x80) { // it's a modifier key. switch (key) { @@ -124,6 +123,7 @@ void TeensyKeyboard::pressedKey(uint8_t key) rightApplePressed = 1; break; } + addEvent(key, true); return; } @@ -219,7 +219,7 @@ bool TeensyKeyboard::kbhit() { if (keypad.getKeys()) { for (int i=0; i