Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoHood committed Sep 19, 2015
1 parent f34df6e commit 36fdbb4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
12 changes: 10 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/HID-Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions src/ImprovedKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand All @@ -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) */
Expand All @@ -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
}
Expand All @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion src/ImprovedKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

Expand Down
1 change: 0 additions & 1 deletion src/PluggableHID/HID.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#define HID_h

#include <stdint.h>
#include <Arduino.h>

#if defined(USBCON)
Expand Down
6 changes: 3 additions & 3 deletions src/PluggableHID/HIDDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down

0 comments on commit 36fdbb4

Please sign in to comment.