diff --git a/src/HID-APIs/AbsoluteMouseAPI.h b/src/HID-APIs/AbsoluteMouseAPI.h index 66dbe42b..8edf0053 100644 --- a/src/HID-APIs/AbsoluteMouseAPI.h +++ b/src/HID-APIs/AbsoluteMouseAPI.h @@ -47,6 +47,7 @@ typedef union ATTRIBUTE_PACKED { int16_t xAxis; int16_t yAxis; int8_t wheel; + int8_t hWheel; }; } HID_MouseAbsoluteReport_Data_t; @@ -69,6 +70,7 @@ class AbsoluteMouseAPI inline void click(uint8_t b = MOUSE_LEFT); inline void moveTo(int x, int y, signed char wheel = 0); inline void move(int x, int y, signed char wheel = 0); + inline void scroll(signed char wheel = 0, signed char hWheel = 0); inline void press(uint8_t b = MOUSE_LEFT); inline void release(uint8_t b = MOUSE_LEFT); inline void releaseAll(void); diff --git a/src/HID-APIs/AbsoluteMouseAPI.hpp b/src/HID-APIs/AbsoluteMouseAPI.hpp index 0913c8a8..cba32b35 100644 --- a/src/HID-APIs/AbsoluteMouseAPI.hpp +++ b/src/HID-APIs/AbsoluteMouseAPI.hpp @@ -92,6 +92,13 @@ void AbsoluteMouseAPI::move(int x, int y, signed char wheel){ moveTo(qadd16(xAxis, x), qadd16(yAxis, y), wheel); } +void AbsoluteMouseAPI::scroll(signed char wheel, signed char hWheel){ + HID_MouseAbsoluteReport_Data_t report; + report.wheel = wheel; + report.hWheel = hWheel; + SendReport(&report, sizeof(report)); +} + void AbsoluteMouseAPI::press(uint8_t b){ // press LEFT by default buttons(_buttons | b); diff --git a/src/HID-APIs/MouseAPI.h b/src/HID-APIs/MouseAPI.h index b3e17dbd..47e1f996 100644 --- a/src/HID-APIs/MouseAPI.h +++ b/src/HID-APIs/MouseAPI.h @@ -47,6 +47,7 @@ typedef union ATTRIBUTE_PACKED { int8_t xAxis; int8_t yAxis; int8_t wheel; + int8_t hWheel; }; } HID_MouseReport_Data_t; @@ -66,22 +67,23 @@ typedef union ATTRIBUTE_PACKED { class MouseAPI { public: - inline MouseAPI(void); - 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 press(uint8_t b = MOUSE_LEFT); // press LEFT by default - inline void release(uint8_t b = MOUSE_LEFT); // release LEFT by default + inline MouseAPI(void); + 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 scroll(signed char wheel = 0, signed char hWheel = 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 + 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; + // 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); + uint8_t _buttons; + inline void buttons(uint8_t b); }; // Implementation is inline diff --git a/src/HID-APIs/MouseAPI.hpp b/src/HID-APIs/MouseAPI.hpp index 332201ff..3d5d1c87 100644 --- a/src/HID-APIs/MouseAPI.hpp +++ b/src/HID-APIs/MouseAPI.hpp @@ -58,6 +58,14 @@ void MouseAPI::move(signed char x, signed char y, signed char wheel) SendReport(&report, sizeof(report)); } +void MouseAPI::scroll(signed char wheel, signed char hWheel) +{ + HID_MouseReport_Data_t report; + report.wheel = wheel; + report.hWheel = hWheel; + SendReport(&report, sizeof(report)); +} + void MouseAPI::buttons(uint8_t b) { if (b != _buttons) diff --git a/src/MultiReport/AbsoluteMouse.cpp b/src/MultiReport/AbsoluteMouse.cpp index 6a2ee819..13e4330b 100644 --- a/src/MultiReport/AbsoluteMouse.cpp +++ b/src/MultiReport/AbsoluteMouse.cpp @@ -58,6 +58,15 @@ static const uint8_t _hidMultiReportDescriptorAbsoluteMouse[] PROGMEM = { 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, 0x01, /* REPORT_COUNT (1) */ 0x81, 0x06, /* INPUT (Data,Var,Rel) */ + + /* Wheel Horizontal*/ + 0x05, 0x0c, /* USAGE PAGE (Consumer Devices) */ + 0x0a, 0x38, 0x02, /* USAGE (AC Pan) */ + 0x15, 0x81, /* LOGICAL_MINIMUM (-127) */ + 0x25, 0x7f, /* LOGICAL_MAXIMUM (127) */ + 0x75, 0x08, /* REPORT_SIZE (8) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x81, 0x06, /* INPUT (Data, Var, Rel) */ /* End */ 0xc0 /* END_COLLECTION */ diff --git a/src/MultiReport/ImprovedMouse.cpp b/src/MultiReport/ImprovedMouse.cpp index 9e4ffebc..0ac0edff 100644 --- a/src/MultiReport/ImprovedMouse.cpp +++ b/src/MultiReport/ImprovedMouse.cpp @@ -51,6 +51,15 @@ static const uint8_t _hidMultiReportDescriptorMouse[] PROGMEM = { 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, 0x03, /* REPORT_COUNT (3) */ 0x81, 0x06, /* INPUT (Data,Var,Rel) */ + + /* Wheel Horizontal Support */ + 0x05, 0x0c, /* USAGE PAGE (Consumer Devices) */ + 0x0a, 0x38, 0x02, /* USAGE (AC Pan) */ + 0x15, 0x81, /* LOGICAL_MINIMUM (-127) */ + 0x25, 0x7f, /* LOGICAL_MAXIMUM (127) */ + 0x75, 0x08, /* REPORT_SIZE (8) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x81, 0x06, /* INPUT (Data, Var, Rel) */ /* End */ 0xc0 /* END_COLLECTION */