From 06d5200c445ac0372d6ad1ddc4cc6420de8e3400 Mon Sep 17 00:00:00 2001 From: Diego Roversi Date: Sat, 18 Nov 2017 10:39:32 +0100 Subject: Use add_key instead of duplicate code (part 2) --- TERES-HID/KeyboardMouse.c | 60 ++++++++--------------------------------------- 1 file 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; -- cgit v1.2.3