@@ -49,10 +49,11 @@ Keyboard_ Keyboard;
49
49
#define HID_REPORTID_KEYBOARD (2 )
50
50
#define HID_REPORTID_RAWHID (3 )
51
51
#define HID_REPORTID_SYSTEMCONTROL (4 )
52
+ #define HID_REPORTID_MOUSE_ABS (5 )
52
53
extern const u8 _hidReportDescriptor[] PROGMEM;
53
54
const u8 _hidReportDescriptor[] = {
54
55
55
- // Mouse
56
+ // Mouse relative
56
57
0x05 , 0x01 , // USAGE_PAGE (Generic Desktop) // 54
57
58
0x09 , 0x02 , // USAGE (Mouse)
58
59
0xa1 , 0x01 , // COLLECTION (Application)
@@ -82,6 +83,38 @@ const u8 _hidReportDescriptor[] = {
82
83
0xc0 , // END_COLLECTION
83
84
0xc0 , // END_COLLECTION
84
85
86
+ #ifdef MOUSE_ABS_ENABLED
87
+ // Mouse absolute
88
+ 0x05 , 0x01 , // USAGE_PAGE (Generic Desktop)
89
+ 0x09 , 0x02 , // USAGE (Mouse)
90
+ 0xa1 , 0x01 , // COLLECTION (Application)
91
+ 0x09 , 0x01 , // USAGE (Pointer)
92
+ 0xa1 , 0x00 , // COLLECTION (Physical)
93
+ 0x85 , HID_REPORTID_MOUSE_ABS, // REPORT_ID (5)
94
+ 0x05 , 0x09 , // USAGE_PAGE (Button)
95
+ 0x19 , 0x01 , // USAGE_MINIMUM (Button 1)
96
+ 0x29 , 0x03 , // USAGE_MAXIMUM (Button 3)
97
+ 0x15 , 0x00 , // LOGICAL_MINIMUM (0)
98
+ 0x25 , 0x01 , // LOGICAL_MAXIMUM (1)
99
+ 0x95 , 0x03 , // REPORT_COUNT (3)
100
+ 0x75 , 0x01 , // REPORT_SIZE (1)
101
+ 0x81 , 0x02 , // INPUT (Data,Var,Abs)
102
+ 0x95 , 0x01 , // REPORT_COUNT (1)
103
+ 0x75 , 0x05 , // REPORT_SIZE (5)
104
+ 0x81 , 0x03 , // INPUT (Cnst,Var,Abs)
105
+ 0x05 , 0x01 , // USAGE_PAGE (Generic Desktop)
106
+ 0x09 , 0x30 , // USAGE (X)
107
+ 0x09 , 0x31 , // USAGE (Y)
108
+ 0x09 , 0x38 , // USAGE (Wheel)
109
+ 0x16 , 0x00 , 0x80 , // LOGICAL_MINIMUM (-32768)
110
+ 0x26 , 0xff , 0x7f , // LOGICAL_MAXIMUM (32767)
111
+ 0x75 , 0x10 , // REPORT_SIZE (16)
112
+ 0x95 , 0x03 , // REPORT_COUNT (3)
113
+ 0x81 , 0x02 , // INPUT (Data,Var,Abs)
114
+ 0xc0 , // END_COLLECTION
115
+ 0xc0 , // END_COLLECTION
116
+ #endif
117
+
85
118
// Keyboard
86
119
0x05 , 0x01 , // USAGE_PAGE (Generic Desktop) // 47
87
120
0x09 , 0x06 , // USAGE (Keyboard)
@@ -268,6 +301,28 @@ void Mouse_::move(signed char x, signed char y, signed char wheel)
268
301
HID_SendReport (HID_REPORTID_MOUSE,m,sizeof (m));
269
302
}
270
303
304
+ #ifdef MOUSE_ABS_ENABLED
305
+ // all parameters have the range of -32768 to 32767 and must be scaled to screen pixels
306
+ // some examples:
307
+ // x=0,y=0 is the middle of the screen
308
+ // x=-32768,y=-32768 is the top left corner
309
+ // x=32767,y=-32768 is the top right corner
310
+ // x=32767,y=32767 is the bottom right corner
311
+ // x=-32768,y=32767 is the bottom left corner
312
+ void Mouse_::moveAbs (int16_t x, int16_t y, int16_t wheel)
313
+ {
314
+ u8 m[7 ];
315
+ m[0 ] = _buttons; // TODO: is it a good idea to take over the _buttons from relative report here or should it be left out?
316
+ m[1 ] = LSB (x);
317
+ m[2 ] = MSB (x);
318
+ m[3 ] = LSB (y);
319
+ m[4 ] = MSB (y);
320
+ m[5 ] = LSB (wheel);
321
+ m[6 ] = MSB (wheel);
322
+ HID_SendReport (HID_REPORTID_MOUSE_ABS,m,sizeof (m));
323
+ }
324
+ #endif
325
+
271
326
void Mouse_::buttons (uint8_t b)
272
327
{
273
328
if (b != _buttons)
0 commit comments