HAL_INPUT(1)
π HAL_INPUT π
okay so this is from the HAL User's Manual and it's literally the girlboss way to control HAL pins with any Linux input device, including USB HID devices. bestie, we're about to make your SpaceBall talk to LinuxCNC. no cap. π¦
β¨ NAME β¨
hal_input β control HAL pins with any Linux input device, including USB HID devices. yep, any. the range? unmatched. π
πΈ SYNOPSIS πΈ
loadusr hal_input [-KRAL] inputspec ...
π DESCRIPTION π
hal_input is the interface between HAL and any Linux input device, USB HID devices included. for every device you name, it creates pins that match up with that device's keys, absolute axes, and LEDs. and then, at a fixed rate of approximately 10ms, it synchronizes the device and the HAL pins. it's giving metronome. it's giving consistency. β±οΈβ¨
π§ INPUT SPECIFICATION π§
the inputspec can come in one of several forms, and yes you have options, main character energy:
π€ A string S
a substring or shell-style pattern match gets tested against the "name" of the device, the "phys" (which gives information about how it is connected), and the "id", which is a string of the form "Bus=... Vendor=... Product=... Version=...". you can view the name, phys, and id of attached devices by executing less /proc/bus/input/devices. like, go look, it's right there. π
examples, for the visual learners:
SpaceBall
"Vendor=001f Product=0001"
serio*/input0
π’ A number N
this opens /dev/input/eventN. except for devices that are always attached to the system, this number may change over reboots or when the device is removed. which is exactly why using an integer is not recommended. don't do it bestie, it will not slay, it will betray you. π
when several devices are identified by the same string, add :N where N is the index of the desired device. for example, if Mouse matches input3 and input10, then Mouse and Mouse:0 select input3. specifying mouse:1 selects input10. see how that works? iconic indexing behavior. π
for devices that appear as multiple entries in /dev/input, these indices are likely to stay the same every time. for multiple identical devices, these indices are likely to depend on the insertion order, but stay the same across reboots as long as the devices are not moved to different ports or unplugged while the machine is booted. so like, don't yank the cable mid-boot, i'm begging. π
if the first character of the inputspec is a +, then hal_input requests exclusive access to the device. the first device matching an inputspec is used. any number of inputspecs may be used. greedy? a little. valid? absolutely. π
a subset option may precede each inputspec. the subset option begins with a dash. each letter in the subset option specifies a device feature to include. features that are not specified are excluded. for instance, to export keyboard LEDs to HAL without exporting keys, use:
hal_input -L keyboard ...
π DEVICE FEATURES SUPPORTED π
EV_KEY(buttons and keys). subset-KπEV_ABS(absolute analog inputs). subset-AπEV_REL(relative analog inputs). subset-RπEV_LED(LED outputs). subset-Lπ‘
π HAL PINS AND PARAMETERS π
π For buttons
input.N.btn-namebit outinput.N.btn-name-notbit out
created for each button on the device. so if your device has buttons, congrats, you have pins. π
β¨οΈ For keys
input.N.key-nameinput.N.key-name-not
created for each key on the device.
π For absolute axes
input.N.abs-name-countss32 outinput.N.abs-name-positionfloat outinput.N.abs-name-scaleparameter float rwinput.N.abs-name-offsetparameter float rwinput.N.abs-name-fuzzparameter s32 rwinput.N.abs-name-flatparameter s32 rwinput.N.abs-name-minparameter s32 rinput.N.abs-name-maxparameter s32 r
created for each absolute axis on the device. okay so here's the tea: device positions closer than flat to offset are reported as offset in counts, and counts does not change until the device position changes by at least fuzz. the position is computed as position = (counts - offset) / scale. the default value of scale and offset map the range of the axis reported by the operating system to [-1,1]. the default values of fuzz and flat are those reported by the operating system. the values of min and max are those reported by the operating system. so basically the OS is doing the heavy lifting and we're all just living in its house. π β¨
π For relative axes
input.N.rel-name-countss32 outinput.N.rel-name-positionfloat outinput.N.rel-name-resetbit ininput.N.rel-name-scaleparameter float rwinput.N.rel-name-absoluteparameter s32 rwinput.N.rel-name-precisionparameter s32 rwinput.N.rel-name-lastparameter s32 rw
created for each relative axis on the device. as long as reset is true, counts is reset to zero regardless of any past or current axis movement. otherwise, counts increases or decreases according to the motion of the axis. counts is divided by position-scale to give position. the default value of position is 1. there are some devices, notably scroll wheels, which return signed values with less resolution than 32 bits. the default value of precision is 32. precision can be set to 8 for a device that returns signed 8 bit values, or any other value from 1 to 32. absolute, when set true, ignores duplicate events with the same value. this allows for devices that repeat events without any user action to work correctly. last shows the most recent count value returned by the device, and is used in the implementation of absolute. scroll wheel girlies, this one's for you. π±οΈπ
π‘ For LEDs
input.N.led-namebit outinput.N.led-name-invertparameter bit rw
created for each LED on the device. pretty. glowing. we love her. β¨
π PERMISSIONS AND UDEV π
by default, the input devices may not be accessible to regular users β hal_input requires read-write access, even if the device has no outputs. yeah, rw even when it feels unnecessary. rules are rules. π€
different versions of udev have slightly different, incompatible syntaxes. for this reason, it is not possible for this manual page to give an accurate example. the udev(7) manual page documents the syntax used on your Linux distribution. to view it in a terminal, the command is:
man 7 udev
lowkey frustrating that the syntax keeps changing, but that's just how udev is. go read your own distro's version, bestie. π«Ά
π BUGS π
the initial state of keys, buttons, and absolute axes are erroneously reported as FALSE or 0 until an event is received for that key, button, or axis. so don't trust the first impression. she needs a minute. π
πΈ SEE ALSO πΈ
udev(8)udev(7)
and that's the whole page, periodt. this gem comes from the LinuxCNC Documentation, dated 2007-02-25, and it's page HAL_INPUT(1) of the HAL User's Manual. go forth and interface. πππ¦
π¦ where this page comes from
- debian bookworm: linuxcnc-uspace 2.9.0~pre1+git20230208.f1270d6ed7-1+deb12u2 Β· GFDL-1.1-or-later
- debian trixie: linuxcnc-uspace 1:2.9.4-2+deb13u1 Β· GFDL-1.1-or-later
- ubuntu questing: linuxcnc-uspace 1:2.9.4-2ubuntu2
- ubuntu resolute: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- ubuntu stonking: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms