From 36fdbb4987182ba98d35d992706f17d6ca929516 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 19 Sep 2015 12:45:43 +0200 Subject: [PATCH] Minor fixes --- Readme.md | 12 ++++++++++-- src/HID-Project.h | 4 ++-- src/ImprovedKeyboard.cpp | 13 ++++++++++--- src/ImprovedKeyboard.h | 6 +++++- src/PluggableHID/HID.h | 1 - src/PluggableHID/HIDDevice.h | 6 +++--- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Readme.md b/Readme.md index 0a27b5a1..68c392a4 100644 --- a/Readme.md +++ b/Readme.md @@ -15,7 +15,8 @@ The idea is to enable enhanced USB functions to almost all 'standard' Arduino bo * Any other 8u2/16u/at90usb162/32u2/32u4 compatible board **Supported HID devices:** -* Keyboard ~~with Leds out (modifiers + 6 keys pressed at the same time)~~ +* Keyboard with Leds out (modifiers + 6 keys pressed at the same time) +* NKRO Keyboard with Leds out (press up to 113 keys at the same time) * Mouse (5 buttons, move, wheel) * Absolute Mouse * Consumer/Media Keys (4 keys for music player, web browser and more) @@ -78,8 +79,15 @@ Version History ``` 2.4 Release (xx.xx.2015) * Added Arduino IDE 1.6.6 compatibility with Pluggable HID +* Improved Pluggable HID (have its own modifed copy now) * Changed USB-Core into a simple library, only possible with Pluggable HID -* Removed HID presets (like mouse + keyboard + consumer + system) +* Removed HID presets in boards menu (like mouse + keyboard + consumer + system) +* Added Teensy Keyboard +* Added NKRO Keyboard +* Added Led report for Keyboard +* Added HID out report in general (RAW HID preparation) +* Added a few key definitions +* Uses .alinkage custom IDE option 2.3 Release (never released) * Updated Libraries diff --git a/src/HID-Project.h b/src/HID-Project.h index 009023b4..ed7d4605 100644 --- a/src/HID-Project.h +++ b/src/HID-Project.h @@ -33,6 +33,8 @@ THE SOFTWARE. #error "This is not an USB AVR or you use an old version of the IDE." #endif +#define HID_KEYBOARD_LEDS_ENABLED + //#define LAYOUT_US_ENGLISH //#define LAYOUT_CANADIAN_FRENCH //#define LAYOUT_CANADIAN_MULTILINGUAL @@ -104,8 +106,6 @@ THE SOFTWARE. #include "HID.h" -extern HID_ HID; - #include "HID-Tables.h" // Include all HID libraries (.a linkage required to work) properly diff --git a/src/ImprovedKeyboard.cpp b/src/ImprovedKeyboard.cpp index 680648aa..e53a3f34 100644 --- a/src/ImprovedKeyboard.cpp +++ b/src/ImprovedKeyboard.cpp @@ -50,7 +50,9 @@ static const u8 _hidReportDescriptor[] PROGMEM = { 0x95, 0x01, /* REPORT_COUNT (1) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x81, 0x03, /* INPUT (Cnst,Var,Abs) */ - + +#if defined(HID_KEYBOARD_LEDS_ENABLED) +//TODO remove reserved bytes to add 3 more custom data bits for advanced users? /* 5 LEDs for num lock etc */ 0x05, 0x08, /* USAGE_PAGE (LEDs) */ 0x19, 0x01, /* USAGE_MINIMUM (Num Lock) */ @@ -62,6 +64,7 @@ static const u8 _hidReportDescriptor[] PROGMEM = { 0x95, 0x01, /* REPORT_COUNT (1) */ 0x75, 0x03, /* REPORT_SIZE (3) */ 0x91, 0x03, /* OUTPUT (Cnst,Var,Abs) */ +#endif /* 6 Keyboard keys */ 0x95, 0x06, /* REPORT_COUNT (6) */ @@ -78,8 +81,10 @@ static const u8 _hidReportDescriptor[] PROGMEM = { }; Keyboard_::Keyboard_(void) : -HIDDevice((uint8_t*)_hidReportDescriptor, sizeof(_hidReportDescriptor), HID_REPORTID_KEYBOARD), -leds(0) +HIDDevice((uint8_t*)_hidReportDescriptor, sizeof(_hidReportDescriptor), HID_REPORTID_KEYBOARD) +#if defined(HID_KEYBOARD_LEDS_ENABLED) +,leds(0) +#endif { // HID Descriptor is appended via the inherited HIDDevice class } @@ -99,6 +104,7 @@ void Keyboard_::sendReport(HID_KeyboardReport_Data_t* keys) SendReport(keys,sizeof(HID_KeyboardReport_Data_t)); } +#if defined(HID_KEYBOARD_LEDS_ENABLED) void Keyboard_::setReportData(const void* data, int len){ // Save led state if(len == 1) @@ -108,6 +114,7 @@ void Keyboard_::setReportData(const void* data, int len){ uint8_t Keyboard_::getLeds(void){ return leds; } +#endif // press() adds the specified key (printing, non-printing, or modifier) diff --git a/src/ImprovedKeyboard.h b/src/ImprovedKeyboard.h index 49d6cc58..6a46cc82 100644 --- a/src/ImprovedKeyboard.h +++ b/src/ImprovedKeyboard.h @@ -57,8 +57,10 @@ class Keyboard_ : public Print, public HIDDevice private: HID_KeyboardReport_Data_t _keyReport; void sendReport(HID_KeyboardReport_Data_t* keys); +#if defined(HID_KEYBOARD_LEDS_ENABLED) virtual void setReportData(const void* data, int len); uint8_t leds; +#endif public: Keyboard_(void); void begin(void); @@ -73,8 +75,10 @@ class Keyboard_ : public Print, public HIDDevice size_t releaseKeycode(uint8_t k); size_t addKeycodeToReport(uint8_t k); size_t removeKeycodeFromReport(uint8_t k); - + +#if defined(HID_KEYBOARD_LEDS_ENABLED) uint8_t getLeds(void); +#endif }; extern Keyboard_ Keyboard; diff --git a/src/PluggableHID/HID.h b/src/PluggableHID/HID.h index 8b1c1502..e15c858e 100644 --- a/src/PluggableHID/HID.h +++ b/src/PluggableHID/HID.h @@ -23,7 +23,6 @@ #define HID_h -#include #include #if defined(USBCON) diff --git a/src/PluggableHID/HIDDevice.h b/src/PluggableHID/HIDDevice.h index 54d68040..6d438668 100644 --- a/src/PluggableHID/HIDDevice.h +++ b/src/PluggableHID/HIDDevice.h @@ -49,9 +49,9 @@ class HIDDevice const uint8_t reportID; virtual void setReportData(const void* data, int len); - -protected: - // TODO make this public for custom, professional usage? + + // Public for custom, professional usage, like raw Keyboard +//protected: void SendReport(const void* data, int len); };