Moved Keyboard Led Out Report to HID Core
Saves some more flash and is better accessible.
This commit is contained in:
parent
66028b983b
commit
ed42b436c3
4 changed files with 10 additions and 24 deletions
|
|
@ -57,6 +57,10 @@ const HIDDescriptor _hidInterface =
|
|||
D_ENDPOINT(USB_ENDPOINT_IN(HID_ENDPOINT_INT), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01)
|
||||
};
|
||||
|
||||
#if defined(HID_KEYBOARD_LEDS_ENABLED)
|
||||
uint8_t hid_keyboard_leds = 0;
|
||||
#endif
|
||||
|
||||
//================================================================================
|
||||
//================================================================================
|
||||
// Driver
|
||||
|
|
@ -122,7 +126,7 @@ bool WEAK HID_Setup(Setup& setup)
|
|||
// write led out report data
|
||||
uint8_t data[2];
|
||||
if (2 == USB_RecvControl(data, 2))
|
||||
HID_SetKeyboardLedReport(data[1]);
|
||||
hid_keyboard_leds = data[1];
|
||||
}
|
||||
// else TODO check for other devices like RAW HID, not needed for now
|
||||
}
|
||||
|
|
@ -131,13 +135,6 @@ bool WEAK HID_Setup(Setup& setup)
|
|||
return false;
|
||||
}
|
||||
|
||||
#if defined(HID_KEYBOARD_LEDS_ENABLED)
|
||||
void WEAK HID_SetKeyboardLedReport(uint8_t leds){
|
||||
// weak function implemented by the Keyboard API
|
||||
// to not always create the Keyboard object, if it isn't used
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#else /* if defined(USBCON) */
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#define HID_KEYBOARD_LEDS_ENABLED
|
||||
#endif
|
||||
|
||||
// extern accessible led out report
|
||||
#if defined(HID_KEYBOARD_LEDS_ENABLED)
|
||||
extern uint8_t hid_keyboard_leds;
|
||||
#endif
|
||||
|
||||
// HID report IDs
|
||||
// note by NicoHood: I would not change the current IDs, since it can confuse the OS
|
||||
// I had several problems if i change the report id and its use.
|
||||
|
|
@ -322,9 +327,6 @@ int HID_GetInterface(uint8_t* interfaceNum);
|
|||
int HID_GetDescriptor(int i);
|
||||
bool HID_Setup(Setup& setup);
|
||||
void HID_SendReport(uint8_t id, const void* data, int len);
|
||||
#if defined(HID_KEYBOARD_LEDS_ENABLED)
|
||||
void HID_SetKeyboardLedReport(uint8_t leds);
|
||||
#endif
|
||||
|
||||
#else /* if defined(USBCON) */
|
||||
|
||||
|
|
|
|||
|
|
@ -23,14 +23,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
//================================================================================
|
||||
// Keyboard
|
||||
|
||||
#if defined(HID_KEYBOARD_LEDS_ENABLED)
|
||||
uint8_t hid_keyboard_leds = 0;
|
||||
void HID_SetKeyboardLedReport(uint8_t leds){
|
||||
// implementation of the weak function in HID.cpp
|
||||
hid_keyboard_leds = leds;
|
||||
}
|
||||
#endif
|
||||
|
||||
Keyboard_ Keyboard;
|
||||
|
||||
void Keyboard_::sendReport(KeyReport* keys)
|
||||
|
|
|
|||
|
|
@ -131,11 +131,6 @@ typedef struct
|
|||
uint8_t keys[6];
|
||||
} KeyReport;
|
||||
|
||||
// extern accessible led out report
|
||||
#if defined(HID_KEYBOARD_LEDS_ENABLED)
|
||||
extern uint8_t hid_keyboard_leds;
|
||||
#endif
|
||||
|
||||
class Keyboard_ : public Print
|
||||
{
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Reference in a new issue