diff options
-rw-r--r-- | TERES-HID/KeyboardMouse.c | 74 |
1 files changed, 15 insertions, 59 deletions
diff --git a/TERES-HID/KeyboardMouse.c b/TERES-HID/KeyboardMouse.c index 5327834..4c3fdec 100644 --- a/TERES-HID/KeyboardMouse.c +++ b/TERES-HID/KeyboardMouse.c @@ -367,64 +367,38 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t * fn = 112; // tp_guarder(); if (PINB & 0x01) { - KeyboardReport->KeyCode[keyc] = - HID_KEYBOARD_SC_PAGE_UP; - if (keyc < 5) - keyc++; + add_key(KeyboardReport, HID_KEYBOARD_SC_PAGE_UP); } if (PINB & 0x02) { KeyboardReport->Modifier |= - HID_KEYBOARD_MODIFIER_LEFTSHIFT; - KeyboardReport->KeyCode[keyc] = - HID_KEYBOARD_SC_LEFT_SHIFT; - if (keyc < 5) - keyc++; + HID_KEYBOARD_MODIFIER_LEFTSHIFT; + add_key(KeyboardReport,HID_KEYBOARD_SC_LEFT_SHIFT); } if (PINB & 0x20) { - KeyboardReport->KeyCode[keyc] = - HID_KEYBOARD_SC_HOME; - if (keyc < 5) - keyc++; + add_key(KeyboardReport,HID_KEYBOARD_SC_HOME); } if (PINB & 0x80) { KeyboardReport->Modifier |= HID_KEYBOARD_MODIFIER_RIGHTSHIFT; - KeyboardReport->KeyCode[keyc] = - HID_KEYBOARD_SC_RIGHT_SHIFT; - if (keyc < 5) - keyc++; + add_key(KeyboardReport,HID_KEYBOARD_SC_RIGHT_SHIFT); } } else { if (PINB & 0x01) { - KeyboardReport->KeyCode[keyc] = - HID_KEYBOARD_SC_UP_ARROW; - if (keyc < 5) - keyc++; - // tp_guarder(); + add_key(KeyboardReport,HID_KEYBOARD_SC_UP_ARROW); } if (PINB & 0x02) { KeyboardReport->Modifier |= HID_KEYBOARD_MODIFIER_LEFTSHIFT; - KeyboardReport->KeyCode[keyc] = - HID_KEYBOARD_SC_LEFT_SHIFT; - if (keyc < 5) - keyc++; + add_key(KeyboardReport,HID_KEYBOARD_SC_LEFT_SHIFT); } if (PINB & 0x20) { - KeyboardReport->KeyCode[keyc] = - HID_KEYBOARD_SC_LEFT_ARROW; - if (keyc < 5) - keyc++; - // tp_guarder(); + add_key(KeyboardReport,HID_KEYBOARD_SC_LEFT_ARROW); } if (PINB & 0x80) { KeyboardReport->Modifier |= HID_KEYBOARD_MODIFIER_RIGHTSHIFT; - KeyboardReport->KeyCode[keyc] = - HID_KEYBOARD_SC_RIGHT_SHIFT; - if (keyc < 5) - keyc++; + add_key(KeyboardReport,HID_KEYBOARD_SC_RIGHT_SHIFT); } } @@ -438,27 +412,18 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t * if (PINB & 0x10) { KeyboardReport->Modifier |= HID_KEYBOARD_MODIFIER_RIGHTCTRL; - KeyboardReport->KeyCode[keyc] = - HID_KEYBOARD_SC_RIGHT_CONTROL; - if (keyc < 5) - keyc++; + add_key(KeyboardReport,HID_KEYBOARD_SC_RIGHT_CONTROL); } if (PINB & 0x40) { KeyboardReport->Modifier |= HID_KEYBOARD_MODIFIER_LEFTCTRL; - KeyboardReport->KeyCode[keyc] = - HID_KEYBOARD_SC_LEFT_CONTROL; - if (keyc < 5) - keyc++; + add_key(KeyboardReport,HID_KEYBOARD_SC_LEFT_CONTROL); } if (PINB & 0x08) { if (fn == 112) - KeyboardReport->KeyCode[keyc] = - HID_KEYBOARD_SC_VOLUME_UP; + add_key(KeyboardReport,HID_KEYBOARD_SC_VOLUME_UP); else - KeyboardReport->KeyCode[keyc] = HID_KEYBOARD_SC_F5; - if (keyc < 5) - keyc++; + add_key(KeyboardReport,HID_KEYBOARD_SC_F5); } PORTB = rowY[colmn]; @@ -478,23 +443,14 @@ 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] = - keys[colmn * 14 + x + fn]; - if (keyc < 5) - keyc++; - } + add_key(KeyboardReport,keynow); } x++; // 2 if ((PINC & (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++; // 3 // Delay_MS(5); |