Skip to content

Implement keyboard service#510

Merged
kurtjd merged 2 commits into
OpenDevicePartnership:mainfrom
kurtjd:keyboard-service
Oct 22, 2025
Merged

Implement keyboard service#510
kurtjd merged 2 commits into
OpenDevicePartnership:mainfrom
kurtjd:keyboard-service

Conversation

@kurtjd

@kurtjd kurtjd commented Oct 10, 2025

Copy link
Copy Markdown
Member

Provides a HID over i2c keyboard service as well as a configurable GPIO HID-aware keyboard.

The provided GPIO keyboard uses keyberon for scanning and special key handling. It uses a basic report descriptor supporting 6 keys per report. Next is to support output reports for things like LEDs, Fn key handling, and consumer reports. In the time being users can use the HidKeyboard trait for more custom behavior if the provided implementation doesn't suit their needs.

The hid backend takes a generic HidKeyboard type and handles listening for i2c commands from the host and processing commands. It also handles asserting interrupts whenever a new key report is available instructing the host to perform a read to retrieve the report.

There is still more work to be done to make this all more flexible and configurable. This serves as a v0.1.0 so developers at least have keyboard support in the meantime.

Also plan to look more into ways to make buffer sizes more configurable and see if there are ways to prevent copying input reports multiple times as they move through the queue.

@kurtjd kurtjd self-assigned this Oct 10, 2025
@kurtjd kurtjd requested a review from a team as a code owner October 10, 2025 23:26
@kurtjd kurtjd added the enhancement New feature or request label Oct 10, 2025
@kurtjd kurtjd moved this to In review in ODP Backlog Oct 10, 2025
@github-actions

github-actions Bot commented Oct 10, 2025

Copy link
Copy Markdown

Cargo Vet Audit Passed

cargo vet has passed in this PR. No new unvetted dependencies were found.

@github-actions github-actions Bot added the cargo vet PRs pending auditor review label Oct 10, 2025
@kurtjd

kurtjd commented Oct 10, 2025

Copy link
Copy Markdown
Member Author

Cargo Vet Audit Failed

cargo vet has failed in this PR. Please run cargo vet --locked locally to check for new or updated unvetted dependencies. Details about the vetting process can be found in supply-chain/README.md

If the unvetted dependencies are not needed

Please modify Cargo.toml file to avoid including the dependencies.

If the unvetted dependencies are needed

Post a new comment with the questionnaire below to the PR to help the auditors vet the dependencies. After the auditors have vetted the dependencies, the PR will need to be rebased to pick up the new audits and pass this check.

Copy and paste the questionnaire as a new comment and provide your answers:

1. What crates (with version) need to be audited?

2. How many of the crates are version updates vs new dependencies?

3. To confirm none of the already included crates serve your needs, please provide a brief description of the purpose of the new crates.

4. Any extra notes to the auditors to help with their audits.

Unfortunately keyberon does not feature gate certain unused dependencies like usb-device. Ultimately keyberon feels pretty restricting in a few ways. May decide to fork or write a custom library.

Comment thread keyboard-service/src/gpio_kb.rs Outdated
Comment thread keyboard-service/src/gpio_kb.rs
Comment thread keyboard-service/src/lib.rs
Comment thread keyboard-service/src/lib.rs Outdated
Comment thread keyboard-service/src/hid_kb.rs
Comment thread keyboard-service/src/gpio_kb.rs Outdated
@kurtjd kurtjd force-pushed the keyboard-service branch 2 times, most recently from 5213714 to 01c74c0 Compare October 14, 2025 22:17
Comment thread keyboard-service/src/hid_kb.rs
@kurtjd kurtjd force-pushed the keyboard-service branch 2 times, most recently from a6b23db to db7d51f Compare October 15, 2025 20:13

@jerrysxie jerrysxie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kurtjd Looks good for a first vertical slice, is there a way to separate the HID report generation from the key scanner implementation?

Is there an example that shows the keyboard service in action?

@kurtjd

kurtjd commented Oct 15, 2025

Copy link
Copy Markdown
Member Author

@kurtjd Looks good for a first vertical slice, is there a way to separate the HID report generation from the key scanner implementation?

Is there an example that shows the keyboard service in action?

Thanks! Yeah I'm thinking of doing something along the lines of what Felipe suggested above, where the scan function returns only an array/slice of keys pressed (though still represented by the HID usage code for each key), then the hid backend can convert it into an input report for HID over i2c. This would also in turn make it decoupled from a future hid over espi backend (in case we decide the input report format for espi should be different than the i2c spec).

@kurtjd kurtjd force-pushed the keyboard-service branch 3 times, most recently from 3a687f0 to a2d0456 Compare October 17, 2025 18:32
@kurtjd

kurtjd commented Oct 17, 2025

Copy link
Copy Markdown
Member Author

Currently have a PR in for keyberon to not pull in the usb-device dependency to make auditing a little bit easier: TeXitoi/keyberon#140

@jerrysxie jerrysxie requested a review from a team as a code owner October 17, 2025 22:40
@jerrysxie

Copy link
Copy Markdown
Contributor

Cargo Vet Audit Failed

cargo vet has failed in this PR. Please run cargo vet --locked locally to check for new or updated unvetted dependencies. Details about the vetting process can be found in supply-chain/README.md

If the unvetted dependencies are not needed

Please modify Cargo.toml file to avoid including the dependencies.

If the unvetted dependencies are needed

Post a new comment with the questionnaire below to the PR to help the auditors vet the dependencies. After the auditors have vetted the dependencies, the PR will need to be rebased to pick up the new audits and pass this check.

Copy and paste the questionnaire as a new comment and provide your answers:

1. What crates (with version) need to be audited?
2. How many of the crates are version updates vs new dependencies?
3. To confirm none of the already included crates serve your needs, please provide a brief description of the purpose of the new crates.
4. Any extra notes to the auditors to help with their audits.

Unfortunately keyberon does not feature gate certain unused dependencies like usb-device. Ultimately keyberon feels pretty restricting in a few ways. May decide to fork or write a custom library.

@kurtjd finished cargo vet audit and pushed commit to repo

@kurtjd

kurtjd commented Oct 17, 2025

Copy link
Copy Markdown
Member Author

Cargo Vet Audit Failed

cargo vet has failed in this PR. Please run cargo vet --locked locally to check for new or updated unvetted dependencies. Details about the vetting process can be found in supply-chain/README.md

If the unvetted dependencies are not needed

Please modify Cargo.toml file to avoid including the dependencies.

If the unvetted dependencies are needed

Post a new comment with the questionnaire below to the PR to help the auditors vet the dependencies. After the auditors have vetted the dependencies, the PR will need to be rebased to pick up the new audits and pass this check.

Copy and paste the questionnaire as a new comment and provide your answers:

1. What crates (with version) need to be audited?
2. How many of the crates are version updates vs new dependencies?
3. To confirm none of the already included crates serve your needs, please provide a brief description of the purpose of the new crates.
4. Any extra notes to the auditors to help with their audits.

Unfortunately keyberon does not feature gate certain unused dependencies like usb-device. Ultimately keyberon feels pretty restricting in a few ways. May decide to fork or write a custom library.

@kurtjd finished cargo vet audit and pushed commit to repo

Thank you! Was hoping my keyberon PR could get in so there'd be one less crate for you to audit, but you're too quick. Really appreciate it!

@jerrysxie jerrysxie requested a review from felipebalbi October 18, 2025 12:33
jerrysxie
jerrysxie previously approved these changes Oct 18, 2025
@kurtjd

kurtjd commented Oct 20, 2025

Copy link
Copy Markdown
Member Author

@felipebalbi When you get a chance could you take another look?

Comment thread keyboard-service/src/lib.rs Outdated
* add audits for proc-macro-error and usb-device

* set audit-as-crates-io as false for keyberon

* prune the imports.lock

@felipebalbi felipebalbi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tullom tullom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And Kurtis said "Let there be keyboard support", and there was keyboard support.

@kurtjd kurtjd merged commit 33fcb3b into OpenDevicePartnership:main Oct 22, 2025
14 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in ODP Backlog Oct 22, 2025
@kurtjd kurtjd deleted the keyboard-service branch January 23, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cargo vet PRs pending auditor review enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants