Keyboard simulation within a userspace component

  • AnnoyingMutt
  • AnnoyingMutt's Avatar
  • Visitor
  • Visitor
23 Jul 2018 23:01 #114726 by AnnoyingMutt
Replied by AnnoyingMutt on topic Keyboard simulation within a userspace component
I'm working on a user component using libevdev that may just be the answer.

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

  • AnnoyingMutt
  • AnnoyingMutt's Avatar
  • Visitor
  • Visitor
24 Jul 2018 11:05 - 24 Jul 2018 11:12 #114739 by AnnoyingMutt
Replied by AnnoyingMutt on topic Keyboard simulation within a userspace component
See this new thread for a proof of concept:
forum.linuxcnc.org/10-advanced-configura...m-via-userspace-comp
Last edit: 24 Jul 2018 11:12 by AnnoyingMutt.

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

  • rodw
  • rodw's Avatar
  • Away
  • Platinum Member
  • Platinum Member
More
24 Jul 2018 11:36 #114742 by rodw
I have not written any userspace components but just wondering if the while(1) blocks execution at all?

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

  • AnnoyingMutt
  • AnnoyingMutt's Avatar
  • Visitor
  • Visitor
24 Jul 2018 20:57 #114767 by AnnoyingMutt
Replied by AnnoyingMutt on topic Keyboard simulation within a userspace component
From the docs
option userspace yes - (default: no) If specified, this file describes a userspace (ie, non-realtime) component, rather than a regular (ie, realtime) one. A userspace component may not have functions defined by the function directive. Instead, after all the instances are constructed, the C function void user_mainloop(void); is called. When this function returns, the component exits. Typically, user_mainloop() will use FOR_ALL_INSTS() to perform the update action for each instance, then sleep for a short time. Another common action in user_mainloop() may be to call the event handler loop of a GUI toolkit.
From that I guess some form of loop is needed. (my basic understanding)
A While loop is used here
forum.linuxcnc.org/forum/18-computer/225...pendant-for-linuxcnc

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

  • AnnoyingMutt
  • AnnoyingMutt's Avatar
  • Visitor
  • Visitor
01 Aug 2018 01:15 #115273 by AnnoyingMutt
Replied by AnnoyingMutt on topic Keyboard simulation within a userspace component

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.


This company has some interesting products
www.hagstromelectronics.com/usb-asc232-shp.html

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

More
01 Aug 2018 03:54 #115276 by dm17ry
i did a membrane keyboard controller using a STM32 as a USB HID. it emulates a standard keyboard plus a bunch of other keys which were handled by hal_input comp. rotary encoder and analog joystick can switch between being a mouse with a wheel and linuxcnc's MPG and joystick. 24-pos rotary switch is handled by an ADC. drives a chain of RGB addressable LEDs. also has a few hardware buttons for cycle start/stop etc...

if someone interested can share the code, but it is a bit more than a little messy, i think... :)

Attachments:
The following user(s) said Thank You: silopolis

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

  • AnnoyingMutt
  • AnnoyingMutt's Avatar
  • Visitor
  • Visitor
01 Aug 2018 08:11 #115287 by AnnoyingMutt
Replied by AnnoyingMutt on topic Keyboard simulation within a userspace component
Ok that is cool.

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

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
01 Aug 2018 09:01 #115291 by tommylight
Replied by tommylight on topic Keyboard simulation within a userspace component

Ok that is cool.

+1

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

  • AnnoyingMutt
  • AnnoyingMutt's Avatar
  • Visitor
  • Visitor
01 Aug 2018 11:08 #115298 by AnnoyingMutt
Replied by AnnoyingMutt on topic Keyboard simulation within a userspace component
I've just been playing around with some userspace hid code which reads stdin to emulate a simple 2 axis 6 button joystick.

One wonders if this could be extended to read a serial port rather than stdin and emulate a keyboard & joystick device.

Linux kernel sample code for user space HID.
github.com/torvalds/linux/blob/master/sa.../uhid/uhid-example.c

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

More
01 Aug 2018 11:56 #115300 by andypugh
For a keyboard matrix like the one shown I think I prefer a system where:

1) The matrix is scanned in realtime, and keys with a real-time permanent function are netted directly.
2) Keys which are "only" used for typing and data entry are passed through to a user-space component to be converted to keystrokes.

This should remove the problem with keyboard-jogging where sometimes the OS appears to not spot the key-up code, leading to longer-than-desired jogs.
The following user(s) said Thank You: silopolis

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

Time to create page: 0.091 seconds
Powered by Kunena Forum