Skip to content

Commit 15b069a

Browse files
committed
More reliable Keyboard API impl
1 parent 91171ca commit 15b069a

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

OS/HID/Keyboard.cpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace MatrixOS::HID::Keyboard
2323
HID_KeyboardReport_Data_t _keyReport;
2424
static TaskHandle_t _sendTaskHandle = nullptr;
2525
static StaticTask_t _sendTaskBuffer;
26-
static StackType_t _sendTaskStack[configMINIMAL_STACK_SIZE];
26+
static StackType_t _sendTaskStack[configMINIMAL_STACK_SIZE * 6];
2727
static uint64_t _lastSendMicros = 0;
2828

2929
static void SendTask(void* param);
@@ -84,8 +84,6 @@ namespace MatrixOS::HID::Keyboard
8484
}
8585
}
8686

87-
MLOGD("HID", "Set failed");
88-
8987
// No empty/pressed key was found
9088
return false;
9189
}
@@ -100,7 +98,6 @@ namespace MatrixOS::HID::Keyboard
10098

10199
if(!HID::Ready())
102100
{
103-
ulTaskNotifyTake(pdTRUE, 0);
104101
continue;
105102
}
106103

@@ -110,17 +107,12 @@ namespace MatrixOS::HID::Keyboard
110107
// and REMOTE_WAKEUP feature is enabled by host
111108
tud_remote_wakeup();
112109
}
113-
114-
tud_hid_n_report(0, REPORT_ID_KEYBOARD, &_keyReport, sizeof(_keyReport));
115-
MatrixOS::SYS::DelayMs(2);
116-
117-
// Clear any queued notifications; we only need to send the latest _keyReport state once.
118-
ulTaskNotifyTake(pdTRUE, 0);
119-
120-
// Send another one to make sure we didn't drop packet
121-
tud_hid_n_report(0, REPORT_ID_KEYBOARD, &_keyReport, sizeof(_keyReport));
122-
MatrixOS::SYS::DelayMs(2);
123-
110+
111+
for(uint8_t i = 0; i < 5; i++)
112+
{
113+
tud_hid_n_report(0, REPORT_ID_KEYBOARD, &_keyReport, sizeof(_keyReport));
114+
MatrixOS::SYS::DelayMs(2);
115+
}
124116
}
125117
}
126118

0 commit comments

Comments
 (0)