14
14
/* This sketch demonstrates USB HID mouse
15
15
* Press button pin will move
16
16
* - mouse toward bottom right of monitor
17
- *
17
+ *
18
18
* Depending on the board, the button pin
19
19
* and its active state (when pressed) are different
20
20
*/
21
- #if defined ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS
21
+ #if defined ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS || defined ARDUINO_NRF52840_CIRCUITPLAY
22
22
const int pin = 4 ; // Left Button
23
23
bool activeState = true ;
24
- #elif defined ARDUINO_NRF52840_FEATHER
25
- const int pin = 7 ; // UserSw
24
+
25
+ #elif defined PIN_BUTTON1
26
+ const int pin = PIN_BUTTON1;
26
27
bool activeState = false ;
28
+
27
29
#else
28
30
const int pin = 12 ;
29
31
bool activeState = false ;
30
32
#endif
31
-
33
+
32
34
33
35
// HID report descriptor using TinyUSB's template
34
36
// Single Report (no ID) descriptor
@@ -51,6 +53,7 @@ void setup()
51
53
// Set up button, pullup opposite to active state
52
54
pinMode (pin, activeState ? INPUT_PULLDOWN : INPUT_PULLUP);
53
55
56
+ usb_hid.setBootProtocol (HID_ITF_PROTOCOL_MOUSE);
54
57
usb_hid.setPollInterval (2 );
55
58
usb_hid.setReportDescriptor (desc_hid_report, sizeof (desc_hid_report));
56
59
// usb_hid.setStringDescriptor("TinyUSB Mouse");
@@ -86,7 +89,8 @@ void loop()
86
89
87
90
if ( usb_hid.ready () )
88
91
{
92
+ uint8_t const report_id = 0 ; // no ID
89
93
int8_t const delta = 5 ;
90
- usb_hid.mouseMove (0 , delta, delta); // no ID: right + down
94
+ usb_hid.mouseMove (report_id , delta, delta); // right + down
91
95
}
92
96
}
0 commit comments