'\" t .\" Title: sendkeys .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 02/10/2023 .\" Manual: LinuxCNC Documentation .\" Source: LinuxCNC .\" Language: English .\" .TH "SENDKEYS" "1" "02/10/2023" "LinuxCNC" "LinuxCNC Documentation" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" sendkeys \- send input events based on pins or scancodes from HAL .SH "SYNOPSIS" .sp \fBloadusr sendkeys config=s8t5, 16, t12\fR .SH "DESCRIPTION" .sp This component is intended as a partner component to matrix_kb or the hostmot2 7i73 driver\&. It accepts the key\-up and key\-down event codes from either of these and converts them to keystrokes sent from a virtual keyboard\&. .sp It also allows for keystrokes to be generated by individual HAL pins\&. .sp The \fBconfig\fR parameter to the \fBloadusr\fR HAL command defines how many scancodes will be supported and how many individual pins are created\&. \fBconfig=s16\fR would support the 16 scancodes of a 4x4 matrix\&. \fBconfig=t10\fR would create 10 individual HAL pin triggers\&. \fBconfig=s16t10\fR would create one instance with both the above\&. .sp Multiple configs separated by commas will create multiple instances of the component\&. The accepted codes can be seen in the extract from the linux headers here: https://wiki\&.linuxcnc\&.org/cgi\-bin/wiki\&.pl?Scancodes .sp The component requires the user to have write permissions to /dev/uinput which is not available by default\&. To give access: .sp Create the uinput group and add the LinuxCNC user to it: .sp .if n \{\ .RS 4 .\} .nf sudo groupadd \-f uinput sudo gpasswd \-a username uinput .fi .if n \{\ .RE .\} .sp Create a new entry in \&.B/etc/udev/rules\&.d/99\-input\&.rules .sp .if n \{\ .RS 4 .\} .nf sudo echo KERNEL=="uinput", GROUP="uinput", MODE:="0660" | sudo tee /etc/udev/rules\&.d/88\-input\&.rules .fi .if n \{\ .RE .\} .sp Then reboot the machine\&. You can test that is has worked: .sp .if n \{\ .RS 4 .\} .nf ls \-l /dev/uinput crw\-rw\-\-\-\- 1 root uinput 10, 223 Nov 11 15:35 /dev/uinput .fi .if n \{\ .RE .\} .sp It is possible to link the 7i73 codes to both the matrix_kb comp and this comp, so that some codes operate HAL pins and some send keystrokes\&. Where the option exists it is \fIMUCH\fR better to use HAL pins for things like jogging and machine control\&. This component should really be used only for text entry and GUI operations\&. .sp Each key on the matrix is allocated a scan code\&. The simplest way to configure the component is to load the component and open a halmeter showing sendkeys\&.0\&.current\-event\&. Note the code for each physical key\&. (If keys do not give consistent results then you probably need to toggle the value of the matrix_kb\&.0\&.negative\-logic pin and/or invert io pins)\&. .sp Then edit the HAL file to assign a key event to each scancode\&. For example: .sp .if n \{\ .RS 4 .\} .nf setp sendkeys\&.0\&.scan\-event\-21 34 .fi .if n \{\ .RE .\} .sp To set a button to type the letter "G" The key events related to each physical key need to be set up prior to the component activating, but after the component is loaded\&. .sp To achieve this there is a pin \fBsendkeys\fR\&./N/\&.\fBinit\fR which should be set to "true" once the events to be sent for each scancode and pin have been set up\&. .sp To generate keystrokes from other sources note that a keydown is simply 0xC0 & keycode and keyup is 0x80 & keycode\&. .SH "PINS" .sp \fBsendkeys\&.N\&.keycode\fR u32 in Connect to scancode generator\&. .sp \fBsendkeys\&.N\&.current\-event\fR s32 out shows the current scancode without keyup / keydown markers\&. .sp \fBsendkeys\&.N\&.init\fR bit in set this pin TRUE once all the event parameters have been set\&. .SH "PARAMETERS" .sp \fBsendkeys\&.N\&.scan\-event\-MM\fR u32 in assign the uinput event codes associated with each scancode\&. .sp \fBsendkeys\&.N\&.pin\-event\-MM\fR u32 in assign the uinput codes associated with each HAL bit pin\&. .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf loadusr \-W sendkeys config=16t2 net scancodes hm2_7i73\&.0\&.0\&.keycode => sendkeys\&.0\&.keycode setp sendkeys\&.0\&.scan\-event\-00 34 # Key G setp sendkeys\&.0\&.scan\-event\-01 2 # Key 1 setp sendkeys\&.0\&.scan\-event\-02 3 # Key 2 setp sendkeys\&.0\&.scan\-event\-03 4 # Key 3 setp sendkeys\&.0\&.scan\-event\-04 50 # Key M setp sendkeys\&.0\&.scan\-event\-05 05 # Key 4 setp sendkeys\&.0\&.scan\-event\-06 06 # Key 5 setp sendkeys\&.0\&.scan\-event\-07 07 # Key 6 setp sendkeys\&.0\&.scan\-event\-08 31 # Key S setp sendkeys\&.0\&.scan\-event\-09 8 # Key 7 setp sendkeys\&.0\&.scan\-event\-10 9 # Key 8 setp sendkeys\&.0\&.scan\-event\-11 10 # Key 9 setp sendkeys\&.0\&.scan\-event\-12 20 # Key T setp sendkeys\&.0\&.scan\-event\-13 11 # Key 0 setp sendkeys\&.0\&.scan\-event\-14 52 # Key Dot setp sendkeys\&.0\&.scan\-event\-15 14 # Backspace setp sendkeys\&.0\&.pin\-event\-00 29 # Left Ctrl setp sendkeys\&.0\&.pin\-event\-01 57 # Space setp sendkeys\&.0\&.init 1 #Send Ctl + Space from one trigger net clear\-errors parport\&.0\&.pin\&.00\&.in sendkeys\&.0\&.trigger\-00 sendkeys\&.0\&.trigger\-01 .fi .if n \{\ .RE .\} .SH "AUTHOR" .sp Andy Pugh .SH "LICENSE" .sp GPL\-2\&.0+