feat(usb_hid_keyboard): Adds Keyboard Layout and Sends reports just for Modifier Keys by SuGlider · Pull Request #10591 · espressif/arduino-esp32 (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation2 Commits6 Checks54 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Description of Change
This PR fixes a problem related to sending just modifier key pressing/releasing (SHIFT/CTRL/ALT).
It also adds the upstream Keyboard Layouts to the library.
Additionally it adds the Brazilian ABNT2 Keyboard Layout.
Tests scenarios
Tested with ESP32-S3 using a Keyboard Test website.
Configuration: CDC on Boot: Disabled || USB Mode: OTG(TinyUSB)
#include "USB.h" #include "USBHIDKeyboard.h" USBHIDKeyboard Keyboard; const int buttonPin = 0; // input pin for pushbutton
void setup() { // make pin 0 an input and turn on the pull-up resistor so it goes high unless // connected to ground: pinMode(buttonPin, INPUT_PULLUP); Serial.begin(115200); while (!Serial) delay(100);
Serial.println(); Serial.println("Starting USB Keyboard Device."); Serial.println();
Keyboard.begin(); USB.begin(); }
void pressRelease(uint8_t k) { Keyboard.press(k); delay(1000); Keyboard.release(k); delay(1000); }
void loop() { while (digitalRead(buttonPin) == HIGH) { // do nothing until button pin goes low delay(50); } delay(500);
// test all 8 modifier keys - press & release pressRelease(KEY_RIGHT_SHIFT); pressRelease(KEY_LEFT_SHIFT); pressRelease(KEY_RIGHT_CTRL); pressRelease(KEY_LEFT_CTRL); pressRelease(KEY_RIGHT_ALT); pressRelease(KEY_LEFT_ALT); pressRelease(KEY_RIGHT_GUI); pressRelease(KEY_LEFT_GUI);
Serial.println("Done."); }
The new Keyboard Layout needs a compatible Keyboard of the selected location.
Example:
#include "USB.h" #include "USBHIDKeyboard.h" #include "keyboardLayout/Keyboard_pt_BR.h" // using Portuguese - ABNT2 Keyboard Layout
USBHIDKeyboard Keyboard; const int buttonPin = 0; // input pin for pushbutton
void setup() { // make pin 0 an input and turn on the pull-up resistor so it goes high unless // connected to ground: pinMode(buttonPin, INPUT_PULLUP); Serial.begin(115200);
Keyboard.begin(KeyboardLayout_pt_BR); USB.begin(); }
void loop() { while (digitalRead(buttonPin) == HIGH) { // do nothing until pin 2 goes low delay(50); }
// presses all ASCII table respective keys for (char i = 32; i < 128; i++) { Keyboard.write(i); if (i == '`' || i == '~') { Keyboard.write(' '); // otherwise it may affect the next character delay(50); } delay(50); // minimum time between keystrokes for Windows OS } // sends enter Keyboard.println(); }
Related links
Fixes #10368
| Warnings | |
|---|---|
| ⚠️ | Please consider squashing your 6 commits (simplifying branch history). |
| Messages | |
|---|---|
| 📖 | This PR seems to be quite large (total lines of code: 1983), you might consider splitting it into smaller PRs |
👋 Hello SuGlider, we appreciate your contribution to this project!
Click to see more instructions ...
This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.
DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.
Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- Addressing info messages (📖) is strongly recommended; they're less critical but valuable.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.
Review and merge process you can expect ...
We do welcome contributions in the form of bug reports, feature requests and pull requests.
1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.
Generated by 🚫 dangerJS against b5b5ebd
Test Results
56 files 56 suites 4m 15s ⏱️
21 tests 21 ✅ 0 💤 0 ❌
134 runs 134 ✅ 0 💤 0 ❌
Results for commit b5b5ebd.
♻️ This comment has been updated with latest results.