Keyboard simulation within a userspace component

More
15 Jul 2018 20:28 #114237 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.

More
15 Jul 2018 21:18 #114241 by InMyDarkestHour
Why not go with USB ?

Free USB Stack, one I've used myself, www.fourwalledcubicle.com/LUFA.php

Please Log in or Create an account to join the conversation.

More
15 Jul 2018 21:34 - 15 Jul 2018 21:36 #114243 by DaOne
Did you happen to have any more information on your previous use? Not against using another method. I really want hal pins from all the keys other than the actual keyboard and number pad. Maybe this can be done in python?

Here is what I am working with...


Attachments:
Last edit: 15 Jul 2018 21:36 by DaOne.

Please Log in or Create an account to join the conversation.

More
15 Jul 2018 22:59 #114247 by InMyDarkestHour
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.

Please Log in or Create an account to join the conversation.

More
16 Jul 2018 01:52 #114255 by InMyDarkestHour
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

Please Log in or Create an account to join the conversation.

More
17 Jul 2018 12:47 #114374 by andypugh
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.

Please Log in or Create an account to join the conversation.

More
17 Jul 2018 12:48 #114375 by andypugh
(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.

More
17 Jul 2018 13:09 #114381 by rodw

Please Log in or Create an account to join the conversation.

More
17 Jul 2018 13:15 #114383 by andypugh
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.

Please Log in or Create an account to join the conversation.

More
22 Jul 2018 02:11 #114651 by InMyDarkestHour

Please Log in or Create an account to join the conversation.

Time to create page: 0.154 seconds
Powered by Kunena Forum