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 | |
| parent | 2f9acf73f09e5dc0bbb271f5269a2b58334e0e1e (diff) | |
Add reset_key and add_key, to remove duplicated code. Disable touchpad button, to avoid problem with fault button.
| -rw-r--r-- | TERES-HID/Descriptors.c | 2 | ||||
| -rw-r--r-- | TERES-HID/KeyboardMouse.c | 33 | 
2 files changed, 28 insertions, 7 deletions
| diff --git a/TERES-HID/Descriptors.c b/TERES-HID/Descriptors.c index c91e2e0..213e230 100644 --- a/TERES-HID/Descriptors.c +++ b/TERES-HID/Descriptors.c @@ -238,7 +238,7 @@ USB_STRING_DESCRIPTOR(L"Olimex Ltd.");   *  Descriptor.   */  const USB_Descriptor_String_t PROGMEM ProductString = -USB_STRING_DESCRIPTOR(L"TERES Keyboard+Touchpad"); +USB_STRING_DESCRIPTOR(L"TERES Keyboard+Touchpad (drv)");  /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"   *  documentation) by the application code so that the address and size of a requested descriptor can be given 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  } | 
