The USBKeyboard interface is used to emulate a keyboard over the USB port. You can type strings and send keycodes, send keys with modifiers (e.g. CTRL + 's'), function keys and also the media control keys
The USB connector should be attached to
p31 (D+), p32 (D-) and GND for the LPC1768 and the LPC11U24
I am very happy that new examples of USB hid devices examples are here at mbed community.
If I can ask I vote for USB Joystick and USB Mass storage (my idea is that mbed will act as USB mass storage device for host with /local or /SD card filesystem mounted as storage space). I found example of USB Mass storage at keil.com but there was used any virtual file system at flash or so as I remember. But porting for mbed was far away my skills. And why USB Mass storage class? You easily plug mbed via D+, D-, Vin, Gnd to host pc as USB mass storage, load files to /sd card attached filesystem as storage space, unplug mbed, restart and mbed can work with new data. Now You can already connect mbed with its mini USB connector but it mounts only /local filesystem so You are limited with 2mb capacity. Yes You can insert an SD card to pc itself but with USB mass storage class device we can use mbed as something like USB SD card reader with features of USB mass storage device.
Now back to USB Mouse, keyboard and common hid device. As I can see there are send, read and readNB "functions". I also added send report to code I work with. Reason is simple. If you want to send to mouse movement and scroll in one report, using mouse.move(10,0); mouse.scroll(1); it results to sending mouse movement in on report and scroll in second report. So I am very happy for send, read and readNB, thumb up!!!
Please if anybody interested in /sd card filesystem mounted to mbed acting as USB mass storage device, leave reply.
I am very happy that new examples of USB hid devices examples are here at mbed community.
If I can ask I vote for USB Joystick and USB Mass storage (my idea is that mbed will act as USB mass storage device for host with /local or /SD card filesystem mounted as storage space). I found example of USB Mass storage at keil.com but there was used any virtual file system at flash or so as I remember. But porting for mbed was far away my skills. And why USB Mass storage class? You easily plug mbed via D+, D-, Vin, Gnd to host pc as USB mass storage, load files to /sd card attached filesystem as storage space, unplug mbed, restart and mbed can work with new data. Now You can already connect mbed with its mini USB connector but it mounts only /local filesystem so You are limited with 2mb capacity. Yes You can insert an SD card to pc itself but with USB mass storage class device we can use mbed as something like USB SD card reader with features of USB mass storage device.
Now back to USB Mouse, keyboard and common hid device. As I can see there are send, read and readNB "functions". I also added send report to code I work with. Reason is simple. If you want to send to mouse movement and scroll in one report, using mouse.move(10,0); mouse.scroll(1); it results to sending mouse movement in on report and scroll in second report. So I am very happy for send, read and readNB, thumb up!!!
Please if anybody interested in /sd card filesystem mounted to mbed acting as USB mass storage device, leave reply.
Great to hear you like it. More interfaces are coming soon!
And note for USBMouse, you can use the update() method to send the co-ordinate, button and scroll wheel information in one go if you want!
Simon
Hi Little,
Great to hear you like it. More interfaces are coming soon!
And note for USBMouse, you can use the [[http://mbed.org/users/samux/libraries/USBDevice/m02c6o/docs/classUSBMouse.html#af2a75630840d3c975dfa4d4972b3e36b|update()]] method to send the co-ordinate, button and scroll wheel information in one go if you want!
Simon
These are great news for me, because I am very interested in USB. The next level of USB devices can be USB host with BT dongle acting as bluetooth HID. Now I am trying these new examples. Thank You very much.
These are great news for me, because I am very interested in USB. The next level of USB devices can be USB host with BT dongle acting as bluetooth HID. Now I am trying these new examples. Thank You very much.
I can final start migrating my HID designs.
On a similar note,
what about Number Lock, Scroll Lock
Function,.as well as NUMLOCK SCROLLLOCK LEDS.
Cheers, a very happy MBED'er
Ceri :)
**YIPPY
BASIC HID**
I have been dying to get this working on my MBED.
I can final start migrating my HID designs.
On a similar note,
what about Number Lock, Scroll Lock
Function,.as well as ** NUMLOCK SCROLLLOCK LEDS.**
Cheers, a very happy MBED'er
**Ceri :)
Feature added. You can now call the function lockStatus() to read the state of lock keys. As you can see in the Hello World example, I control leds according to lock keys. The first bit of the result represents NUM_LOCK, the second CAPS_LOCK and the last one SCROLL_LOCK.
Don't hesitate to share your HID designs. That sounds very cool.
Sam
Hi Ceri,
Feature added. You can now call the function lockStatus() to read the state of lock keys. As you can see in the Hello World example, I control leds according to lock keys. The first bit of the result represents NUM_LOCK, the second CAPS_LOCK and the last one SCROLL_LOCK.
Don't hesitate to share your HID designs. That sounds very cool.
Sam
Trying to run this on the LPC1768 but not having any luck. Changed out the M0 Library and put in the Mbed library and it compiles just fine but I just get an unrecognised device in windows? Any ideas
Trying to run this on the LPC1768 but not having any luck. Changed out the M0 Library and put in the Mbed library and it compiles just fine but I just get an unrecognised device in windows? Any ideas
Make sure that your hardware part is good. D- on D- and D+ on D+.
Can you try another library (USBHID, USBSerial, USBMouse,...) to see if you have the same problem ?
Which version of Windows are you using ?
Cheers
Hi Steven,
Make sure that your hardware part is good. D- on D- and D+ on D+.
Can you try another library (USBHID, USBSerial, USBMouse,...) to see if you have the same problem ?
Which version of Windows are you using ?
Cheers
Its alright I got it in the end. D+ and D- were the wrong way round despite checking the cable wire colours multiple times.
My only other problem is that my KVM doesn't recognise it. Windows installs the general keyboard driver just fine when connected directly but it seems to lock up my kvm.
I was trying to use it to switch the output on my KVM which requires the scroll lock key to be pressed twice and I have confirmed that when plugged into windows the key is pressed twice but it seems to hang the mbed before entering main (presumable inside the instantiation of the keyboard)
Any ideas? my kvm is a Aten CS-62U
Its alright I got it in the end. D+ and D- were the wrong way round despite checking the cable wire colours multiple times.
My only other problem is that my KVM doesn't recognise it. Windows installs the general keyboard driver just fine when connected directly but it seems to lock up my kvm.
I was trying to use it to switch the output on my KVM which requires the scroll lock key to be pressed twice and I have confirmed that when plugged into windows the key is pressed twice but it seems to hang the mbed before entering main (presumable inside the instantiation of the keyboard)
Any ideas? my kvm is a Aten CS-62U
This is a neat library. I've been tying this together with a wii nunchuck to make a smart mouse/controller. One thing I can't work out how to do is to send the signal for direction (up/down/left/right) keys in order to send a command to switch desktops areas. Is it possible to send these signals?
This is a neat library. I've been tying this together with a wii nunchuck to make a smart mouse/controller. One thing I can't work out how to do is to send the signal for direction (up/down/left/right) keys in order to send a command to switch desktops areas. Is it possible to send these signals?
Hi Nick,
I have just updated the USB library.
You can access down/up/left/right arrows by using:
<<code>>
keyboard.keyCode(DOWN_ARROW);
keyboard.keyCode(UP_ARROW);
keyboard.keyCode(LEFT_ARROW);
keyboard.keyCode(RIGHT_ARROW);
<</code>>
Sam
How difficult would it be to read/control key press/depress information? I'm using the library to emulate a nintendo controller over USB, and in this context there is a difference between 'send A repeatedly' and 'hold down the A button'.
Cheers,
Craig
Hi Sam,
How difficult would it be to read/control key press/depress information? I'm using the library to emulate a nintendo controller over USB, and in this context there is a difference between 'send A repeatedly' and 'hold down the A button'.
Cheers,
Craig
You can see in the USBDevice library/USBHID/USBKeyboard how I send a press/depress information (in the keyCode() method for instance). In fact two different reports are sent.
Hope that helps
Sam
Hi Craig,
You can see in the USBDevice library/USBHID/USBKeyboard how I send a press/depress information (in the keyCode() method for instance). In fact two different reports are sent.
Hope that helps
Sam
Can you describe the type of variables needed for scroll and Key_F's?
these don't work when i try them:
key_mouse.scroll(1); and key_mouse.scroll(-1);
key_mouse.keycode(Key_F1); all the way to F12
Thanks :)
Can you describe the type of variables needed for scroll and Key_F's?
these don't work when i try them:
key_mouse.scroll(1); and key_mouse.scroll(-1);
key_mouse.keycode(Key_F1); all the way to F12
Thanks :)
- Try to put scroll(10) and be sure that you have a content that can be scrolled.
- I just tested keyCode(KEY_F11) and my screen switched to full screen. Have you tested KEY_F11 ?
Sam
Hi Matthew,
Which OS are you using?
- Try to put scroll(10) and be sure that you have a content that can be scrolled.
- I just tested keyCode(KEY_F11) and my screen switched to full screen. Have you tested KEY_F11 ?
Sam
- Try to put scroll(10) and be sure that you have a content that can be scrolled.
- I just tested keyCode(KEY_F11) and my screen switched to full screen. Have you tested KEY_F11 ?
Sam
I will try that now one moment
<<quote samux>>
Hi Matthew,
Which OS are you using?
- Try to put scroll(10) and be sure that you have a content that can be scrolled.
- I just tested keyCode(KEY_F11) and my screen switched to full screen. Have you tested KEY_F11 ?
Sam
<</quote>>
I will try that now one moment
On Windows, there is another specific sequence to enter these characters: press and hold ALT followed by the code of the character (code).
The problem is that the ALT key has to be held. The current API does not allow this capability. A patch is coming soon ;)
Cheers,
Sam
Hi,
@naoki kimura: as a temporary solution, you can do a small patch to USBKeyboard to send the ESC key:
* modify in USBKeyboard.cpp (line 63)
<<code>>
{0, 0}, /* ESC */
<</code>>
to
<<code>>
{0x29, 0}, /* ESC */
<</code>>
* define in USBKeyboard.h a new symbol for the ESCAPE key:
<<code>>
#define ESCAPE 0x1b
<</code>>
* You can then invoke in your main code:
<<code>>
keyboard.keyCode(ESCAPE);
<</code>>
@alteio sdc: You can try to send unicode characters.
* On linux, unicode characters can be sent by pressing CTRL+SHIFT+U and then the hex code of the character ([[http://www.utf8-chartable.de/| list]]) (f1 for ñ) followed by "\r\n":
<<code>>
keyboard.keyCode('U', KEY_CTRL | KEY_SHIFT);
keyboard.printf("f1\r\n");
<</code>>
* On Windows, there is another specific sequence to enter these characters: press and hold ALT followed by the code of the character ([[http://www.omniglot.com/mlcomputing/diacrits_win.htm| code]]).
The problem is that the ALT key has to be held. The current API does not allow this capability. A patch is coming soon ;)
Cheers,
Sam
Hi,
Been testing with the USBkeyboard library and it on the LPC11U24 and it is recognized by the host PC fine as HID device. But I want to alter it into a true keyboard so it needs to send 'key down' and 'key release' reports. I notice in your function you send a report with the keymap code and the modifier bits first and then a report with both of them zeroed out. Is this a general 'release all keys' report ?
My goal is to send the raw keycode reports for the normal keys and CTRL, ALT and Shift (both left and right) so combinations of keys can also be sent (like Ctrl-Alt-Delete and such).
How would I do this ?
Hi,
Been testing with the USBkeyboard library and it on the LPC11U24 and it is recognized by the host PC fine as HID device. But I want to alter it into a true keyboard so it needs to send 'key down' and 'key release' reports. I notice in your function you send a report with the keymap code and the modifier bits first and then a report with both of them zeroed out. Is this a general 'release all keys' report ?
My goal is to send the raw keycode reports for the normal keys and CTRL, ALT and Shift (both left and right) so combinations of keys can also be sent (like Ctrl-Alt-Delete and such).
How would I do this ?
output of pc.printf() can be seen on terminal.
But where to see the output of the statements
keyboard.printf("Hello World from Mbed\r\n");
keyboard.keyCode('s', KEY_SHIFT);
output of pc.printf() can be seen on terminal.
But where to see the output of the statements
keyboard.printf("Hello World from Mbed\r\n");
keyboard.keyCode('s', KEY_SHIFT);
The messages should appear somewhere where you can actually tap keys with your keyboard (text editor / ....). This library emulates a keyboard.
Cheers,
Sam
Hi Pravin,
The messages should appear somewhere where you can actually tap keys with your keyboard (text editor / ....). This library emulates a keyboard.
Cheers,
Sam
I imported the program USBKeyboard_HelloWorld.cpp and compiled it online and saved USBKeyboard_HelloWorld.bin to the memory of LPC11U24.
Before pressing the reset button of the device I opened Notepad. After that I pressed the reset button of the device but still I don't see any output. What may be the problem?
i AM ONLY USING THE DEVICE WITHOUT BREADBOARD. IS THAT A PROBLEM?
I imported the program USBKeyboard_HelloWorld.cpp and compiled it online and saved USBKeyboard_HelloWorld.bin to the memory of LPC11U24.
Before pressing the reset button of the device I opened Notepad. After that I pressed the reset button of the device but still I don't see any output. What may be the problem?
i AM ONLY USING THE DEVICE WITHOUT BREADBOARD. IS THAT A PROBLEM?
I imported the program USBKeyboard_HelloWorld.cpp and compiled it online and saved USBKeyboard_HelloWorld.bin to the memory of LPC11U24.
Before pressing the reset button of the device I opened Notepad. After that I pressed the reset button of the device but still I don't see any output. What may be the problem?
i AM ONLY USING THE DEVICE WITHOUT BREADBOARD. IS THAT A PROBLEM?
Hi Pravin-
USBKeyboard uses the USB connection on pins 31 and 32 and not the built in USB connector on top of the mBed.
Mike
<<quote pravinpphule>>
I imported the program USBKeyboard_HelloWorld.cpp and compiled it online and saved USBKeyboard_HelloWorld.bin to the memory of LPC11U24.
Before pressing the reset button of the device I opened Notepad. After that I pressed the reset button of the device but still I don't see any output. What may be the problem?
i AM ONLY USING THE DEVICE WITHOUT BREADBOARD. IS THAT A PROBLEM?
<</quote>>
Hi,
Been testing with the USBkeyboard library and it on the LPC11U24 and it is recognized by the host PC fine as HID device. But I want to alter it into a true keyboard so it needs to send 'key down' and 'key release' reports. I notice in your function you send a report with the keymap code and the modifier bits first and then a report with both of them zeroed out. Is this a general 'release all keys' report ?
My goal is to send the raw keycode reports for the normal keys and CTRL, ALT and Shift (both left and right) so combinations of keys can also be sent (like Ctrl-Alt-Delete and such).
How would I do this ?
Hi
I too would really like to be able to do this.
I want to use it as a keyboard encoder for video game emulation.
Any progress on detecting the key down and key up events?
<<quote gertk>>
Hi,
Been testing with the USBkeyboard library and it on the LPC11U24 and it is recognized by the host PC fine as HID device. But I want to alter it into a true keyboard so it needs to send 'key down' and 'key release' reports. I notice in your function you send a report with the keymap code and the modifier bits first and then a report with both of them zeroed out. Is this a general 'release all keys' report ?
My goal is to send the raw keycode reports for the normal keys and CTRL, ALT and Shift (both left and right) so combinations of keys can also be sent (like Ctrl-Alt-Delete and such).
How would I do this ?
<</quote>>
Hi
I too would really like to be able to do this.
I want to use it as a keyboard encoder for video game emulation.
Any progress on detecting the key down and key up events?
Please login to post comments.