From d3147adbfd7f0e712faf0e0e72b938b92c6b5bf3 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 5 Mar 2016 17:58:16 +0100 Subject: [PATCH 1/6] Added releaseAll() for Mouse API --- src/HID-APIs/MouseAPI.h | 7 ++++--- src/HID-APIs/MouseAPI.hpp | 15 ++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/HID-APIs/MouseAPI.h b/src/HID-APIs/MouseAPI.h index b72712e..184a5ae 100644 --- a/src/HID-APIs/MouseAPI.h +++ b/src/HID-APIs/MouseAPI.h @@ -70,14 +70,15 @@ public: inline void begin(void); inline void end(void); inline void click(uint8_t b = MOUSE_LEFT); - inline void move(signed char x, signed char y, signed char wheel = 0); + inline void move(signed char x, signed char y, signed char wheel = 0); inline void press(uint8_t b = MOUSE_LEFT); // press LEFT by default inline void release(uint8_t b = MOUSE_LEFT); // release LEFT by default + inline void releaseAll(void); inline bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default - + // Sending is public in the base class for advanced users. virtual void SendReport(void* data, int length) = 0; - + protected: uint8_t _buttons; inline void buttons(uint8_t b); diff --git a/src/HID-APIs/MouseAPI.hpp b/src/HID-APIs/MouseAPI.hpp index 55d144d..332201f 100644 --- a/src/HID-APIs/MouseAPI.hpp +++ b/src/HID-APIs/MouseAPI.hpp @@ -29,12 +29,12 @@ MouseAPI::MouseAPI(void) : _buttons(0) // Empty } -void MouseAPI::begin(void) +void MouseAPI::begin(void) { end(); } -void MouseAPI::end(void) +void MouseAPI::end(void) { _buttons = 0; move(0, 0, 0); @@ -67,7 +67,7 @@ void MouseAPI::buttons(uint8_t b) } } -void MouseAPI::press(uint8_t b) +void MouseAPI::press(uint8_t b) { buttons(_buttons | b); } @@ -77,10 +77,15 @@ void MouseAPI::release(uint8_t b) buttons(_buttons & ~b); } +void MouseAPI::releaseAll(void) +{ + _buttons = 0; + move(0,0,0); +} + bool MouseAPI::isPressed(uint8_t b) { - if ((b & _buttons) > 0) + if ((b & _buttons) > 0) return true; return false; } - From b33ff31253ed37f5caba2b714005281d9bfb33f5 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 5 Mar 2016 18:00:05 +0100 Subject: [PATCH 2/6] Bump to version 2.4.4 --- Readme.md | 7 ++++--- library.properties | 2 +- src/HID-Project.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Readme.md b/Readme.md index 39007ee..af57092 100644 --- a/Readme.md +++ b/Readme.md @@ -1,4 +1,4 @@ -Arduino HID Project 2.4.3 +Arduino HID Project 2.4.4 ========================= ![Header Picture](header.jpg) @@ -41,14 +41,15 @@ An offline snapshot is available in [releases](https://github.com/NicoHood/HID/r Contact ======= -You can contact me on my wordpress blog in the contact section. - www.nicohood.de Version History =============== ``` +2.4.4 Release (xx.xx.2016) +* Added releaseAll() to Mouse API + 2.4.3 Release (02.03.2016) * Fixed NKRO Keyboard modifier add() #76 diff --git a/library.properties b/library.properties index e724e48..b74e139 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=HID-Project -version=2.4.3 +version=2.4.4 author=NicoHood maintainer=NicoHood sentence=Extended HID Functions for Arduino diff --git a/src/HID-Project.h b/src/HID-Project.h index 8645047..e1df58a 100644 --- a/src/HID-Project.h +++ b/src/HID-Project.h @@ -25,7 +25,7 @@ THE SOFTWARE. #pragma once // Software version -#define HID_PROJECT_VERSION 243 +#define HID_PROJECT_VERSION 244 #if ARDUINO < 10607 #error HID Project requires Arduino IDE 1.6.7 or greater. Please update your IDE. From 7c269d9749222983e21a82aff841538111e9998f Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 5 Mar 2016 18:02:50 +0100 Subject: [PATCH 3/6] Added releaseAll() for abs Mouse --- src/HID-APIs/AbsoluteMouseAPI.h | 4 ++-- src/HID-APIs/AbsoluteMouseAPI.hpp | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/HID-APIs/AbsoluteMouseAPI.h b/src/HID-APIs/AbsoluteMouseAPI.h index 37a6ee8..6f117e6 100644 --- a/src/HID-APIs/AbsoluteMouseAPI.h +++ b/src/HID-APIs/AbsoluteMouseAPI.h @@ -71,12 +71,12 @@ public: inline void move(int x, int y, signed char wheel = 0); inline void press(uint8_t b = MOUSE_LEFT); inline void release(uint8_t b = MOUSE_LEFT); + inline void releaseAll(void); inline bool isPressed(uint8_t b = MOUSE_LEFT); - + // Sending is public in the base class for advanced users. virtual void SendReport(void* data, int length) = 0; }; // Implementation is inline #include "AbsoluteMouseAPI.hpp" - diff --git a/src/HID-APIs/AbsoluteMouseAPI.hpp b/src/HID-APIs/AbsoluteMouseAPI.hpp index 23f736e..a561d19 100644 --- a/src/HID-APIs/AbsoluteMouseAPI.hpp +++ b/src/HID-APIs/AbsoluteMouseAPI.hpp @@ -32,7 +32,7 @@ void AbsoluteMouseAPI::buttons(uint8_t b){ } int16_t AbsoluteMouseAPI::qadd16(int16_t base, int16_t increment) { - // Separate between subtracting and adding + // Separate between subtracting and adding if (increment < 0) { // Subtracting more would cause an undefined overflow if ((int16_t)0x8000 - increment > base) @@ -50,7 +50,7 @@ int16_t AbsoluteMouseAPI::qadd16(int16_t base, int16_t increment) { return base; } -AbsoluteMouseAPI::AbsoluteMouseAPI(void): +AbsoluteMouseAPI::AbsoluteMouseAPI(void): xAxis(0), yAxis(0), _buttons(0) { // Empty @@ -98,6 +98,11 @@ void AbsoluteMouseAPI::release(uint8_t b){ buttons(_buttons & ~b); } +void AbsoluteMouseAPI::releaseAll(void){ + _buttons = 0; + moveTo(xAxis, yAxis, 0); +} + bool AbsoluteMouseAPI::isPressed(uint8_t b){ // check LEFT by default if ((b & _buttons) > 0) From 12557b5489cd36330eabb23baf6b882fd66be2ad Mon Sep 17 00:00:00 2001 From: NicoHood Date: Thu, 5 May 2016 23:08:11 +0200 Subject: [PATCH 4/6] Added wiki submodule --- .gitmodules | 3 +++ HID.wiki | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 HID.wiki diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..89a2490 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "HID.wiki"] + path = HID.wiki + url = https://github.com/NicoHood/HID.wiki.git diff --git a/HID.wiki b/HID.wiki new file mode 160000 index 0000000..a1a0b08 --- /dev/null +++ b/HID.wiki @@ -0,0 +1 @@ +Subproject commit a1a0b086985dec037d7e7d86c6b2d5816207f202 From 583718f4536ddbd418b7d0b694fd5855ecb0f87d Mon Sep 17 00:00:00 2001 From: NicoHood Date: Fri, 27 Jan 2017 12:22:02 +0100 Subject: [PATCH 5/6] Fix flexible array errors --- src/HID-APIs/AbsoluteMouseAPI.h | 6 ++--- src/HID-APIs/ConsumerAPI.h | 9 +++---- src/HID-APIs/DefaultKeyboardAPI.h | 7 +++--- src/HID-APIs/GamepadAPI.h | 9 +++---- src/HID-APIs/MouseAPI.h | 12 ++++----- src/HID-APIs/NKROKeyboardAPI.h | 9 +++---- src/HID-APIs/SystemAPI.h | 4 +-- src/SingleReport/RawHID.h | 41 +++++++++++++++---------------- 8 files changed, 46 insertions(+), 51 deletions(-) diff --git a/src/HID-APIs/AbsoluteMouseAPI.h b/src/HID-APIs/AbsoluteMouseAPI.h index 6f117e6..a74c782 100644 --- a/src/HID-APIs/AbsoluteMouseAPI.h +++ b/src/HID-APIs/AbsoluteMouseAPI.h @@ -39,9 +39,9 @@ THE SOFTWARE. typedef union{ // Absolute mouse report: 8 buttons, 2 absolute axis, wheel - uint8_t whole8[]; - uint16_t whole16[]; - uint32_t whole32[]; + uint8_t whole8[0]; + uint16_t whole16[0]; + uint32_t whole32[0]; struct{ uint8_t buttons; int16_t xAxis; diff --git a/src/HID-APIs/ConsumerAPI.h b/src/HID-APIs/ConsumerAPI.h index 33558b6..a12c674 100644 --- a/src/HID-APIs/ConsumerAPI.h +++ b/src/HID-APIs/ConsumerAPI.h @@ -450,9 +450,9 @@ enum ConsumerKeycode : uint16_t { typedef union { // Every usable Consumer key possible, up to 4 keys presses possible - uint8_t whole8[]; - uint16_t whole16[]; - uint32_t whole32[]; + uint8_t whole8[0]; + uint16_t whole16[0]; + uint32_t whole32[0]; ConsumerKeycode keys[4]; struct { ConsumerKeycode key1; @@ -472,7 +472,7 @@ public: inline void press(ConsumerKeycode m); inline void release(ConsumerKeycode m); inline void releaseAll(void); - + // Sending is public in the base class for advanced users. virtual void SendReport(void* data, int length) = 0; @@ -482,4 +482,3 @@ protected: // Implementation is inline #include "ConsumerAPI.hpp" - diff --git a/src/HID-APIs/DefaultKeyboardAPI.h b/src/HID-APIs/DefaultKeyboardAPI.h index b586b09..e605f27 100644 --- a/src/HID-APIs/DefaultKeyboardAPI.h +++ b/src/HID-APIs/DefaultKeyboardAPI.h @@ -29,9 +29,9 @@ THE SOFTWARE. typedef union{ // Low level key report: up to 6 keys and shift, ctrl etc at once - uint8_t whole8[]; - uint16_t whole16[]; - uint32_t whole32[]; + uint8_t whole8[0]; + uint16_t whole16[0]; + uint32_t whole32[0]; struct{ uint8_t modifiers; uint8_t reserved; @@ -74,4 +74,3 @@ private: // Implementation is inline #include "DefaultKeyboardAPI.hpp" - diff --git a/src/HID-APIs/GamepadAPI.h b/src/HID-APIs/GamepadAPI.h index 13ea7b5..6a50018 100644 --- a/src/HID-APIs/GamepadAPI.h +++ b/src/HID-APIs/GamepadAPI.h @@ -41,9 +41,9 @@ THE SOFTWARE. typedef union { // 32 Buttons, 6 Axis, 2 D-Pads - uint8_t whole8[]; - uint16_t whole16[]; - uint32_t whole32[]; + uint8_t whole8[0]; + uint16_t whole16[0]; + uint32_t whole32[0]; uint32_t buttons; struct{ @@ -117,7 +117,7 @@ public: inline void rzAxis(int8_t a); inline void dPad1(int8_t d); inline void dPad2(int8_t d); - + // Sending is public in the base class for advanced users. virtual void SendReport(void* data, int length) = 0; @@ -127,4 +127,3 @@ protected: // Implementation is inline #include "GamepadAPI.hpp" - diff --git a/src/HID-APIs/MouseAPI.h b/src/HID-APIs/MouseAPI.h index 184a5ae..1ce85eb 100644 --- a/src/HID-APIs/MouseAPI.h +++ b/src/HID-APIs/MouseAPI.h @@ -39,9 +39,9 @@ THE SOFTWARE. typedef union{ // Mouse report: 8 buttons, position, wheel - uint8_t whole8[]; - uint16_t whole16[]; - uint32_t whole32[]; + uint8_t whole8[0]; + uint16_t whole16[0]; + uint32_t whole32[0]; struct{ uint8_t buttons; int8_t xAxis; @@ -53,9 +53,9 @@ typedef union{ typedef union{ // BootMouse report: 3 buttons, position // Wheel is not supported by boot protocol - uint8_t whole8[]; - uint16_t whole16[]; - uint32_t whole32[]; + uint8_t whole8[0]; + uint16_t whole16[0]; + uint32_t whole32[0]; struct{ uint8_t buttons; int8_t xAxis; diff --git a/src/HID-APIs/NKROKeyboardAPI.h b/src/HID-APIs/NKROKeyboardAPI.h index 7dafbd7..6ff0c1a 100644 --- a/src/HID-APIs/NKROKeyboardAPI.h +++ b/src/HID-APIs/NKROKeyboardAPI.h @@ -32,9 +32,9 @@ THE SOFTWARE. typedef union{ // Modifier + keymap + 1 custom key - uint8_t whole8[]; - uint16_t whole16[]; - uint32_t whole32[]; + uint8_t whole8[0]; + uint16_t whole16[0]; + uint32_t whole32[0]; struct{ uint8_t modifiers; uint8_t keys[NKRO_KEY_COUNT / 8]; @@ -43,7 +43,7 @@ typedef union{ uint8_t allkeys[2 + NKRO_KEY_COUNT / 8]; } HID_NKROKeyboardReport_Data_t; - + class NKROKeyboardAPI : public KeyboardAPI { public: @@ -62,4 +62,3 @@ private: // Implementation is inline #include "NKROKeyboardAPI.hpp" - diff --git a/src/HID-APIs/SystemAPI.h b/src/HID-APIs/SystemAPI.h index e27abac..b1d7d75 100644 --- a/src/HID-APIs/SystemAPI.h +++ b/src/HID-APIs/SystemAPI.h @@ -76,7 +76,7 @@ enum SystemKeycode : uint8_t { typedef union{ // Every usable system control key possible - uint8_t whole8[]; + uint8_t whole8[0]; uint8_t key; } HID_SystemControlReport_Data_t; @@ -89,7 +89,7 @@ public: inline void press(SystemKeycode s); inline void release(void); inline void releaseAll(void); - + // Sending is public in the base class for advanced users. virtual void SendReport(void* data, int length) = 0; }; diff --git a/src/SingleReport/RawHID.h b/src/SingleReport/RawHID.h index 9ccc43e..0382971 100644 --- a/src/SingleReport/RawHID.h +++ b/src/SingleReport/RawHID.h @@ -54,17 +54,17 @@ THE SOFTWARE. typedef union{ // a RAWHID_TX_SIZE byte buffer for tx - uint8_t whole8[]; - uint16_t whole16[]; - uint32_t whole32[]; + uint8_t whole8[0]; + uint16_t whole16[0]; + uint32_t whole32[0]; uint8_t buff[RAWHID_TX_SIZE]; } HID_RawKeyboardTXReport_Data_t; typedef union{ // a RAWHID_TX_SIZE byte buffer for rx - uint8_t whole8[]; - uint16_t whole16[]; - uint32_t whole32[]; + uint8_t whole8[0]; + uint16_t whole16[0]; + uint32_t whole32[0]; uint8_t buff[RAWHID_RX_SIZE]; } HID_RawKeyboardRXReport_Data_t; @@ -77,23 +77,23 @@ public: if(length > 0){ featureReport = (uint8_t*)report; featureLength = length; - + // Disable feature report by default disableFeatureReport(); } } - + int availableFeatureReport(void){ if(featureLength < 0){ return featureLength & ~0x8000; } return 0; } - + void enableFeatureReport(void){ featureLength &= ~0x8000; } - + void disableFeatureReport(void){ featureLength |= 0x8000; } @@ -110,22 +110,22 @@ public: disable(); dataLength = 0; } - + void enable(void){ dataAvailable = 0; } - + void disable(void){ dataAvailable = -1; } - + virtual int available(void){ if(dataAvailable < 0){ return 0; } return dataAvailable; } - + virtual int read(){ // Check if we have data available if(dataAvailable > 0) @@ -135,7 +135,7 @@ public: } return -1; } - + virtual int peek(){ // Check if we have data available if(dataAvailable > 0){ @@ -143,7 +143,7 @@ public: } return -1; } - + virtual void flush(void){ // Writing will always flush by the USB driver } @@ -157,24 +157,23 @@ public: virtual size_t write(uint8_t *buffer, size_t size){ return USB_Send(pluggedEndpoint | TRANSFER_RELEASE, buffer, size); } - + protected: // Implementation of the PUSBListNode int getInterface(uint8_t* interfaceCount); int getDescriptor(USBSetup& setup); bool setup(USBSetup& setup); - + uint8_t epType[1]; uint8_t protocol; uint8_t idle; - + // Buffer pointers to hold the received data int dataLength; int dataAvailable; uint8_t* data; - + uint8_t* featureReport; int featureLength; }; extern RawHID_ RawHID; - From 51611e6548ad2c0a4c21510c5cef3d7be2210973 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Fri, 27 Jan 2017 12:24:29 +0100 Subject: [PATCH 6/6] Release 2.4.4 --- Readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index af57092..3f5f85a 100644 --- a/Readme.md +++ b/Readme.md @@ -47,8 +47,9 @@ www.nicohood.de Version History =============== ``` -2.4.4 Release (xx.xx.2016) +2.4.4 Release (27.01.2017) * Added releaseAll() to Mouse API +* Fix flexible array errors 2.4.3 Release (02.03.2016) * Fixed NKRO Keyboard modifier add() #76