Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge KeyboardioHID into plugins #1372

Merged
merged 599 commits into from
Dec 14, 2023
Merged

Merge KeyboardioHID into plugins #1372

merged 599 commits into from
Dec 14, 2023

Conversation

obra
Copy link
Member

@obra obra commented Dec 14, 2023

KeyboardioHID does not have a separate life outside of Kaleidoscope. Maintaining it in a standalone repo was an artifact of an earlier era of development.

This PR merges it into Kaleidoscope/plugins, preserving all history and applies only

automated code formatting and cpplint changes.

obra added 30 commits December 14, 2023 14:45
(Other than the HID descriptor)
obra and others added 28 commits December 14, 2023 14:49
This method was only sending one report, but two are necessary for a "click".
There was an assumption, based on the old Kaleidoscope, that a report would be
sent every cycle, so the release report would be "free".  This is not true of
Kaleidoscope any longer, and any other client might also not behave that way.

Also, if the mouse button was already active ("held"), the "press" report would
be a no-op, so instead of a click, we'd just get a release.

Signed-off-by: Michael Richters <[email protected]>
buffers that are modulo 16 bits in size.

This is currently necessary because these fields are read
directly from the USB peripheral with ‘usbd_ep_data_read’,
which can only read in 16-bit chunks (as of version 2.1.2
of the firmware library).
This reverts commit acbb10c.

Signed-off-by: Michael Richters <[email protected]>
This reverts commit cea28ac.

Signed-off-by: Michael Richters <[email protected]>
This reverts commit c964f84, reversing
changes made to 75c1e0b.

Signed-off-by: Michael Richters <[email protected]>
This version confines the changes to the method definitions affected, and
should make it simpler to revert those changes later.

Signed-off-by: Michael Richters <[email protected]>
"release" report at init time.  This is...not actually correct on a
normal device. This commit reverts that behavior, which, among other
things, caused the Keyboardio Model 100 to freeze on boot on Intel macs.

That code came with this comment:
    // Force API to send a clean report.
    // This is important for and HID bridge where the receiver stays on,
    // while the sender is resetted.

Added in this commit:

  commit 91e2a62
  Author: NicoHood <[email protected]>
  Date:   Sun Oct 25 14:26:55 2015 +0100

      Made Keyboard API a lot more flexible
Since 781eb41,  `SystemControl_::begin()` is a
no-op, calling it in `release()` and `releaseAll()` is not doing what it did
prior to that commit: call `end()`, which is what the release functions really
wanted to do in the first place.

However, calling `end()` is also backwards: `end()` should be calling one of the
release functions instead. So lets do that: `releaseAll()` will now send an
empty report, and `release()` and `end()` will call it.

Signed-off-by: Gergely Nagy <[email protected]>
There was a fencepost error in counting the number of bits in the key
bitmap. This resulted in the report descriptor declaring one more Usage
than items in the report, which might cause validation problems on some
HID implementations.

The only affected Usage was Keypad Hexadecimal, which is probably not
used often.

Signed-off-by: Taylor Yu <[email protected]>
On non-boot devices, reject Get/Set Protocol requests, because we don't
implement the boot protocol for non-BootKeyboard devices.

Signed-off-by: Taylor Yu <[email protected]>
Always respond with the current Idle period, possibly set by the
host. Also, set the initial idle period to 0 (indefinite), because
that's how we actually behave.

Signed-off-by: Taylor Yu <[email protected]>
Only reset boot/report protocol on USB bus reset. Windows 10 will
sometimes try to cache report descriptors if it has high confidence
that it's a device it's seen before. This means it won't retrieve
either the configuration descriptor set or the report descriptors when
resetting after receving control from the BIOS/UEFI. The BIOS or UEFI
probably set the boot keyboard to boot protocol, which meant that
when Windows regained control, the boot keyboard was still in boot
protocol, contrary to the USB HID specification.

This requires the higher-level driver to call a polling function,
because detection of USB reset events isn't as portable as checking
the USB device configuration.

Signed-off-by: Taylor Yu <[email protected]>
Use a singleton for BootKeyboard to make sure that it is the first HID
interface. Some UEFIs or BIOSes appear to only recognize a boot keyboard
if it's the first HID interface.

Signed-off-by: Taylor Yu <[email protected]>
Instead of having a poll function to check for USB reset in
BootKeyboard, use an onReset hook instead.

Signed-off-by: Taylor Yu <[email protected]>
Remove the GD32 `recvControl` workaround, because changes to the USB
core mean that it's no longer required.

Signed-off-by: Taylor Yu <[email protected]>
It's possible that some KVM switches or OSes didn't like the mouse
devices, because the axes aren't wrapped in a Pointer Physical
Collection.

Also use the correct macro for the item tag for the multibyte AC Pan on
the relative mouse. No change in encoding; it's just a more meaningful
macro.

Signed-off-by: Taylor Yu <[email protected]>
In a HID Report Descriptor, the correct encoding for Logical Maximum
(255) is `26 FF 00`, not `25 FF`. The latter encodes Logical Maximum
(-1). This is a common error, and some hosts rightfully reject it.

(The correct Logical Maximum is probably 221, because otherwise, the
modifier keys could also be encoded in the key codes array, which is
invalid for their usage type. A lot of production keyboards use 255
anyway, and hosts seem to accept that.)

Signed-off-by: Taylor Yu <[email protected]>
@obra obra merged commit 4175bb2 into master Dec 14, 2023
15 checks passed
@obra obra deleted the f/merge-keyboardio-hid branch December 14, 2023 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants