* usb_device_state: add idle_rate, led and protocol
Previously all usb drivers and platform implementations (expect for our
oddball atsam) tracked the same two global variables:
- keyboard_protocol: to indicate if we are in report or boot protocol
- keyboard_idle: for the idle_rate of the keyboard endpoint
And a local variable that was exposed trough some indirection:
- keyboard_led_state: for the currently set indicator leds (caps lock etc.)
These have all been moved into the usb_device_state struct wich is
accessible by getters and setters.
This reduces code duplication and centralizes the state management
across platforms and drivers.
Signed-off-by: Stefan Kerkmann <karlk90@pm.me>
* usb_device_state: reset protocol on reset
The usb hid specification section 7.2.6 states:
When initialized, all devices default to report protocol. However the
host should not make any assumptions about the device’s state and should
set the desired protocol whenever initializing a device.
Thus on reset we should always do exactly that.
Signed-off-by: Stefan Kerkmann <karlk90@pm.me>
* keyboards: fix oversize warnings
Signed-off-by: Stefan Kerkmann <karlk90@pm.me>
---------
Signed-off-by: Stefan Kerkmann <karlk90@pm.me>
* Add missing '(' to print_bin_reverse32 declaration
* Fix insufficient character buffers on satisfaction75
* Remove \0 character in format string and use corrected offset math
instead on rocketboard 16
* Replace snprintf_ with snprintf for djinn
* Explicitly ignore format checks for tracktyl manuform that uses %b
specifier
* Print properly escaped version string in command.c, as PRODUCT or
other defines can contain constructs like 'Vendor keyboard 66%' which
will be interpreted as a format specifier
* quantum/command.c: coalesce `print()`s in `command_common_help()` & `print_version()`
Also undo some damage by clang-format in b624f32f94
* quantum/command.c: replace `print(…); print_{,val_}{dec,hex}*(…);` sequences with single `xprintf(…)`
`print_{dec,hex}*(…)` are just `#define`s for `xprintf(…)` anyway.
Each additional `xprintf(…)` costs ~8 bytes: the call instructions,
plus an additional NUL terminator.
This _really_ adds up: this commit saves 814 bytes on my ATmega32.
* quantum/command.c: optimise `mousekey_console()` for size & legibility
Made various tweaks to the interface, but still functionally identical.
Assume `KC_1`…`KC_0` to be contiguous, and removed `numkey2num(…)` entirely.
It was exported in `command.h` by 1a0bac8bcc for no obvious reason, before
which it was `static`. I doubt anyone uses it.
`mousekey_console()` is now enabled regardless of `MK_3_SPEED`.
Needs fleshing out for things other than the X11 variant though.
This commit saves 638 bytes on my ATmega32.