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

Leonardo Keyboard.write generates incorrect codes for certain input values #1358

Open
Davonic opened this issue Apr 10, 2013 · 6 comments
Open
Assignees
Labels
Component: Core Related to the code for the standard Arduino API Library: HID The HID Arduino library Type: Bug

Comments

@Davonic
Copy link

Davonic commented Apr 10, 2013

The Arduino Leonardo Keyboard.write command generates incorrect KeyDown & KeyUp wParam values as follows:

KEY_LEFT_CTRL & KEY_RIGHT_CTRL both generate 17 but should generate 162 & 163 respectively.
KEY_LEFT_SHIFT & KEY_RIGHT_SHIFT both generate 16 but should generate 160 & 161 respectively.
KEY_LEFT_ALT & KEY_RIGHT_ALT both generate 18 but should generate 164 & 165 respectively.

I believe the following should also happen although it may have been done on purpose by the designers.

Keyboard.write() values of 48 to 57 generate the correct codes of 48 to 57 for the main pad keys 0 thru 9.
I believe the values of 166 to 174 should generate the Numpad key values of 96 to 105 but instead they also generate the main pad key ones of 48 to 57.

No other values generate 96 to 105, 160 to 165 so there is no way to generate the Numpad numeric keys or the Left & Right versions of the 3 modifiers.

All the remaining values generate the expected KeyDown/KeyUp wParam values.

These results are all on a Windows 7 system although I suspect that isn't relevant and that they in fact would be true of any Windows system.

@Davonic
Copy link
Author

Davonic commented May 13, 2013

Just curious as to whether anyone (dev or other) has even read this thread? Even if nothing's going to be done anytime soon it'd be nice to know that it's at least been noted and maybe put on a list of things to be fixed someday.

@cmaglie
Copy link
Member

cmaglie commented May 13, 2013

We read it, the list is the github issues, and this one is correctly submitted.
There is no deadline set for this specific issue.

@Davonic
Copy link
Author

Davonic commented May 16, 2013

Thanks cmaglie!

It's nice to know I haven't been wasting my time for the last month just checking for updates and will continue to watch. I'm simply using work arounds for the time being but would love to eliminate them once a fix is issued.

@nospam2000
Copy link

You should look at the issue #1391. There you can find the changes which make it possible to send any key code (actually USB HID "usages"), not only ASCII based codes plus some special codes. Some of the allowed keycodes are defined in the changed file hardware/arduino/cores/arduino/USBAPI.h the complete list can be found in chapter 10 "Keyboard/Keypad Page (0x07)" of http://www.usb.org/developers/devclass_docs/Hut1_11.pdf.

Some of the codes (any "usage" value below 120) can be reached today without patches to the Arduino code by adding 136 to the value. To send the key <Keypad 1>, use Keyboard.press(136+89)

@nospam2000
Copy link

The last sentence of the previous comment should be
To send the key "Keypad 1", use
Keyboard.press(136+89)

@Davonic
Copy link
Author

Davonic commented Jul 21, 2013

Thank You! nospam2000!

The codes you supplied properly generate the Numpad Enter, Dot & the numeric keys. The left/right ctrl, shift & alt were less of an issue for my current projects so I'm quite content to live with those issues.

@ffissore ffissore added New and removed New labels Feb 27, 2014
@ffissore ffissore modified the milestones: Release 1.6.5, Release 1.6.6 Jun 15, 2015
@ffissore ffissore modified the milestones: Release 1.6.6, 1.6.7 Nov 4, 2015
@ffissore ffissore modified the milestone: Release 1.6.7 Dec 14, 2015
@per1234 per1234 added the Library: HID The HID Arduino library label Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Related to the code for the standard Arduino API Library: HID The HID Arduino library Type: Bug
Projects
None yet
Development

No branches or pull requests

5 participants