summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Roversi <diegor@tiscali.it>2017-11-18 10:39:32 +0100
committerDiego Roversi <diegor@tiscali.it>2017-11-18 10:39:32 +0100
commit06d5200c445ac0372d6ad1ddc4cc6420de8e3400 (patch)
tree9198890f896624ef425f3b7c23e4ce112b6ee353
parent6e0444390a4281872824b7cf6bad232a35f8345e (diff)
Use add_key instead of duplicate code (part 2)
-rw-r--r--TERES-HID/KeyboardMouse.c60
1 files changed, 10 insertions, 50 deletions
diff --git a/TERES-HID/KeyboardMouse.c b/TERES-HID/KeyboardMouse.c
index 4c3fdec..aec2e21 100644
--- a/TERES-HID/KeyboardMouse.c
+++ b/TERES-HID/KeyboardMouse.c
@@ -463,11 +463,7 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
TouchPadLocked = !TouchPadLocked;
while ((PIND & (1 << 7)) == 0);
}
- if (keynow != 0) {
- KeyboardReport->KeyCode[keyc] = keynow;
- if (keyc < 5)
- keyc++;
- }
+ add_key(KeyboardReport,keynow);
}
x++; // 4
// Delay_MS(5);
@@ -475,99 +471,63 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- if (keynow != 0) {
- KeyboardReport->KeyCode[keyc] = keynow;
- if (keyc < 5)
- keyc++;
- }
+ add_key(KeyboardReport,keynow);
}
x++; // 5
if ((PINF & (1 << 1)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- if (keynow != 0) {
- KeyboardReport->KeyCode[keyc] = keynow;
- if (keyc < 5)
- keyc++;
- }
+ add_key(KeyboardReport,keynow);
}
x++; // 6
if ((PINF & (1 << 6)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- if (keynow != 0) {
- KeyboardReport->KeyCode[keyc] = keynow;
- if (keyc < 5)
- keyc++;
- }
+ add_key(KeyboardReport,keynow);
}
x++; // 7
if ((PINE & (1 << 6)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- if (keynow != 0) {
- KeyboardReport->KeyCode[keyc] = keynow;
- if (keyc < 5)
- keyc++;
- }
+ add_key(KeyboardReport,keynow);
}
x++; // 8
if ((PINF & (1 << 4)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- if (keynow != 0) {
- KeyboardReport->KeyCode[keyc] = keynow;
- if (keyc < 5)
- keyc++;
- }
+ add_key(KeyboardReport,keynow);
}
x++; // 9
if ((PIND & (1 << 5)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- if (keynow != 0) {
- KeyboardReport->KeyCode[keyc] = keynow;
- if (keyc < 5)
- keyc++;
- }
+ add_key(KeyboardReport,keynow);
}
x++; // 10
if ((PINF & (1 << 5)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- if (keynow != 0) {
- KeyboardReport->KeyCode[keyc] = keynow;
- if (keyc < 5)
- keyc++;
- }
+ add_key(KeyboardReport,keynow);
}
x++; // 11
if ((PINF & (1 << 7)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- if (keynow != 0) {
- KeyboardReport->KeyCode[keyc] = keynow;
- if (keyc < 5)
- keyc++;
- }
+ add_key(KeyboardReport,keynow);
}
x++; // 12
if ((PINE & (1 << 2)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- if (keynow != 0) {
- KeyboardReport->KeyCode[keyc] = keynow;
- if (keyc < 5)
- keyc++;
- }
+ add_key(KeyboardReport,keynow);
}
DDRD = 0;
PORTD = 0xfc;