1
0
mirror of https://bitbucket.org/C_Classic/prgkbd.git synced 2024-11-22 10:15:06 +01:00

Added code to detect the keytype

This commit is contained in:
Markus Koch 2013-08-13 14:19:18 +02:00
parent afad66d3be
commit c90f7aee73

View File

@ -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! */