From bc952e0bc0eb24a9dfb25c67b8c96700014d4937 Mon Sep 17 00:00:00 2001 From: Nico Date: Sat, 17 Jan 2015 14:53:10 +0100 Subject: [PATCH] Fixed Consumer/System-Control names Also added Absolute Mouse Report --- avr/cores/hid/USB-Core/Consumer.h | 8 ++++---- avr/cores/hid/USB-Core/HID.h | 16 ++++++++-------- avr/cores/hid/USB-Core/Mouse.h | 13 ++++++++++++- avr/cores/hid/USB-Core/System.h | 2 +- avr/variants/leonardo_custom/pins_arduino.h | 12 ++++++------ avr/variants/leonardo_gamepad/pins_arduino.h | 4 ++-- avr/variants/leonardo_hid/pins_arduino.h | 4 ++-- avr/variants/micro_custom/pins_arduino.h | 12 ++++++------ avr/variants/micro_gamepad/pins_arduino.h | 4 ++-- avr/variants/micro_hid/pins_arduino.h | 4 ++-- 10 files changed, 45 insertions(+), 34 deletions(-) diff --git a/avr/cores/hid/USB-Core/Consumer.h b/avr/cores/hid/USB-Core/Consumer.h index 1cc9dae..3397f52 100644 --- a/avr/cores/hid/USB-Core/Consumer.h +++ b/avr/cores/hid/USB-Core/Consumer.h @@ -64,7 +64,7 @@ typedef union{ uint16_t key3; uint16_t key4; }; -} HID_ConsumerReport_Data_t; +} HID_ConsumerControlReport_Data_t; class Consumer_{ public: @@ -85,7 +85,7 @@ public: } inline void press(uint16_t m){ // search for a free spot - for (int i = 0; i < sizeof(HID_ConsumerReport_Data_t) / 2; i++) { + for (int i = 0; i < sizeof(HID_ConsumerControlReport_Data_t) / 2; i++) { if (_report.whole16[i] == 0x00) { _report.whole16[i] = m; break; @@ -95,7 +95,7 @@ public: } inline void release(uint16_t m){ // search and release the keypress - for (int i = 0; i < sizeof(HID_ConsumerReport_Data_t) / 2; i++) { + for (int i = 0; i < sizeof(HID_ConsumerControlReport_Data_t) / 2; i++) { if (_report.whole16[i] == m) { _report.whole16[i] = 0x00; // no break to delete multiple keys @@ -107,7 +107,7 @@ public: begin(); } private: - HID_ConsumerReport_Data_t _report; + HID_ConsumerControlReport_Data_t _report; }; extern Consumer_ Consumer; diff --git a/avr/cores/hid/USB-Core/HID.h b/avr/cores/hid/USB-Core/HID.h index c996420..d2db12f 100644 --- a/avr/cores/hid/USB-Core/HID.h +++ b/avr/cores/hid/USB-Core/HID.h @@ -70,11 +70,11 @@ THE SOFTWARE. #ifdef HID_RAWHID_ENABLE #define HID_RAWHID_API_ENABLE #endif -#ifdef HID_CONSUMER_ENABLE -#define HID_CONSUMER_API_ENABLE +#ifdef HID_CONSUMERCONTROL_ENABLE +#define HID_CONSUMERCONTROL_API_ENABLE #endif -#ifdef HID_SYSTEM_ENABLE -#define HID_SYSTEM_API_ENABLE +#ifdef HID_SYSTEMCONTROL_ENABLE +#define HID_SYSTEMCONTROL_API_ENABLE #endif #ifdef HID_GAMEPAD_ENABLE #define HID_GAMEPAD_API_ENABLE @@ -404,8 +404,8 @@ void HID_SendReport(uint8_t id, const void* data, int len); #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_CONSUMERCONTROL_API_ENABLE +#define HID_SYSTEMCONTROL_API_ENABLE #define HID_GAMEPAD_API_ENABLE #endif @@ -423,11 +423,11 @@ void HID_SendReport(uint8_t id, const void* data, int len); #include "RawHID.h" #endif -#ifdef HID_CONSUMER_API_ENABLE +#ifdef HID_CONSUMERCONTROL_API_ENABLE #include "Consumer.h" #endif -#ifdef HID_SYSTEM_API_ENABLE +#ifdef HID_SYSTEMCONTROL_API_ENABLE #include "System.h" #endif diff --git a/avr/cores/hid/USB-Core/Mouse.h b/avr/cores/hid/USB-Core/Mouse.h index ce57999..23462ed 100644 --- a/avr/cores/hid/USB-Core/Mouse.h +++ b/avr/cores/hid/USB-Core/Mouse.h @@ -72,6 +72,17 @@ typedef union{ }; } HID_MouseReport_Data_t; +typedef union{ + // mouse absolute report: 2 absolute axis + uint8_t whole8[4]; + uint16_t whole16[4 / 2]; + uint32_t whole32[4 / 4]; + struct{ + int16_t xAxis; + int16_t yAxis; + }; +} HID_MouseAbsoluteReport_Data_t; + class Mouse_ { private: @@ -128,7 +139,7 @@ public: return false; } - inline void moveTo(uint16_t x, uint16_t y){ + inline void moveTo(int16_t x, int16_t y){ // uses different report ID and different HID mouse device! uint32_t pos = ((uint32_t)y << 16) | x; HID_SendReport(HID_REPORTID_MOUSE_ABSOLUTE, &pos, sizeof(pos)); diff --git a/avr/cores/hid/USB-Core/System.h b/avr/cores/hid/USB-Core/System.h index b47f148..5c0a2d0 100644 --- a/avr/cores/hid/USB-Core/System.h +++ b/avr/cores/hid/USB-Core/System.h @@ -39,7 +39,7 @@ typedef union{ // every usable system control key possible uint8_t whole8[1]; uint8_t key; -} HID_SystemReport_Data_t; +} HID_SystemControlReport_Data_t; class System_{ public: diff --git a/avr/variants/leonardo_custom/pins_arduino.h b/avr/variants/leonardo_custom/pins_arduino.h index 111d4f9..ede4dff 100644 --- a/avr/variants/leonardo_custom/pins_arduino.h +++ b/avr/variants/leonardo_custom/pins_arduino.h @@ -53,8 +53,8 @@ You have to enable the specific hid apis on your own then, also the keyboard led #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_CONSUMERCONTROL_ENABLE +//#define HID_SYSTEMCONTROL_ENABLE //#define HID_GAMEPAD_ENABLE // only works without mouse absolute //================================================================================ @@ -78,8 +78,8 @@ HID_REPORT_MOUSE(HID_REPORTID_MOUSE) #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_CONSUMERCONTROL_API_ENABLE +//#define HID_SYSTEMCONTROL_API_ENABLE //#define HID_GAMEPAD_API_ENABLE //#define HID_ENABLE_ALL_APIS // enables all of the ones above @@ -124,8 +124,8 @@ HID_REPORT_MOUSE(HID_REPORTID_MOUSE) ////#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_CONSUMERCONTROL_API_ENABLE +////#define HID_SYSTEMCONTROL_API_ENABLE ////#define HID_GAMEPAD_API_ENABLE ////#define HID_ENABLE_ALL_APIS // enables all of the ones above diff --git a/avr/variants/leonardo_gamepad/pins_arduino.h b/avr/variants/leonardo_gamepad/pins_arduino.h index 75b7638..6898e24 100644 --- a/avr/variants/leonardo_gamepad/pins_arduino.h +++ b/avr/variants/leonardo_gamepad/pins_arduino.h @@ -34,6 +34,6 @@ THE SOFTWARE. #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_CONSUMERCONTROL_ENABLE +//#define HID_SYSTEMCONTROL_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 7378bca..8f1f8f3 100644 --- a/avr/variants/leonardo_hid/pins_arduino.h +++ b/avr/variants/leonardo_hid/pins_arduino.h @@ -34,6 +34,6 @@ THE SOFTWARE. #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_CONSUMERCONTROL_ENABLE +#define HID_SYSTEMCONTROL_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 59045af..d6a3af8 100644 --- a/avr/variants/micro_custom/pins_arduino.h +++ b/avr/variants/micro_custom/pins_arduino.h @@ -53,8 +53,8 @@ You have to enable the specific hid apis on your own then, also the keyboard led #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_CONSUMERCONTROL_ENABLE +//#define HID_SYSTEMCONTROL_ENABLE //#define HID_GAMEPAD_ENABLE // only works without mouse absolute //================================================================================ @@ -78,8 +78,8 @@ HID_REPORT_MOUSE(HID_REPORTID_MOUSE) #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_CONSUMERCONTROL_API_ENABLE +//#define HID_SYSTEMCONTROL_API_ENABLE //#define HID_GAMEPAD_API_ENABLE //#define HID_ENABLE_ALL_APIS // enables all of the ones above @@ -124,8 +124,8 @@ HID_REPORT_MOUSE(HID_REPORTID_MOUSE) ////#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_CONSUMERCONTROL_API_ENABLE +////#define HID_SYSTEMCONTROL_API_ENABLE ////#define HID_GAMEPAD_API_ENABLE ////#define HID_ENABLE_ALL_APIS // enables all of the ones above diff --git a/avr/variants/micro_gamepad/pins_arduino.h b/avr/variants/micro_gamepad/pins_arduino.h index dcbd43a..d2cbea4 100644 --- a/avr/variants/micro_gamepad/pins_arduino.h +++ b/avr/variants/micro_gamepad/pins_arduino.h @@ -34,6 +34,6 @@ THE SOFTWARE. #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_CONSUMERCONTROL_ENABLE +//#define HID_SYSTEMCONTROL_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 6b8fdcf..32e49b0 100644 --- a/avr/variants/micro_hid/pins_arduino.h +++ b/avr/variants/micro_hid/pins_arduino.h @@ -34,6 +34,6 @@ THE SOFTWARE. #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_CONSUMERCONTROL_ENABLE +#define HID_SYSTEMCONTROL_ENABLE //#define HID_GAMEPAD_ENABLE // only works without mouse absolute