diff --git a/firmware/keyboard.c b/firmware/keyboard.c index 755a631..df495af 100644 --- a/firmware/keyboard.c +++ b/firmware/keyboard.c @@ -17,6 +17,11 @@ uint8_t oldKey=0; uint8_t hasReleased=0; uint8_t flag_keyPress=0; +uint8_t keyType[16]; // Will contain whether the key has to be handled as a ... +#define KEYTYPE_TEXT 0 // Text-Button (-> only button presses) or whether we need to pay attention to +#define KEYTYPE_KEY 1 // push and release events + + // MEMORY ARCHITECTURE (INTERNAL) #define MEM_SERIAL_OFFSET 0 #define MEM_SERIAL_LENGTH 16 @@ -323,6 +328,25 @@ void keyboard(void) { EEOpen(); // We open our eeprom uchar i; + // First, we scan through the codes so we can determine the key types. + { + uint8_t keyId, x; + for (keyId=0;keyId < 16; ++keyId) { + for (x=0; x < MEM_KEY_LENGTH; ++x) { + uint8_t instr = EEReadByte(keyId*MEM_KEY_LENGTH+x); + if (instr == INSTR_KEYPRESS) { // If KEYPRESS is used at any time, it is a text-command + keyType[keyId] = KEYTYPE_TEXT; + break; + } + else if (instr == INSTR_BREAK) { // If only KEYDOWN and KEYUP are used KEYDOWN it is a standard key + keyType[keyId] = KEYTYPE_KEY; + break; + } + } + } + } + + cli(); usbInit(); usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */