diff --git a/Readme.md b/Readme.md index bf69280..5cf7295 100644 --- a/Readme.md +++ b/Readme.md @@ -46,6 +46,7 @@ Make sure you use Arduino IDE 1.5.8 or newer. You don't have to modify the origi At the moment you have to move the cores/hid folder into your Arduino installation *arduino-1.6.0/hardware/arduino/avr/cores/hid* because of a bug in the IDE. +![HID Folder Picture](hid-core.png) **Your sketchbook folder should look like this:** ![Installation Picture](installation.png) @@ -208,6 +209,7 @@ Version History * Added Keycode functions in Keyboard API * Inlined a lot of the HID API functions to save flash * Added Gamepad +* Added RawHID API (but RawHID itself isnt working still) * Added USB Wakeup support * Separated USB-Core in its own folder * Added HID Tables diff --git a/avr/boards.txt b/avr/boards.txt index d03c595..43f101d 100644 --- a/avr/boards.txt +++ b/avr/boards.txt @@ -100,4 +100,70 @@ microExtended.menu.usbcore.NO_USB=No USB functions microExtended.menu.usbcore.NO_USB.build.variant=micro_no_usb microExtended.menu.usbcore.NO_USB.build.core=arduino:hid -############################################################## \ No newline at end of file +############################################################## + +uno.name=Arduino Uno HID-Project + +uno.vid.0=0x2341 +uno.pid.0=0x0043 +uno.vid.1=0x2341 +uno.pid.1=0x0001 + +uno.upload.tool=arduino:avrdude +uno.upload.protocol=arduino +uno.upload.maximum_size=32256 +uno.upload.maximum_data_size=2048 +uno.upload.speed=115200 + +uno.bootloader.tool=arduino:avrdude +uno.bootloader.low_fuses=0xFF +uno.bootloader.high_fuses=0xDE +uno.bootloader.extended_fuses=0x05 +uno.bootloader.unlock_bits=0x3F +uno.bootloader.lock_bits=0x0F +uno.bootloader.file=arduino:optiboot/optiboot_atmega328.hex + +uno.build.mcu=atmega328p +uno.build.f_cpu=16000000L +uno.build.board=AVR_UNO +uno.build.core=arduino:hid +uno.build.variant=arduino:standard + +############################################################## + + +mega.name=Arduino Mega 2560 HID-Project + +mega.vid.0=0x2341 +mega.pid.0=0x0010 +mega.vid.1=0x2341 +mega.pid.1=0x0042 + +mega.upload.tool=arduino:avrdude +mega.upload.maximum_data_size=8192 + +mega.bootloader.tool=arduino:avrdude +mega.bootloader.low_fuses=0xFF +mega.bootloader.unlock_bits=0x3F +mega.bootloader.lock_bits=0x0F + +mega.build.f_cpu=16000000L +mega.build.core=arduino:hid +mega.build.variant=arduino:mega +# default board may be overridden by the cpu menu +mega.build.board=AVR_MEGA2560 + +## Arduino Mega w/ ATmega2560 +## ------------------------- + +mega.upload.protocol=wiring +mega.upload.maximum_size=253952 +mega.upload.speed=115200 + +mega.bootloader.high_fuses=0xD8 +mega.bootloader.extended_fuses=0xFD +mega.bootloader.file=arduino:stk500v2/stk500boot_v2_mega2560.hex + +mega.build.mcu=atmega2560 +mega.build.board=AVR_MEGA2560 + diff --git a/avr/cores/hid/USB-Core/HID.cpp b/avr/cores/hid/USB-Core/HID.cpp index 587c016..dac5d61 100644 --- a/avr/cores/hid/USB-Core/HID.cpp +++ b/avr/cores/hid/USB-Core/HID.cpp @@ -54,7 +54,30 @@ const u8 _hidReportDescriptor[] = { #ifdef EXTERN_HID_REPORT EXTERN_HID_REPORT #else - DEFAULT_HID_REPORT + // use the hid descriptors of the selected hid devices +#ifdef HID_KEYBOARD_LEDS_ENABLE //TODO move keyboard below mouse? + HID_REPORT_KEYBOARD_LEDS(HID_REPORTID_KEYBOARD), +#elif defined(HID_KEYBOARD_KEYS_ENABLE) + HID_REPORT_KEYBOARD_KEYS(HID_REPORTID_KEYBOARD), +#endif +#if defined(HID_MOUSE_ENABLE) + HID_REPORT_MOUSE(HID_REPORTID_MOUSE), +#endif +#if defined(HID_MOUSE_ABSOLUTE_ENABLE) + HID_REPORT_MOUSE_ABSOLUTE(HID_REPORTID_MOUSE_ABSOLUTE), +#endif +#ifdef HID_RAWHID_ENABLE + HID_REPORT_RAWHID(HID_REPORTID_RAWHID), // not working at the moment +#endif +#ifdef HID_CONSUMER_ENABLE + HID_REPORT_CONSUMERCONTROL(HID_REPORTID_CONSUMERCONTROL), +#endif +#ifdef HID_SYSTEM_ENABLE + HID_REPORT_SYSTEMCONTROL(HID_REPORTID_SYSTEMCONTROL), +#endif +#ifdef HID_GAMEPAD_ENABLE + HID_REPORT_GAMEPAD(HID_REPORTID_GAMEPAD), +#endif #endif }; diff --git a/avr/cores/hid/USB-Core/HID.h b/avr/cores/hid/USB-Core/HID.h index 79a3fbe..020f2ec 100644 --- a/avr/cores/hid/USB-Core/HID.h +++ b/avr/cores/hid/USB-Core/HID.h @@ -48,6 +48,36 @@ THE SOFTWARE. // for the extern HID descriptors + settings #include "pins_arduino.h" +#ifndef EXTERN_HID_REPORT +// by default enable mouse + keyboard api +#define HID_MOUSE_ENABLE +#define HID_KEYBOARD_KEYS_ENABLE +#endif + +#ifdef HID_KEYBOARD_LEDS_ENABLE +// enable the Keyboard Led functions if the led report is selected +#define HID_KEYBOARD_LEDS_ENABLED +#endif + +#if defined(HID_MOUSE_ENABLE) || defined(HID_MOUSE_ABSOLUTE_ENABLE) +#define HID_MOUSE_API_ENABLE +#endif +#if defined(HID_KEYBOARD_LEDS_ENABLE) || defined(HID_KEYBOARD_KEYS_ENABLE) +#define HID_KEYBOARD_API_ENABLE +#endif +#ifdef HID_RAWHID_ENABLE +#define HID_RAWHID_API_ENABLE +#endif +#ifdef HID_CONSUMER_ENABLE +#define HID_CONSUMER_API_ENABLE +#endif +#ifdef HID_SYSTEM_ENABLE +#define HID_SYSTEM_API_ENABLE +#endif +#ifdef HID_GAMEPAD_ENABLE +#define HID_GAMEPAD_API_ENABLE +#endif + // extern accessible led out report #if defined(HID_KEYBOARD_LEDS_ENABLED) extern uint8_t hid_keyboard_leds; @@ -302,10 +332,18 @@ extern uint8_t hid_keyboard_leds; // note by NicoHood: RawHID might never work with multireports, because of OS problems // therefore we have to make it a single report with no idea. No other HID device will be supported then. +#ifndef RAWHID_USAGE_PAGE #define RAWHID_USAGE_PAGE 0xFFC0 // recommended: 0xFF00 to 0xFFFF +#endif +#ifndef RAWHID_USAGE #define RAWHID_USAGE 0x0C00 // recommended: 0x0100 to 0xFFFF +#endif +#ifndef RAWHID_TX_SIZE #define RAWHID_TX_SIZE (USB_EP_SIZE-1) +#endif +#ifndef RAWHID_RX_SIZE #define RAWHID_RX_SIZE (USB_EP_SIZE-1) +#endif #define LSB(_x) ((_x) & 0xFF) #define MSB(_x) ((_x) >> 8) @@ -331,18 +369,6 @@ extern uint8_t hid_keyboard_leds; 0xC0 /* end collection */ #endif -// default HID report descriptor -#ifdef HID_KEYBOARD_LEDS_ENABLED -#define DEFAULT_HID_REPORT \ -HID_REPORT_KEYBOARD_LEDS(HID_REPORTID_KEYBOARD), \ -HID_REPORT_MOUSE(HID_REPORTID_MOUSE) - -#else -#define DEFAULT_HID_REPORT \ -HID_REPORT_KEYBOARD_KEYS(HID_REPORTID_KEYBOARD), \ -HID_REPORT_MOUSE(HID_REPORTID_MOUSE) -#endif - #if defined(USBCON) #include "USBDesc.h" @@ -375,14 +401,10 @@ void HID_SendReport(uint8_t id, const void* data, int len); // include all HID APIs #define HID_MOUSE_API_ENABLE #define HID_KEYBOARD_API_ENABLE +#define HID_RAWHID_API_ENABLE #define HID_CONSUMER_API_ENABLE #define HID_SYSTEM_API_ENABLE #define HID_GAMEPAD_API_ENABLE - -#elif !defined(EXTERN_HID_REPORT) -// by default enable mouse + keyboard api -#define HID_MOUSE_API_ENABLE -#define HID_KEYBOARD_API_ENABLE #endif #ifdef USBCON @@ -395,6 +417,10 @@ void HID_SendReport(uint8_t id, const void* data, int len); #include "Keyboard.h" #endif +#ifdef HID_RAWHID_API_ENABLE +#include "RawHID.h" +#endif + #ifdef HID_CONSUMER_API_ENABLE #include "Consumer.h" #endif diff --git a/avr/cores/hid/USB-Core/Keyboard.h b/avr/cores/hid/USB-Core/Keyboard.h index 5f405a5..1bf159d 100644 --- a/avr/cores/hid/USB-Core/Keyboard.h +++ b/avr/cores/hid/USB-Core/Keyboard.h @@ -143,13 +143,25 @@ THE SOFTWARE. #define RAW_KEYBOARD_SCROLL_LOCK 0x47 #define RAW_KEYBOARD_PAUSE 0x48 +typedef union{ + // Low level key report: up to 6 keys and shift, ctrl etc at once + uint8_t whole8[8]; + uint16_t whole16[8 / 2]; + uint32_t whole32[8 / 4]; + struct{ + uint8_t modifiers; + uint8_t reserved; + uint8_t keys[6]; + }; +} HID_KeyboardReport_Data_t; + // Low level key report: up to 6 keys and shift, ctrl etc at once typedef struct { uint8_t modifiers; uint8_t reserved; uint8_t keys[6]; -} KeyReport; +} KeyReport; //TODO typedef union above class Keyboard_ : public Print { diff --git a/avr/cores/hid/USB-Core/Mouse.h b/avr/cores/hid/USB-Core/Mouse.h index 05e48c9..ce57999 100644 --- a/avr/cores/hid/USB-Core/Mouse.h +++ b/avr/cores/hid/USB-Core/Mouse.h @@ -59,6 +59,19 @@ THE SOFTWARE. // but the last 3 wont do anything from what I tested #define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE | MOUSE_PREV | MOUSE_NEXT) +typedef union{ + // mouse report: 8 buttons, position, wheel + uint8_t whole8[4]; + uint16_t whole16[4 / 2]; + uint32_t whole32[4 / 4]; + struct{ + uint8_t buttons; + int8_t xAxis; + int8_t yAxis; + int8_t wheel; + }; +} HID_MouseReport_Data_t; + class Mouse_ { private: diff --git a/avr/cores/hid/USB-Core/RawHID.cpp b/avr/cores/hid/USB-Core/RawHID.cpp new file mode 100644 index 0000000..b5a1687 --- /dev/null +++ b/avr/cores/hid/USB-Core/RawHID.cpp @@ -0,0 +1,30 @@ +/* +Copyright (c) 2014 NicoHood +See the readme for credit to other people. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "RawHID.h" + +//================================================================================ +// RawHID +//================================================================================ + +RawHID_ RawHID; \ No newline at end of file diff --git a/avr/cores/hid/USB-Core/RawHID.h b/avr/cores/hid/USB-Core/RawHID.h new file mode 100644 index 0000000..bd31630 --- /dev/null +++ b/avr/cores/hid/USB-Core/RawHID.h @@ -0,0 +1,79 @@ +/* +Copyright (c) 2014 NicoHood +See the readme for credit to other people. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef __RAWHIDAPI__ +#define __RAWHIDAPI__ + +// to access the HID_SendReport via USBAPI.h and report number +#include "Arduino.h" + +//================================================================================ +// RawHID +//================================================================================ + +typedef union{ +// a RAWHID_TX_SIZE byte buffer for rx or tx +uint8_t whole8[RAWHID_TX_SIZE]; +uint16_t whole16[RAWHID_TX_SIZE / 2]; +uint32_t whole32[RAWHID_TX_SIZE / 4]; +uint8_t buff[RAWHID_TX_SIZE]; +} HID_RawKeyboardReport_Data_t; + +class RawHID_ : public Print{ +public: + inline RawHID_(void){ + // empty + } + + inline void begin(void){ + // empty + } + + inline void end(void){ + // empty + } + + using Print::write; // to get the String version of write + inline size_t write(uint8_t b){ + write(&b, 1); + } + + inline size_t write(const uint8_t *buffer, size_t size){ + size_t bytesleft = size; + // first work through the buffer thats already there + while (bytesleft >= RAWHID_RX_SIZE){ + HID_SendReport(HID_REPORTID_RAWHID, &buffer[size - bytesleft], RAWHID_RX_SIZE); + bytesleft -= RAWHID_RX_SIZE; + } + // write down the other bytes and fill with zeros + if (bytesleft){ + uint8_t rest[RAWHID_RX_SIZE]; + memcpy(rest, &buffer[size - bytesleft], bytesleft); + memset(&rest[bytesleft], 0, RAWHID_RX_SIZE - bytesleft); + HID_SendReport(HID_REPORTID_RAWHID, &rest, RAWHID_RX_SIZE); + } + } +}; +extern RawHID_ RawHID; + +#endif \ No newline at end of file diff --git a/avr/variants/leonardo_custom/pins_arduino.h b/avr/variants/leonardo_custom/pins_arduino.h index 5fed3ae..c198ad0 100644 --- a/avr/variants/leonardo_custom/pins_arduino.h +++ b/avr/variants/leonardo_custom/pins_arduino.h @@ -28,20 +28,60 @@ THE SOFTWARE. // HID Settings //================================================================================ +/* +You have two options to enable/disbale hid functions: + +The nearly full automatic way which enables the specific hid report for you, +enables the specific hid api and also enables the keyboard led function if needed. + +The fully customizable variant where you can create your very own HID report. +You still can use the predefined hid reports or add you very own ones. +You have to enable the specific hid apis on your own then, also the keyboard led function. +*/ + +#define HID_AUTOMATIC +#define HID_CUSTOM_SETTINGS + +//================================================================================ +// Automatic +//================================================================================ + +#ifdef HID_AUTOMATIC +// pre selected hid reports with autoinclude of the api +#define HID_MOUSE_ENABLE // normal mouse with buttons + wheel +//#define HID_MOUSE_ABSOLUTE_ENABLE // only works with system and without gamepad +#define HID_KEYBOARD_LEDS_ENABLE // leds OR keys +//#define HID_KEYBOARD_KEYS_ENABLE +//#define HID_RAWHID_ENABLE // currently not working +//#define HID_CONSUMER_ENABLE +//#define HID_SYSTEM_ENABLE +//#define HID_GAMEPAD_ENABLE // only works without mouse absolute + +//================================================================================ +// Custom Settings +//================================================================================ + +#elif defined(HID_CUSTOM_SETTINGS) + +// default setting here shows a mouse + keyboard with no led function +// like in IDE 1.0.6/1.5.8 or lower + // use this to enable the Keyboard Led functions -#define HID_KEYBOARD_LEDS_ENABLED +//#define HID_KEYBOARD_LEDS_ENABLED // add your custom report here: #define EXTERN_HID_REPORT \ -HID_REPORT_KEYBOARD_LEDS(HID_REPORTID_KEYBOARD), \ +HID_REPORT_KEYBOARD_KEYS(HID_REPORTID_KEYBOARD), \ HID_REPORT_MOUSE(HID_REPORTID_MOUSE) // activate your custom HID-APIs here: #define HID_MOUSE_API_ENABLE #define HID_KEYBOARD_API_ENABLE +//#define HID_RAWHID_API_ENABLE //#define HID_CONSUMER_API_ENABLE //#define HID_SYSTEM_API_ENABLE //#define HID_GAMEPAD_API_ENABLE +//#define HID_ENABLE_ALL_APIS // enables all of the ones above /* You can use the pre defined reports as well. @@ -58,7 +98,11 @@ Currently available pre defined reports : //HID_REPORT_KEYBOARD_KEYS(HID_REPORTID_KEYBOARD), //HID_REPORT_MOUSE(HID_REPORTID_MOUSE), //HID_REPORT_MOUSE_ABSOLUTE(HID_REPORTID_MOUSE_ABSOLUTE), -////HID_REPORT_RAWHID(HID_REPORTID_RAWHID), // not working at the moment +//HID_REPORT_RAWHID(HID_REPORTID_RAWHID), //HID_REPORT_CONSUMERCONTROL(HID_REPORTID_CONSUMERCONTROL), //HID_REPORT_SYSTEMCONTROL(HID_REPORTID_SYSTEMCONTROL), -//HID_REPORT_GAMEPAD(HID_REPORTID_GAMEPAD), \ No newline at end of file +//HID_REPORT_GAMEPAD(HID_REPORTID_GAMEPAD), + +#else +#error Please select automatic or custom hid report in the pins_arduino.h! +#endif \ No newline at end of file diff --git a/avr/variants/leonardo_gamepad/pins_arduino.h b/avr/variants/leonardo_gamepad/pins_arduino.h index 738c80e..85a19e2 100644 --- a/avr/variants/leonardo_gamepad/pins_arduino.h +++ b/avr/variants/leonardo_gamepad/pins_arduino.h @@ -28,18 +28,12 @@ THE SOFTWARE. // HID Settings //================================================================================ -// use this to enable the Keyboard Led functions -#define HID_KEYBOARD_LEDS_ENABLED - -#define GAMEPAD_HID_REPORT \ -HID_REPORT_KEYBOARD_LEDS(HID_REPORTID_KEYBOARD), \ -HID_REPORT_MOUSE(HID_REPORTID_MOUSE), \ -HID_REPORT_GAMEPAD(HID_REPORTID_GAMEPAD) - -// add your custom report here: -#define EXTERN_HID_REPORT GAMEPAD_HID_REPORT - -// activate your custom HID-APIs here: -#define HID_MOUSE_API_ENABLE -#define HID_KEYBOARD_API_ENABLE -#define HID_GAMEPAD_API_ENABLE \ No newline at end of file +// pre selected hid reports with autoinclude of the api +#define HID_MOUSE_ENABLE // normal mouse with buttons + wheel +//#define HID_MOUSE_ABSOLUTE_ENABLE // only works with system and without gamepad +#define HID_KEYBOARD_LEDS_ENABLE // leds OR keys +//#define HID_KEYBOARD_KEYS_ENABLE +//#define HID_RAWHID_ENABLE // currently not working +//#define HID_CONSUMER_ENABLE +//#define HID_SYSTEM_ENABLE +#define HID_GAMEPAD_ENABLE // only works without mouse absolute diff --git a/avr/variants/leonardo_hid/pins_arduino.h b/avr/variants/leonardo_hid/pins_arduino.h index 4d8fbc4..22545bf 100644 --- a/avr/variants/leonardo_hid/pins_arduino.h +++ b/avr/variants/leonardo_hid/pins_arduino.h @@ -28,21 +28,12 @@ THE SOFTWARE. // HID Settings //================================================================================ -// use this to enable the Keyboard Led functions -#define HID_KEYBOARD_LEDS_ENABLED - -#define EXTENDED_HID_REPORT \ -HID_REPORT_KEYBOARD_LEDS(HID_REPORTID_KEYBOARD), \ -HID_REPORT_MOUSE(HID_REPORTID_MOUSE), \ -HID_REPORT_MOUSE_ABSOLUTE(HID_REPORTID_MOUSE_ABSOLUTE), \ -HID_REPORT_CONSUMERCONTROL(HID_REPORTID_CONSUMERCONTROL), \ -HID_REPORT_SYSTEMCONTROL(HID_REPORTID_SYSTEMCONTROL) - -// add your custom report here: -#define EXTERN_HID_REPORT EXTENDED_HID_REPORT - -// activate your custom HID-APIs here: -#define HID_MOUSE_API_ENABLE -#define HID_KEYBOARD_API_ENABLE -#define HID_CONSUMER_API_ENABLE -#define HID_SYSTEM_API_ENABLE +// pre selected hid reports with autoinclude of the api +#define HID_MOUSE_ENABLE // normal mouse with buttons + wheel +#define HID_MOUSE_ABSOLUTE_ENABLE // only works with system and without gamepad +#define HID_KEYBOARD_LEDS_ENABLE // leds OR keys +//#define HID_KEYBOARD_KEYS_ENABLE +//#define HID_RAWHID_ENABLE // currently not working +#define HID_CONSUMER_ENABLE +#define HID_SYSTEM_ENABLE +//#define HID_GAMEPAD_ENABLE // only works without mouse absolute diff --git a/avr/variants/micro_custom/pins_arduino.h b/avr/variants/micro_custom/pins_arduino.h index 4e7ff4c..1b6241f 100644 --- a/avr/variants/micro_custom/pins_arduino.h +++ b/avr/variants/micro_custom/pins_arduino.h @@ -28,20 +28,60 @@ THE SOFTWARE. // HID Settings //================================================================================ +/* +You have two options to enable/disbale hid functions: + +The nearly full automatic way which enables the specific hid report for you, +enables the specific hid api and also enables the keyboard led function if needed. + +The fully customizable variant where you can create your very own HID report. +You still can use the predefined hid reports or add you very own ones. +You have to enable the specific hid apis on your own then, also the keyboard led function. +*/ + +#define HID_AUTOMATIC +#define HID_CUSTOM_SETTINGS + +//================================================================================ +// Automatic +//================================================================================ + +#ifdef HID_AUTOMATIC +// pre selected hid reports with autoinclude of the api +#define HID_MOUSE_ENABLE // normal mouse with buttons + wheel +//#define HID_MOUSE_ABSOLUTE_ENABLE // only works with system and without gamepad +#define HID_KEYBOARD_LEDS_ENABLE // leds OR keys +//#define HID_KEYBOARD_KEYS_ENABLE +//#define HID_RAWHID_ENABLE // currently not working +//#define HID_CONSUMER_ENABLE +//#define HID_SYSTEM_ENABLE +//#define HID_GAMEPAD_ENABLE // only works without mouse absolute + +//================================================================================ +// Custom Settings +//================================================================================ + +#elif defined(HID_CUSTOM_SETTINGS) + +// default setting here shows a mouse + keyboard with no led function +// like in IDE 1.0.6/1.5.8 or lower + // use this to enable the Keyboard Led functions -#define HID_KEYBOARD_LEDS_ENABLED +//#define HID_KEYBOARD_LEDS_ENABLED // add your custom report here: #define EXTERN_HID_REPORT \ -HID_REPORT_KEYBOARD_LEDS(HID_REPORTID_KEYBOARD), \ +HID_REPORT_KEYBOARD_KEYS(HID_REPORTID_KEYBOARD), \ HID_REPORT_MOUSE(HID_REPORTID_MOUSE) // activate your custom HID-APIs here: #define HID_MOUSE_API_ENABLE #define HID_KEYBOARD_API_ENABLE +//#define HID_RAWHID_API_ENABLE //#define HID_CONSUMER_API_ENABLE //#define HID_SYSTEM_API_ENABLE //#define HID_GAMEPAD_API_ENABLE +//#define HID_ENABLE_ALL_APIS // enables all of the ones above /* You can use the pre defined reports as well. @@ -58,7 +98,11 @@ Currently available pre defined reports : //HID_REPORT_KEYBOARD_KEYS(HID_REPORTID_KEYBOARD), //HID_REPORT_MOUSE(HID_REPORTID_MOUSE), //HID_REPORT_MOUSE_ABSOLUTE(HID_REPORTID_MOUSE_ABSOLUTE), -////HID_REPORT_RAWHID(HID_REPORTID_RAWHID), // not working at the moment +//HID_REPORT_RAWHID(HID_REPORTID_RAWHID), //HID_REPORT_CONSUMERCONTROL(HID_REPORTID_CONSUMERCONTROL), //HID_REPORT_SYSTEMCONTROL(HID_REPORTID_SYSTEMCONTROL), -//HID_REPORT_GAMEPAD(HID_REPORTID_GAMEPAD), \ No newline at end of file +//HID_REPORT_GAMEPAD(HID_REPORTID_GAMEPAD), + +#else +#error Please select automatic or custom hid report in the pins_arduino.h! +#endif \ No newline at end of file diff --git a/avr/variants/micro_gamepad/pins_arduino.h b/avr/variants/micro_gamepad/pins_arduino.h index 54a65b7..18a3497 100644 --- a/avr/variants/micro_gamepad/pins_arduino.h +++ b/avr/variants/micro_gamepad/pins_arduino.h @@ -28,18 +28,12 @@ THE SOFTWARE. // HID Settings //================================================================================ -// use this to enable the Keyboard Led functions -#define HID_KEYBOARD_LEDS_ENABLED - -#define GAMEPAD_HID_REPORT \ -HID_REPORT_KEYBOARD_LEDS(HID_REPORTID_KEYBOARD), \ -HID_REPORT_MOUSE(HID_REPORTID_MOUSE), \ -HID_REPORT_GAMEPAD(HID_REPORTID_GAMEPAD) - -// add your custom report here: -#define EXTERN_HID_REPORT GAMEPAD_HID_REPORT - -// activate your custom HID-APIs here: -#define HID_MOUSE_API_ENABLE -#define HID_KEYBOARD_API_ENABLE -#define HID_GAMEPAD_API_ENABLE \ No newline at end of file +// pre selected hid reports with autoinclude of the api +#define HID_MOUSE_ENABLE // normal mouse with buttons + wheel +//#define HID_MOUSE_ABSOLUTE_ENABLE // only works with system and without gamepad +#define HID_KEYBOARD_LEDS_ENABLE // leds OR keys +//#define HID_KEYBOARD_KEYS_ENABLE +//#define HID_RAWHID_ENABLE // currently not working +//#define HID_CONSUMER_ENABLE +//#define HID_SYSTEM_ENABLE +#define HID_GAMEPAD_ENABLE // only works without mouse absolute diff --git a/avr/variants/micro_hid/pins_arduino.h b/avr/variants/micro_hid/pins_arduino.h index b687abd..18ec7e1 100644 --- a/avr/variants/micro_hid/pins_arduino.h +++ b/avr/variants/micro_hid/pins_arduino.h @@ -28,21 +28,12 @@ THE SOFTWARE. // HID Settings //================================================================================ -// use this to enable the Keyboard Led functions -#define HID_KEYBOARD_LEDS_ENABLED - -#define EXTENDED_HID_REPORT \ -HID_REPORT_KEYBOARD_LEDS(HID_REPORTID_KEYBOARD), \ -HID_REPORT_MOUSE(HID_REPORTID_MOUSE), \ -HID_REPORT_MOUSE_ABSOLUTE(HID_REPORTID_MOUSE_ABSOLUTE), \ -HID_REPORT_CONSUMERCONTROL(HID_REPORTID_CONSUMERCONTROL), \ -HID_REPORT_SYSTEMCONTROL(HID_REPORTID_SYSTEMCONTROL) - -// add your custom report here: -#define EXTERN_HID_REPORT EXTENDED_HID_REPORT - -// activate your custom HID-APIs here: -#define HID_MOUSE_API_ENABLE -#define HID_KEYBOARD_API_ENABLE -#define HID_CONSUMER_API_ENABLE -#define HID_SYSTEM_API_ENABLE \ No newline at end of file +// pre selected hid reports with autoinclude of the api +#define HID_MOUSE_ENABLE // normal mouse with buttons + wheel +#define HID_MOUSE_ABSOLUTE_ENABLE // only works with system and without gamepad +#define HID_KEYBOARD_LEDS_ENABLE // leds OR keys +//#define HID_KEYBOARD_KEYS_ENABLE +//#define HID_RAWHID_ENABLE // currently not working +#define HID_CONSUMER_ENABLE +#define HID_SYSTEM_ENABLE +//#define HID_GAMEPAD_ENABLE // only works without mouse absolute diff --git a/examples/Projects/HoodLoader1_API_Legacy/HoodLoader1_API_Legacy.ino b/examples/Projects/HoodLoader1_API_Legacy/HoodLoader1_API_Legacy.ino index 546a413..b8f4fe9 100644 --- a/examples/Projects/HoodLoader1_API_Legacy/HoodLoader1_API_Legacy.ino +++ b/examples/Projects/HoodLoader1_API_Legacy/HoodLoader1_API_Legacy.ino @@ -27,6 +27,8 @@ See official documentation for more infos */ +#include "USB-Core/Keyboard.h" + // Serial to write Protocol data to. Default: Serial #define HID_SERIAL Serial #define SERIAL_HID_BAUD 115200 diff --git a/hid-core.png b/hid-core.png new file mode 100644 index 0000000..4d3d0ce Binary files /dev/null and b/hid-core.png differ