3
3
#include <stdint.h>
4
4
5
5
// 1 byte for buttons + padding, 1 byte for X position, 1 byte for Y position,
6
- // 1 byte for wheel motion
7
- #define SC_HID_MOUSE_INPUT_SIZE 4
6
+ // 1 byte for wheel motion, 1 byte for hozizontal scrolling
7
+ #define SC_HID_MOUSE_INPUT_SIZE 5
8
8
9
9
/**
10
10
* Mouse descriptor from the specification:
@@ -75,6 +75,21 @@ static const uint8_t SC_HID_MOUSE_REPORT_DESC[] = {
75
75
// Input (Data, Variable, Relative): 3 position bytes (X, Y, Wheel)
76
76
0x81 , 0x06 ,
77
77
78
+ // Usage Page (Consumer Page)
79
+ 0x05 , 0x0C ,
80
+ // Usage(AC Pan)
81
+ 0x0A , 0x38 , 0x02 ,
82
+ // Logical Minimum (-127)
83
+ 0x15 , 0x81 ,
84
+ // Logical Maximum (127)
85
+ 0x25 , 0x7F ,
86
+ // Report Size (8)
87
+ 0x75 , 0x08 ,
88
+ // Report Count (1)
89
+ 0x95 , 0x01 ,
90
+ // Input (Data, Variable, Relative): 1 byte (AC Pan)
91
+ 0x81 , 0x06 ,
92
+
78
93
// End Collection
79
94
0xC0 ,
80
95
@@ -160,7 +175,8 @@ sc_hid_mouse_generate_input_from_motion(struct sc_hid_input *hid_input,
160
175
data [0 ] = sc_hid_buttons_from_buttons_state (event -> buttons_state );
161
176
data [1 ] = CLAMP (event -> xrel , -127 , 127 );
162
177
data [2 ] = CLAMP (event -> yrel , -127 , 127 );
163
- data [3 ] = 0 ; // wheel coordinates only used for scrolling
178
+ data [3 ] = 0 ; // no vertical scrolling
179
+ data [4 ] = 0 ; // no horizontal scrolling
164
180
}
165
181
166
182
void
@@ -172,13 +188,14 @@ sc_hid_mouse_generate_input_from_click(struct sc_hid_input *hid_input,
172
188
data [0 ] = sc_hid_buttons_from_buttons_state (event -> buttons_state );
173
189
data [1 ] = 0 ; // no x motion
174
190
data [2 ] = 0 ; // no y motion
175
- data [3 ] = 0 ; // wheel coordinates only used for scrolling
191
+ data [3 ] = 0 ; // no vertical scrolling
192
+ data [4 ] = 0 ; // no horizontal scrolling
176
193
}
177
194
178
195
bool
179
196
sc_hid_mouse_generate_input_from_scroll (struct sc_hid_input * hid_input ,
180
197
const struct sc_mouse_scroll_event * event ) {
181
- if (!event -> vscroll_int ) {
198
+ if (!event -> vscroll_int && ! event -> hscroll_int ) {
182
199
// Need a full integral value for HID
183
200
return false;
184
201
}
@@ -190,7 +207,7 @@ sc_hid_mouse_generate_input_from_scroll(struct sc_hid_input *hid_input,
190
207
data [1 ] = 0 ; // no x motion
191
208
data [2 ] = 0 ; // no y motion
192
209
data [3 ] = CLAMP (event -> vscroll_int , -127 , 127 );
193
- // Horizontal scrolling ignored
210
+ data [ 4 ] = CLAMP ( event -> hscroll_int , -127 , 127 );
194
211
return true;
195
212
}
196
213
0 commit comments