Keyboard simulation within a userspace component
- DaOne
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 196
- Thank you received: 6
15 Jul 2018 20:28 #114237
by DaOne
Keyboard simulation within a userspace component was created by DaOne
I am trying to create a custom keypad using an arduino to matrix the 130 key membrane keypad. I got the arduino side done sending each key as a code via serial. I plan to use the component that ArcEye created a while back as a base. I think I have all the pins figured as hal pins but I want the standard keyboard part to work as an actual keyboard for input. Is the a way in the .comp file to send a keystroke like if it was a real keyboard? Also if there is how would I handle "shift" commands? I can manage the shift key on the arduino side and just give every uppercase key a different key code.
Please Log in or Create an account to join the conversation.
- AnnoyingMutt
- Visitor
15 Jul 2018 21:18 #114241
by AnnoyingMutt
Replied by AnnoyingMutt on topic Keyboard simulation within a userspace component
Please Log in or Create an account to join the conversation.
- DaOne
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 196
- Thank you received: 6
15 Jul 2018 21:34 - 15 Jul 2018 21:36 #114243
by DaOne
Replied by DaOne on topic Keyboard simulation within a userspace component
Last edit: 15 Jul 2018 21:36 by DaOne.
Please Log in or Create an account to join the conversation.
- AnnoyingMutt
- Visitor
15 Jul 2018 22:59 #114247
by AnnoyingMutt
Replied by AnnoyingMutt on topic Keyboard simulation within a userspace component
Best idea would be to look at the LUFA frame work, you maybe able to create a composite device eg Keyboard & joystick, Keyboard would be handled as per normal, and use hal_input for joysyick side.
linuxcnc.org/docs/2.7/html/man/man1/hal_input.1.html
There is also this:
generichid.sourceforge.net/
Makefile needs a bit of faffing around with, nothing too serious.
The code I wrote is for a joystick device,pretty much just extending the lufa example, it appears as a standard joystick, I used the hidcomp component from franksworkshop. I used a Arduino micro, but I have a Teensy floating around as I want a more complete panel.
I'd have to fire up the old Thinkpad & Beaglebone to look at the code but it's pretty boiler plate.
linuxcnc.org/docs/2.7/html/man/man1/hal_input.1.html
There is also this:
generichid.sourceforge.net/
Makefile needs a bit of faffing around with, nothing too serious.
The code I wrote is for a joystick device,pretty much just extending the lufa example, it appears as a standard joystick, I used the hidcomp component from franksworkshop. I used a Arduino micro, but I have a Teensy floating around as I want a more complete panel.
I'd have to fire up the old Thinkpad & Beaglebone to look at the code but it's pretty boiler plate.
Please Log in or Create an account to join the conversation.
- AnnoyingMutt
- Visitor
16 Jul 2018 01:52 #114255
by AnnoyingMutt
Replied by AnnoyingMutt on topic Keyboard simulation within a userspace component
I just had a thought, maybe there is a python library or code example you could use to send key events.
I found this, haven't given it a try, not too sure if it can be used at all.
github.com/boppreh/keyboard
I found this, haven't given it a try, not too sure if it can be used at all.
github.com/boppreh/keyboard
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23560
- Thank you received: 4858
17 Jul 2018 12:47 #114374
by andypugh
Replied by andypugh on topic Keyboard simulation within a userspace component
I did do this once. At one point the matrix_kb HAL component could be configured to send keystrokes. (so it would generate scan codes and also send key strokes via a system call).
linuxcnc.org/docs/2.7/html/man/man9/matrix_kb.9.html
However I removed this feature as it was concluded that the system call to generate key strokes wasn't thread-safe.
However, it ought to be possible to pass the scan-code to a user-space module written in Python.
stackoverflow.com/questions/13564851/how...ard-events-in-python
The second answer seems to suggest some very simple ways to do what you want.
linuxcnc.org/docs/2.7/html/man/man9/matrix_kb.9.html
However I removed this feature as it was concluded that the system call to generate key strokes wasn't thread-safe.
However, it ought to be possible to pass the scan-code to a user-space module written in Python.
stackoverflow.com/questions/13564851/how...ard-events-in-python
The second answer seems to suggest some very simple ways to do what you want.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23560
- Thank you received: 4858
17 Jul 2018 12:48 #114375
by andypugh
Replied by andypugh on topic Keyboard simulation within a userspace component
(It is a pity you have more than 64 keys, otherwise the 7i73 would be an off-the-shelf solution)
Please Log in or Create an account to join the conversation.
- rodw
- Offline
- Platinum Member
Less
More
- Posts: 10738
- Thank you received: 3541
17 Jul 2018 13:09 #114381
by rodw
Replied by rodw on topic Keyboard simulation within a userspace component
Maybe this python code would work?
pythonfiddle.com/usb-keyboard-emulator/
pythonfiddle.com/usb-keyboard-emulator/
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23560
- Thank you received: 4858
17 Jul 2018 13:15 #114383
by andypugh
Replied by andypugh on topic Keyboard simulation within a userspace component
I wonder if it makes sense to split the keyboard into two sections?
One part (numbers and letters) as a USB keyboard, either real or emulated, and the other as a matrix keyboard creating HAL pins in realtime.
One part (numbers and letters) as a USB keyboard, either real or emulated, and the other as a matrix keyboard creating HAL pins in realtime.
Please Log in or Create an account to join the conversation.
- AnnoyingMutt
- Visitor
22 Jul 2018 02:11 #114651
by AnnoyingMutt
Replied by AnnoyingMutt on topic Keyboard simulation within a userspace component
Ok what you maybe able to do is use uinput.
robocup.wtb.tue.nl/svn/techunited/trunk/...nput%20subsystem.pdf
robocup.wtb.tue.nl/svn/techunited/trunk/...nput%20subsystem.pdf
Please Log in or Create an account to join the conversation.
Time to create page: 0.117 seconds