Based on Attach functions to a push button article, I was able to bind a button to a script residing in /etc/rc.button/.
I defined in my button in my dts file such as below.
keys {
compatible = "gpio-keys";
btn_0 {
label = "button_0";
gpios = <&gpio 40 GPIO_ACTIVE_LOW>;
linux,code = <BTN_0>;
};
btn_1 {
label = "button_1";
gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
linux,code = <BTN_1>;
};
};
And the simple script I made for BTN_1 is below, which run perfectly.
#!/bin/sh
[ "${ACTION}" = "released" ] || exit 0
if [ "$SEEN" -ge 5 ]
then
echo "BTN_1 is pressed" > /dev/console
fi
return 0
Now, I would like to test and try to capture a similar result in C++, but from the article it seems like the best way is to check for the /dev/input/eventX. However I do not see that in my device.
Did I miss something or made a mistake in initializing my button in my dts file?