Hi there!
So I've been mucking around with an old ps2 Keyboard using the PS/2 Library.
By now, I'm calling keyboard.read() to get an ascii code of the key that I'm pressing on the ps/2 keyboard. This is working perfectly fine.
The problem that I have is that I just can't receive a "key up" or a "key break" signal.
Something so that I could see if the key has been let go...
Is this even possible with the library?
In the keywords.txt of the library, I found this line:
PS2_KC_BREAK LITERAL1
though, when I try to implement it into the code, I just get the error message:
"ps2Keyboard_2.ino:41:14: error: 'PS2_KC_BREAK' was not declared in this scope
Error compiling."
Here's a shortened version of the code:
(For background information on what the scetch should do: I'm trying to receive keyboard input from the ps2 keyboard. I'll then flash the arduino like this, so that it will appear as a standard usb keyboard, thus enabling me to interact with the keyboard input...
#include <PS2Keyboard.h>
const int DataPin = 2; // Yellow wire
const int IRQpin = 3; // Green wire
uint8_t buf[8] = {0};
PS2Keyboard keyboard;
void setup() {
delay(1000);
keyboard.begin(DataPin, IRQpin, PS2Keymap_German);
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(servicePin, INPUT);
}
void loop() {
if (keyboard.available()) {
char c = keyboard.read();
///// WASD Control
if (c == 'a' || c == 'A') pressKey(4);
if (c == 'b' || c == 'B') pressKey(5);
if (c == 'd' || c == 'D') pressKey(7);
if (c == 'w' || c == 'W') pressKey(26);
if (c == 's' || c == 'S') pressKey(22);
////// Special Keys
if (c == PS2_ESC) pressKey(41);
////// Arrows
if (c == PS2_LEFTARROW) pressKey(92);
if (c == PS2_RIGHTARROW) pressKey(94);
if (c == PS2_UPARROW) pressKey(96);
if (c == PS2_DOWNARROW) pressKey(90);
////Release the key
if (c == PS2_KC_BREAK) releaseKey();
}
}
void pressKey(int key) {
buf[2] = key;
Serial.write(buf, 8);
}
void releaseKey() {
//Serial.println();
buf[0] = 0;
buf[2] = 0;
Serial.write(buf, 8); // Release key
}