tmk / tmk_keyboard

Keyboard firmwares for Atmel AVR and Cortex-M
3.98k stars 1.7k forks source link

hid_listen on Windows with 64 endpoint size #727

Open tmk opened 2 years ago

tmk commented 2 years ago

When console endpoint size is 64 bytes hid_listen fails to display debug prints like below. On Linux hid_listen works without problem.

Device disconnected.
Waiting for new device:
Listening:

Device disconnected.
Waiting for new device:
Listening:

Device disconnected.
Waiting for new device:
Listening:

Device disconnected.
Waiting for new device:
Listening:

Device disconnected.
Waiting for new device:
Listening:

Device disconnected.
Waiting for new device:
Listening:
tmk commented 2 years ago

ReadFile() appears to require that buffer size is 65 when reading from 64-byte endpoint. The function replies with error 1784 when using 64-byte buffer.

ERROR_INVALID_USER_BUFFER 1784 (0x6F8) The supplied user buffer is not valid for the requested operation.

https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--1700-3999-

https://github.com/tmk/hid_listen/blob/dc2681d11e6e367aabb63ec81c936f378e7fbbd6/hid_listen.c#L34

https://github.com/tmk/hid_listen/blob/dc2681d11e6e367aabb63ec81c936f378e7fbbd6/rawhid.c#L636

tmk commented 2 years ago

Revert to 32-byte for console EP size

b690da76

hid_listen code on TMK has been fixed but Windows binary is not available yet.

https://github.com/tmk/hid_listen/commit/e586cf19006999a29dafe22d1dbdea754e4c25d2

TODO: Learn Windows binary build for public distribution