Skip to content

USB USBHIDKeyboard::pressRaw() modifier key not working #9377

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

Closed
1 task done
EmileSpecialProducts opened this issue Mar 15, 2024 · 4 comments · Fixed by #9473
Closed
1 task done

USB USBHIDKeyboard::pressRaw() modifier key not working #9377

EmileSpecialProducts opened this issue Mar 15, 2024 · 4 comments · Fixed by #9473
Assignees
Labels
Area: Libraries Issue is related to Library support. Status: Solved

Comments

@EmileSpecialProducts
Copy link

Board

ESP32-S3

Device Description

ESP32-S3

Hardware Configuration

USB connection on ESP32-S3

Version

latest master (checkout manually)

IDE Name

PlatformIO / not relavant

Operating System

Win

Flash frequency

80Mhz

PSRAM enabled

no

Upload speed

USB

Description

The modifiers are not working for the USBHIDKeyboard::pressRaw(uint8_t k)/ USBHIDKeyboard::releaseRaw(uint8_t k)
The modifiers are between 0xe0 and 0xe8 this will represent the Bit in the _keyReport.modifiers.
Then you will need to subtract 0xe0 and not 0x80

Original code:

    if (k >= 0xE0 && k < 0xE8) {
        // it's a modifier key
        _keyReport.modifiers |= (1<<(k-0x80));

Needs to be

    if (k >= 0xE0 && k < 0xE8) {
        // it's a modifier key
        _keyReport.modifiers |= (1<<(k-0xE0));

Sketch

not provided.

Debug Message

There is not debug information

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@EmileSpecialProducts EmileSpecialProducts added the Status: Awaiting triage Issue is waiting for triage label Mar 15, 2024
@EmileSpecialProducts
Copy link
Author

@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this Mar 15, 2024
@P-R-O-C-H-Y P-R-O-C-H-Y added Status: Test needed Issue needs testing and removed Status: Awaiting triage Issue is waiting for triage labels Mar 15, 2024
@P-R-O-C-H-Y
Copy link
Member

Thanks @EmileSpecialProducts for reporting. I will take a look.

@P-R-O-C-H-Y P-R-O-C-H-Y added the Area: Libraries Issue is related to Library support. label Mar 15, 2024
@SuGlider
Copy link
Collaborator

SuGlider commented Apr 9, 2024

The modifiers are not working for the USBHIDKeyboard::pressRaw(uint8_t k)/ USBHIDKeyboard::releaseRaw(uint8_t k)
The modifiers are between 0xe0 and 0xe8 this will represent the Bit in the _keyReport.modifiers.
Then you will need to subtract 0xe0 and not 0x80

This is correct. The modifiers are marked in a bitmap in the HID Report Descriptor.

Bit:        7   6   5   4   3   2   1   0
          +---+---+---+---+---+---+---+---+
Byte 0    | RG| RA| RS| RC| LG| LA| LS| LC|  Modifier bits (LC=Left Control, LS= Left Shift, etc)
          +---+---+---+---+---+---+---+---+
Byte 1    |        Reserved byte          |
          +---+---+---+---+---+---+---+---+
Byte 2    |        Key 1                  |
          +---+---+---+---+---+---+---+---+
Byte 3    |        Key 2                  |
          +---+---+---+---+---+---+---+---+
Byte 4    |        Key 3                  |
          +---+---+---+---+---+---+---+---+
Byte 5    |        Key 4                  |
          +---+---+---+---+---+---+---+---+
Byte 6    |        Key 5                  |
          +---+---+---+---+---+---+---+---+
Byte 7    |        Key 6                  |
          +---+---+---+---+---+---+---+---+

@SuGlider
Copy link
Collaborator

SuGlider commented Apr 9, 2024

It shall be fixed with #9473

@SuGlider SuGlider self-assigned this Apr 9, 2024
@SuGlider SuGlider added Status: Solved and removed Status: Test needed Issue needs testing labels Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Libraries Issue is related to Library support. Status: Solved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants