diff --git a/examples/AbsoluteMouse/AbsoluteMouse.ino b/examples/AbsoluteMouse/AbsoluteMouse.ino index 89c762d..4abccd9 100644 --- a/examples/AbsoluteMouse/AbsoluteMouse.ino +++ b/examples/AbsoluteMouse/AbsoluteMouse.ino @@ -11,7 +11,7 @@ */ #include "HID.h" -#include "AbsoluteMouse.h" +#include "HID-Project.h" const int pinLed = LED_BUILTIN; const int pinButtonClick = 2; diff --git a/examples/Consumer/Consumer.ino b/examples/Consumer/Consumer.ino index 1590007..fa75e26 100644 --- a/examples/Consumer/Consumer.ino +++ b/examples/Consumer/Consumer.ino @@ -10,7 +10,7 @@ */ #include "HID.h" -#include "Consumer.h" +#include "HID-Project.h" const int pinLed = LED_BUILTIN; const int pinButton = 2; diff --git a/examples/Gamepad/Gamepad.ino b/examples/Gamepad/Gamepad.ino index 008df47..bff18da 100644 --- a/examples/Gamepad/Gamepad.ino +++ b/examples/Gamepad/Gamepad.ino @@ -9,9 +9,8 @@ https://github.com/NicoHood/HID/wiki/Gamepad-API */ -#include "Mouse.h" #include "HID.h" -#include "Gamepad.h" +#include "HID-Project.h" const int pinLed = LED_BUILTIN; const int pinButton = 2; diff --git a/examples/System/System.ino b/examples/System/System.ino index a3308b5..92445d6 100644 --- a/examples/System/System.ino +++ b/examples/System/System.ino @@ -10,7 +10,7 @@ */ #include "HID.h" -#include "System.h" +#include "HID-Project.h" const int pinLed = LED_BUILTIN; const int pinButtonS = 2; diff --git a/library.properties b/library.properties index 62d0c8c..e75184e 100644 --- a/library.properties +++ b/library.properties @@ -7,3 +7,4 @@ paragraph=Includes Consumer, System and Gamepad. Also compatible with Arduino Un category=Device Control url=https://github.com/NicoHood/HID architectures=* +alinkage=true diff --git a/src/AbsoluteMouse.h b/src/AbsoluteMouse.h index de6647a..94b2eee 100644 --- a/src/AbsoluteMouse.h +++ b/src/AbsoluteMouse.h @@ -27,7 +27,7 @@ THE SOFTWARE. #if !defined(_USING_HID) -#warning "Using legacy HID core (non pluggable)" +#error "This is not an USB AVR or you use an old version of the IDE." #else @@ -48,7 +48,7 @@ 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) -static const u8 _hidReportDescriptor[] PROGMEM = { +static const uint8_t _absmouseReportDescriptor[] PROGMEM = { /* Mouse absolute */ 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) 54 */ 0x09, 0x02, /* USAGE (Mouse) */ @@ -137,8 +137,8 @@ private: public: inline AbsMouse_(void) { static HID_Descriptor cb = { - .length = sizeof(_hidReportDescriptor), - .descriptor = _hidReportDescriptor, + .length = sizeof(_absmouseReportDescriptor), + .descriptor = _absmouseReportDescriptor, }; static HIDDescriptorListNode node(&cb); HID.AppendDescriptor(&node); diff --git a/src/Consumer.h b/src/Consumer.h index 51670a5..041660a 100644 --- a/src/Consumer.h +++ b/src/Consumer.h @@ -27,7 +27,7 @@ THE SOFTWARE. #if !defined(_USING_HID) -#warning "Using legacy HID core (non pluggable)" +#error "This is not an USB AVR or you use an old version of the IDE." #else @@ -67,7 +67,7 @@ THE SOFTWARE. #define CONSUMER_BROWSER_REFRESH 0x227 #define CONSUMER_BROWSER_BOOKMARKS 0x22A -static const u8 _hidReportDescriptor[] PROGMEM = { +static const uint8_t _consumerReportDescriptor[] PROGMEM = { /* Consumer Control (Sound/Media keys) */ 0x05, 0x0C, /* usage page (consumer device) */ 0x09, 0x01, /* usage -- consumer control */ @@ -103,8 +103,8 @@ class Consumer_ { public: inline Consumer_(void) { static HID_Descriptor cb = { - .length = sizeof(_hidReportDescriptor), - .descriptor = _hidReportDescriptor, + .length = sizeof(_consumerReportDescriptor), + .descriptor = _consumerReportDescriptor, }; static HIDDescriptorListNode node(&cb); HID.AppendDescriptor(&node); diff --git a/src/Gamepad.h b/src/Gamepad.h index 97d2e20..ecd478d 100644 --- a/src/Gamepad.h +++ b/src/Gamepad.h @@ -27,7 +27,7 @@ THE SOFTWARE. #if !defined(_USING_HID) -#warning "Using legacy HID core (non pluggable)" +#error "This is not an USB AVR or you use an old version of the IDE." #else @@ -50,7 +50,7 @@ THE SOFTWARE. #define GAMEPAD_DPAD_LEFT 7 #define GAMEPAD_DPAD_UP_LEFT 8 -static const u8 _hidReportDescriptor[] PROGMEM = { +static const uint8_t _gamepadReportDescriptor[] PROGMEM = { /* Gamepad with 32 buttons and 6 axis*/ 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ 0x09, 0x04, /* USAGE (Joystick) */ @@ -162,8 +162,8 @@ class Gamepad_{ public: inline Gamepad_(void){ static HID_Descriptor cb = { - .length = sizeof(_hidReportDescriptor), - .descriptor = _hidReportDescriptor, + .length = sizeof(_gamepadReportDescriptor), + .descriptor = _gamepadReportDescriptor, }; static HIDDescriptorListNode node(&cb); HID.AppendDescriptor(&node); diff --git a/src/HID-Project.h b/src/HID-Project.h index e69de29..9d17d30 100644 --- a/src/HID-Project.h +++ b/src/HID-Project.h @@ -0,0 +1,36 @@ +/* +Copyright (c) 2014-2015 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 guard +#pragma once + +// Software version +#define HID_PROJECT_VERSION 240 + +#include + +// Include all HID libraries (.a linkage required to work) properly +#include "AbsoluteMouse.h" +#include "Consumer.h" +#include "Gamepad.h" +#include "System.h" diff --git a/src/System.h b/src/System.h index 5cb4d13..fbe42c1 100644 --- a/src/System.h +++ b/src/System.h @@ -27,7 +27,7 @@ THE SOFTWARE. #if !defined(_USING_HID) -#warning "Using legacy HID core (non pluggable)" +#error "This is not an USB AVR or you use an old version of the IDE." #else @@ -43,7 +43,7 @@ THE SOFTWARE. #define SYSTEM_SLEEP 0x82 #define SYSTEM_WAKE_UP 0x83 -static const u8 _hidReportDescriptor[] PROGMEM = { +static const uint8_t _systemReportDescriptor[] PROGMEM = { //TODO limit to system keys only? /* System Control (Power Down, Sleep, Wakeup, ...) */ 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ @@ -73,8 +73,8 @@ class System_{ public: inline System_(void){ static HID_Descriptor cb = { - .length = sizeof(_hidReportDescriptor), - .descriptor = _hidReportDescriptor, + .length = sizeof(_systemReportDescriptor), + .descriptor = _systemReportDescriptor, }; static HIDDescriptorListNode node(&cb); HID.AppendDescriptor(&node);