Display and control your Android device
Add horizontal scrolling support for HID mouse
Romain Vimont4841fdd1eff5
diff --git a/app/src/hid/hid_mouse.c b/app/src/hid/hid_mouse.cindex e1fff45b..33f0807e 100644--- a/app/src/hid/hid_mouse.c+++ b/app/src/hid/hid_mouse.c@@ -3,8 +3,8 @@#include <stdint.h>// 1 byte for buttons + padding, 1 byte for X position, 1 byte for Y position,-// 1 byte for wheel motion-#define SC_HID_MOUSE_INPUT_SIZE 4+// 1 byte for wheel motion, 1 byte for hozizontal scrolling+#define SC_HID_MOUSE_INPUT_SIZE 5/*** Mouse descriptor from the specification:@@ -75,6 +75,21 @@ static const uint8_t SC_HID_MOUSE_REPORT_DESC[] = {// Input (Data, Variable, Relative): 3 position bytes (X, Y, Wheel)0x81, 0x06,+ // Usage Page (Consumer Page)+ 0x05, 0x0C,+ // Usage(AC Pan)+ 0x0A, 0x38, 0x02,+ // Logical Minimum (-127)+ 0x15, 0x81,+ // Logical Maximum (127)+ 0x25, 0x7F,+ // Report Size (8)+ 0x75, 0x08,+ // Report Count (1)+ 0x95, 0x01,+ // Input (Data, Variable, Relative): 1 byte (AC Pan)+ 0x81, 0x06,+// End Collection0xC0,@@ -160,7 +175,8 @@ sc_hid_mouse_generate_input_from_motion(struct sc_hid_input *hid_input,data[0] = sc_hid_buttons_from_buttons_state(event->buttons_state);data[1] = CLAMP(event->xrel, -127, 127);data[2] = CLAMP(event->yrel, -127, 127);- data[3] = 0; // wheel coordinates only used for scrolling+ data[3] = 0; // no vertical scrolling+ data[4] = 0; // no horizontal scrolling}void@@ -172,13 +188,14 @@ sc_hid_mouse_generate_input_from_click(struct sc_hid_input *hid_input,data[0] = sc_hid_buttons_from_buttons_state(event->buttons_state);data[1] = 0; // no x motiondata[2] = 0; // no y motion- data[3] = 0; // wheel coordinates only used for scrolling+ data[3] = 0; // no vertical scrolling+ data[4] = 0; // no horizontal scrolling}boolsc_hid_mouse_generate_input_from_scroll(struct sc_hid_input *hid_input,const struct sc_mouse_scroll_event *event) {- if (!event->vscroll_int) {+ if (!event->vscroll_int && !event->hscroll_int) {// Need a full integral value for HIDreturn false;}@@ -190,7 +207,7 @@ sc_hid_mouse_generate_input_from_scroll(struct sc_hid_input *hid_input,data[1] = 0; // no x motiondata[2] = 0; // no y motiondata[3] = CLAMP(event->vscroll_int, -127, 127);- // Horizontal scrolling ignored+ data[4] = CLAMP(event->hscroll_int, -127, 127);return true;}