Skip to content

Commit 3863f50

Browse files
Merge branch 'set_idle_fix' of https://github.com/seife/DigistumpArduino
2 parents b6fe9f6 + 7873411 commit 3863f50

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

digistump-avr/libraries/DigisparkJoystick/DigiJoystick.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ class DigiJoystickDevice {
161161

162162
// instead of above code, use millis arduino system to enforce minimum reporting frequency
163163
unsigned long time_since_last_report = millis() - last_report_time;
164-
if (time_since_last_report >= (idle_rate * 4 /* in units of 4ms - usb spec stuff */)) {
164+
/* idle_rate == 0, never send idle reports
165+
cf https://www.usb.org/sites/default/files/hid1_11.pdf 7.2.4 "Set_Idle Request":
166+
"When the upper byte of wValue is 0 (zero), the duration is indefinite. The endpoint will
167+
inhibit reporting forever, only reporting when a change is detected in the report data." */
168+
if (idle_rate > 0 && time_since_last_report >= (idle_rate * 4 /* in units of 4ms - usb spec stuff */)) {
165169
last_report_time += idle_rate * 4;
166170
must_report = 1;
167171
}

digistump-avr/libraries/DigisparkMouse/DigiMouse.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,11 @@ class DigiMouseDevice {
185185

186186
// instead of above code, use millis arduino system to enforce minimum reporting frequency
187187
unsigned long time_since_last_report = millis() - last_report_time;
188-
if (time_since_last_report >= (idle_rate * 4 /* in units of 4ms - usb spec stuff */)) {
188+
/* idle_rate == 0, never send idle reports
189+
cf https://www.usb.org/sites/default/files/hid1_11.pdf 7.2.4 "Set_Idle Request":
190+
"When the upper byte of wValue is 0 (zero), the duration is indefinite. The endpoint will
191+
inhibit reporting forever, only reporting when a change is detected in the report data." */
192+
if (idle_rate > 0 && time_since_last_report >= (idle_rate * 4 /* in units of 4ms - usb spec stuff */)) {
189193
last_report_time += idle_rate * 4;
190194
must_report = 1;
191195
}

0 commit comments

Comments
 (0)