Pages: [1]   Go Down
Author Topic: Leonardo keyboard leds emulation?  (Read 984 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 2
Posts: 73
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to create an USB keyboard controller with an Arduino Leonardo, but I can't find the way to emulate the keyboard leds. The PC sends the leds status to the keyboard but the Keyboard object on Arduino seems not to have any read function or any way to get the leds status.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The PC sends the leds status to the keyboard
What LED and what status are you talking about? Shift lock, num lock? If so, didn't YOU send that information to the PC?
Logged

0
Offline Offline
Jr. Member
**
Karma: 2
Posts: 73
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What LED and what status are you talking about? Shift lock, num lock? If so, didn't YOU send that information to the PC?

In the very very old XT keyboards, the num lock/caps lock/scroll lock status where sent only from keyboard to PC. Xt keyboards didn't receive info from the PC. But since many years with the AT keyboards, the communication is bidirectional, then you can connect two keyboards to the PC and hitting num lock in one affects the led status in all keyboards. Then, you can change the caps/scrool/num lock statys by software and this status is shown in the leds. Remember that keyboards does not send "letters" to the PC; it sends row/column of the key. Caps lock key is only another key with it's own row/column scan code and hitting it not necessarily will cause the caps lock led to get on or off. It is controlled by software in the PC.

 
« Last Edit: June 23, 2013, 07:35:24 am by anv » Logged

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 108
Posts: 4023
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your original posting made no mention of a second keyboard, only the one being emulated by the Leonardo, hence the comment that as you were setting the Shift lock/Num lock status using the Arduino you had sent the status to the PC and did not need to receive it back.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

0
Offline Offline
Jr. Member
**
Karma: 2
Posts: 73
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your original posting made no mention of a second keyboard, only the one being emulated by the Leonardo, hence the comment that as you were setting the Shift lock/Num lock status using the Arduino you had sent the status to the PC and did not need to receive it back.

It does not matter how-many keyboards have you connected to the PC. The system is made in a way that allows many keyboards, then, the lock status is managed by the operating system and NOT by the keyboard. Then, the leds are controlled by the PC software and NOT by the keyboard itself. When you press caps lock, it does not turns on the caps lock led. The heyboard send the scan code (row/column) to the PC. The PC software changes the status of a flag and sends back to the keyboard the command for tuning on or off the led. The led status is not decided by the keyboard chip: it is completely controlled by the PC's operating system. Then, the keyboad chip must be able to receive controls from the PC... what seems to be lacking in Arduino HID implementation...
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Then, the keyboad chip must be able to receive controls from the PC... what seems to be lacking in Arduino HID implementation...
It's open source. Quit whining and add it, if you need it.
Logged

0
Offline Offline
Jr. Member
**
Karma: 2
Posts: 73
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Then, the keyboad chip must be able to receive controls from the PC... what seems to be lacking in Arduino HID implementation...
It's open source. Quit whining and add it, if you need it.
Of corse, just now I am checking the code. But first I wanted to ask if there where some way of doing it without modifying the libraries.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you succed in this? I added support for USB keyboard LED reports myself over the weekend, maybe this is still of interest to you ...

* usb_key_leds.diff (3.01 KB - downloaded 60 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The LED patch by hartmut_holzgraefe worked great for my project!

I've got a 20 year old Maxiswitch keyboard whose controller board died and I thought it would be a good project to replace the original Intel 8085 chip with an Arduino.  This is a 124 key keyboard with extra left side function keys etc.

I used a Sparkfun Pro Micro arduino and my program does all the keyboard row and column scanning mapping into the correct HID keyboard codes.  Thanks to the patch to the USB library, the shift/num/scroll lock LEDs work too.  Plus thanks to the Arduino, it is now a USB keyboard instead of the ancient AT style.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys,

Could anyone explain how to install the "The LED patch by hartmut_holzgraefe"

I am not familiar with .diff   patchs , but I guess I would need the original to see the difference to alter the files

or could someone post their patched  USAPI.h  and HID.cpp ?

I have been looking for an example all night  smiley-confuse,  so I could modify it to show a "MUTE" LED

http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf

-------------------------------------------
Page 61

section 11   LEDPAGE(0x08)
09 Mute LED
----------------------------------------------
Thanks in advance

Rupert

« Last Edit: February 19, 2014, 08:20:30 pm by koogar » Logged

0
Offline Offline
Jr. Member
**
Karma: 2
Posts: 73
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A patch file is a file that indicates how to modify a given source code (or any text file) to obtain a new one with some changes.

Essentialy, a patch file contains data indicating something like "add this line, remove that one, etc.". It is generated by the unix command "diff" that compares two files and responds with this data. Having the patch file and the original file, one can use the command "patch" to obtain the modified version.

[edit] (found the patch file). I am applying it:
# cd /usr/share/arduino/hardware
# patch -p2 </home/anv/Descargas/usb_key_leds.diff
patching file arduino/cores/arduino/HID.cpp
patching file arduino/cores/arduino/USBAPI.h
Hunk #1 succeeded at 111 (offset -1 lines).
Hunk #2 succeeded at 131 (offset -1 lines).
Hunk #3 succeeded at 140 (offset -1 lines).

I'm attaching the result files
« Last Edit: March 06, 2014, 02:40:01 am by anv » Logged

0
Offline Offline
Jr. Member
**
Karma: 2
Posts: 73
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm attaching the patched files resulting of applying usb_key_leds.diff to arduino version 1.0.5

Not tested it yet.

* HID.cpp (14.29 KB - downloaded 41 times.)
* USBAPI.h (5.41 KB - downloaded 32 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Once these files are replaced, how what code do we use in a sketch to listen for a num/scroll/caps lock led from the PC?
Logged

Pages: [1]   Go Up
Jump to: