Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context awareness for REPEAT/UP actions #3

Closed
ldolse opened this issue Nov 24, 2012 · 1 comment
Closed

Context awareness for REPEAT/UP actions #3

ldolse opened this issue Nov 24, 2012 · 1 comment
Assignees

Comments

@ldolse
Copy link
Contributor

ldolse commented Nov 24, 2012

I'm using empcd in conjunction with IR remotes - I want to tie playlists to numpad hotkeys and allow programming from the remote itself, similar to old-school car radios. A user should be able to hold down a hotkey to save the current playlist to the hotkey with a long press. A single brief press to the hotkey would then load the saved playlist.

In empcd I've attempted to accomplish this using UP and REPEAT events. Numpad REPEAT will save the current playlist to that key. Numpad UP will play the playlist on that key.

The problem is empcd doesn't have any context awareness around Up/Down/Repeat - so the UP event is executed when the key is released after a REPEAT event. Ideally if REPEAT triggered an action then the UP should be ignored.

Relevant lines from empcd.conf:

key KEY_1   UP  mpd_plst_load 1
key KEY_1   REPEAT  mpd_plst_save 1

Event Sequence with normal keyboard/Harmony remote:

  1. DOWN event - does nothing
  2. REPEAT event - saves existing MPD playlist
  3. UP event - loads the playlist, appending the playlist to itself

Debug log below, filtered for relevant/unique items. The actual user action was just to hold down a button for second or so, then release.

# empcd -y 10 -f -x
[  info] empcd 2012.11.23 by Jeroen Massar <jeroen@massar.ch>
[ debug] ReadConfig(/root/.empcd.conf) = error
[ debug] ReadConfig(/etc/empcd.conf) = ok
[ debug] /etc/empcd.conf@0019: mpd_port 6600
[ debug] Setting MPD_PORT to 6600
[ debug] /etc/empcd.conf@0022: eventdevice /dev/input/event0
[ debug] /etc/empcd.conf@0026: exclusive on
[ debug] /etc/empcd.conf@0057: key KEY_0 UP mpd_play
[ debug] Mapping Event KEY_0 (0/11) up (Key goes up again) to do mpd_play (MPD Start Playing) with arg <none>
[ debug] /etc/empcd.conf@0095: key KEY_1 UP mpd_plst_load 1
[ debug] Mapping Event KEY_1 (1/2) up (Key goes up again) to do mpd_plst_load (MPD Load Playlist) with arg 1
[ debug] /etc/empcd.conf@0099: key KEY_1 REPEAT mpd_plst_save 1
[ debug] Mapping Event KEY_1 (1/2) repeat (Key down and gets repeated) to do mpd_plst_save (MPD Save Playlist) with arg 1
[ debug] /etc/empcd.conf@0111: key KEY_CYCLEWINDOWS UP exec /usr/sbin/loadplaylist restore
[ debug] Mapping Event KEY_CYCLEWINDOWS (Window cycle/154) up (Key goes up again) to do exec (Execute a command) with arg /usr/sbin/loadplaylist restore
[ debug] /etc/empcd.conf@0113: key KEY_NUMERIC_POUND UP exec sima_d toggle
[ debug] Mapping Event KEY_NUMERIC_POUND (*/523) up (Key goes up again) to do exec (Execute a command) with arg sima_d toggle
[ debug] /etc/empcd.conf@0114: key KEY_NUMERIC_STAR UP exec /usr/bin/albumbler
[ debug] Mapping Event KEY_NUMERIC_STAR (#/522) up (Key goes up again) to do exec (Execute a command) with arg /usr/bin/albumbler
[  info] Running as PID 8357, processing your strokes
[ debug] Event: T1353732547.042511, type 4, code 4, value 2
[ debug] Event: T1353732547.042515, type 1, code 2, value 1: down, name: KEY_1, desc: 1
[ debug] Event: T1353732547.042515, type 0, code 0, value 0
[ debug] Event: T1353732547.292987, type 4, code 4, value 2
[ debug] Event: T1353732547.292990, type 1, code 2, value 2: repeat, name: KEY_1, desc: 1
[ debug] Event: T1353732547.292990, type 1, code 2, value 2: repeat, name: KEY_1, desc: 1, action: mpd_plst_save(1)
[ debug] Event: T1353732547.292990, type 1, code 2, value 2: repeat, name: KEY_1, desc: 1
[ debug] Event: T1353732548.818290, type 0, code 0, value 0
[ debug] Event: T1353732548.834393, type 4, code 4, value 2
[ debug] Event: T1353732548.834395, type 1, code 2, value 0: up, name: KEY_1, desc: 1
[ debug] Event: T1353732548.834395, type 1, code 2, value 0: up, name: KEY_1, desc: 1, action: mpd_plst_load(1)
[ debug] Event: T1353732548.834395, type 1, code 2, value 0: up, name: KEY_1, desc: 1
[ debug] Event: T1353732548.834396, type 0, code 0, value 0
[ debug] Event: T1353732550.802553, type 4, code 4, value 29
@ghost ghost assigned massar Nov 26, 2012
@massar
Copy link
Owner

massar commented Feb 27, 2013

Implemented in e376081 with the help of a special EV_KEY value "UPNR" which stands for "Up No Repeat" which causes an UP event to be ignored if the previous event for that type/code was REPEAT.

Only works for EV_KEY though as that is the only one we have this information for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants