Getting events from /dev/input/ devices (linux)

Hello everyone!

I’ve got a custom UI board/hat for Raspberry Pi that includes some buttons and encoders. These are all setup with a device overlay so they show up as /dev/input/ devices like this (output from dmesg):

[    3.903843] input: keys as /devices/platform/keys/input/input4
[    4.241849] input: soc:knob3 as /devices/platform/soc/soc:knob3/input/input5
[    4.262185] input: soc:knob2 as /devices/platform/soc/soc:knob2/input/input6
[    4.274703] input: soc:knob1 as /devices/platform/soc/soc:knob1/input/input7
[    4.284326] input: soc:knob4 as /devices/platform/soc/soc:knob4/input/input8

What is my best approach to work with these inputs from OF?

Likely it’s all in the docs for the HAT - and maybe some configuration of ofSerial. But easier still might be that if via the terminal you can poll each location for a value (ie. the terminal prints the encoder or button value), then call it via string ofSystem(const string &command) - then you could make that an ofThread, and generate buttonPressed and encoderValueChanged events.

Well… I’m the guy who made/designed the HAT in question so… :grin:

The buttons (keys) do get sent to the terminal as keycodes. But, the encoder values do not print there.

The other (audio) software I use with this device uses some C code to get values from the GPIOs (where the buttons/encoders are connected to the pi). Maybe I need to look at the GPIO addon?