Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/HID-APIs/AbsoluteMouseAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typedef union ATTRIBUTE_PACKED {
int16_t xAxis;
int16_t yAxis;
int8_t wheel;
int8_t hWheel;
};
} HID_MouseAbsoluteReport_Data_t;

Expand All @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/HID-APIs/AbsoluteMouseAPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this? Doesnt this set the cursor to a fixed position, maybe 0,0?

report.wheel = wheel;
report.hWheel = hWheel;
SendReport(&report, sizeof(report));
}

void AbsoluteMouseAPI::press(uint8_t b){
// press LEFT by default
buttons(_buttons | b);
Expand Down
26 changes: 14 additions & 12 deletions src/HID-APIs/MouseAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typedef union ATTRIBUTE_PACKED {
int8_t xAxis;
int8_t yAxis;
int8_t wheel;
int8_t hWheel;
};
} HID_MouseReport_Data_t;

Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/HID-APIs/MouseAPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions src/MultiReport/AbsoluteMouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
9 changes: 9 additions & 0 deletions src/MultiReport/ImprovedMouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down