diff options
author | Diego Roversi <diegor@tiscali.it> | 2017-11-18 09:29:45 +0100 |
---|---|---|
committer | Diego Roversi <diegor@tiscali.it> | 2017-11-18 09:29:45 +0100 |
commit | a0e455654fb92b0e6ea39bb101fea7dfbeba26c5 (patch) | |
tree | 26a11833bfc42092ebb81bff945c03116010c0fa /TERES-HID/KeyboardMouse.c | |
parent | 2f9acf73f09e5dc0bbb271f5269a2b58334e0e1e (diff) |
Add reset_key and add_key, to remove duplicated code. Disable touchpad button, to avoid problem with fault button.
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 } |