I'm using LIRCd to capture the keys I press on my remote control, with the proper configuration file.
According to the documentation, I have to wait for the blocking function lirc_nextcode()
to return and I get a nice line to decode, like this:
0000000080bf4bb4 00 CURSOR_DOWN myremote
First number is the key value, next is the amount of repeats that this key was pressed (here 0, since I only pressed it and released it), then the key name and my remote's name.
Anyway, what I'd like to do is detect the key up of my remote.
If I press a button for a certain amount of time, this is what I get (new line every ~ 200ms):
0000000080bf4bb4 00 CURSOR_DOWN myremote
0000000080bf4bb4 01 CURSOR_DOWN myremote
0000000080bf4bb4 02 CURSOR_DOWN myremote
0000000080bf4bb4 03 CURSOR_DOWN myremote
0000000080bf4bb4 04 CURSOR_DOWN myremote
0000000080bf4bb4 05 CURSOR_DOWN myremote
0000000080bf4bb4 06 CURSOR_DOWN myremote
0000000080bf4bb4 07 CURSOR_DOWN myremote
0000000080bf4bb4 08 CURSOR_DOWN myremote
0000000080bf4bb4 09 CURSOR_DOWN myremote
0000000080bf4bb4 0a CURSOR_DOWN myremote
// I let go for 1s and press it again:
0000000080bf4bb4 00 CURSOR_DOWN myremote
So the second number increments whenever I long-press a key, but once I release it and press it again, it resets to 0.
What I want is be able to detect the moment when the repeat stops.
Now, I can see how I could implement a key up detection: if lirc_nextcode()
doesn't crack after a certain amount of time, I can consider that the key has been released.
What I'm asking you is: is there another (more proper) way to do that?
By configuring LIRCd maybe?
Or, if there's no other way to do it than with a timer, what's the best implementation?
Indeed, the lirc_getcode()
is blocking, so whenever a timer cracks, I need it to return!
edit: btw, no lirc
or lircd
tag, would be nice to have!