diff options
Diffstat (limited to 'TERES-HID/KeyboardMouse.c')
-rw-r--r-- | TERES-HID/KeyboardMouse.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/TERES-HID/KeyboardMouse.c b/TERES-HID/KeyboardMouse.c index f0ed997..5327834 100644 --- a/TERES-HID/KeyboardMouse.c +++ b/TERES-HID/KeyboardMouse.c @@ -283,6 +283,27 @@ EVENT_USB_Device_StartOfFrame(void) HID_Device_MillisecondElapsed(&Mouse_HID_Interface); } +void +reset_key(USB_KeyboardReport_Data_t *report) +{ + keyc = 0; + report->Modifier = 0; + + for (int x = 0; x < 6; x++) + report->KeyCode[x] = 0; +} + +void +add_key(USB_KeyboardReport_Data_t * report, uint8_t key) +{ + if (key == 0) + return; + report->KeyCode[keyc] = key; + if (keyc < 5) + keyc++; +} + + /** HID class driver callback function for the creation of HID reports to the host. * * \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced @@ -312,12 +333,7 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t * uint8_t x = 0; uint8_t fn = 0; - keyc = 0; // reset keys - KeyboardReport->Modifier = 0; - - for (x = 0; x < 6; x++) - KeyboardReport->KeyCode[x] = 0; - + reset_key( KeyboardReport ); if (itsDone) { itsDone = false; @@ -607,6 +623,7 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t * *ReportSize = sizeof(USB_KeyboardReport_Data_t); return true; // return false; } + if (HIDInterfaceInfo == &Mouse_HID_Interface) { USB_WheelMouseReport_Data_t *MouseReport = (USB_WheelMouseReport_Data_t *) ReportData; @@ -723,6 +740,8 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t * *ReportSize = sizeof(USB_WheelMouseReport_Data_t); return true; } + + return false; } @@ -766,6 +785,8 @@ ISR(ADC_vect) mouse = 0; } else oldbutton = button; + + mouse=0; // temporary fix: disable button } |