Coder Social home page Coder Social logo

empcd's Introduction

Jeroen Massar @ GitHub

Hi, I'm Jeroen Massar and this is my little spot on GitHub. I use this space to publish hopefully useful projects and so that we can colloborate together on improving them.

In case of questions or comments don't hesitate to contact me by email at [email protected].

My Homepage with a lot of information about me and what I work on can be found at https://jeroen.massar.ch. There you'll find more details about me, along with papers & presentations about my projects and the work that I do.

Hats & Projects

I have various hats, and depending on the hat, code will appear in the relevant repository.

empcd's People

Contributors

jille avatar ldolse avatar massar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

empcd's Issues

Context awareness for REPEAT/UP actions

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 <[email protected]>
[ 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

make deb

Hi,
I'm on raspberry pi, I run "make deb" to have a debian package. An error is thrown :

pi@raspi ~/empcd $ sudo make deb dpkg-buildpackage -rfakeroot -D -us -uc dpkg-buildpackage: warning: using a gain-root-command while being root dpkg-buildpackage: source package empcd dpkg-buildpackage: source version 2014.01.08 dpkg-buildpackage: source changed by Jeroen Massar <[email protected]> dpkg-source --before-build empcd dpkg-buildpackage: host architecture armhf dpkg-source: error: syntax error in empcd/debian/control at line 16: continued value line not in field dpkg-buildpackage: error: dpkg-source --before-build empcd gave error exit status 25 debuild: fatal error at line 1357: dpkg-buildpackage -rfakeroot -D -us -uc failed make: *** [deb] Error 29

I have to remove the 2 empty lines in the debian/control at line 14 and 16. And it works.

Mouse events

Hello!

I'd say this is more a help request then an issue.

I'm able to set up keyboard to control MPD. But when I try to do the same with mouse, the events coming in empcd are shortest then those from the keyboard. Example:
[ debug] Event: T1353732547.292987, type 4, code 4, value 2
which means they are missing ": repeat, name: KEY_1, desc: 1" part.
According to http://www.kernel.org/doc/Documentation/input/event-codes.txt this events should behave the same as those from mouse in my opinion.
So my question is: What am I missing?

Hardware: Raspberry Pi "B" with Rasbian with no desktop, but the same is valid for Dell D420 with Linux Mint "Nadia".

Thanks in advance!

Diff to add mpd_enable and mpd_disable commands for switching outputs on and off.

I've never contributed to a project before, but this is what I did to get mpd_enable and mpd_disable working in empcd. I use it to switch the inputs from a small RF remote so I don't have to use an app. This is "monkey see monkey do" C coding, so I don't know if it's the best code, but it seems to work.

diff empcd.c.orig empcd.c:

404a405,453
> 
> static void f_enable(const char *arg, const char UNUSED *args);
> static void f_enable(const char *arg, const char UNUSED *args)
> {
>       int i = 0, output = 0, retry = 5;
> 
>         mpd_Status *status = empcd_status();
>         if (!status) return;
>         output = atoi(&arg[i]);
> 
>         while (retry > 0)
>         {
>                 retry--;
>                 mpd_sendEnableOutputCommand(mpd, output);
>                 if (mpd_check()) continue;
>                 mpd_finishCommand(mpd);
>                 if (mpd_check()) continue;
>                 break;
>         }
> 
>         mpd_freeStatus(status);
> }
> 
> 
> static void f_disable(const char *arg, const char UNUSED *args);
> static void f_disable(const char *arg, const char UNUSED *args)
> {
>         int i = 0, output = 0, retry = 5;
> 
>         mpd_Status *status = empcd_status();
>         if (!status) return;
>         output = atoi(&arg[i]);
> 
>         while (retry > 0)
>         {
>                 retry--;
>                 mpd_sendDisableOutputCommand(mpd, output);
>                 if (mpd_check()) continue;
>                 mpd_finishCommand(mpd);
>                 if (mpd_check()) continue;
>                 break;
>         }
> 
>         mpd_freeStatus(status);
> }
> 
> 
> 
> 
498a548,549
>       { f_enable,     true, "mpd_enable",             "<val>",        "MPD Enable Output #"           },
>       { f_disable,    true, "mpd_disable",            "<val>",        "MPD Disable Output #"          },

And you can then use the new commands in your empcd.conf:

key KEY_HOMEPAGE        UP      mpd_disable 0
key KEY_HOMEPAGE        UP      mpd_enable 1

init.d script

The init.d script contains a mistake. The info shown when daemon is started is "Starting..." In place of "Stopping...".

Compound MPD Actions

This relates to issue #3, again going back to the car radio analogy.

When you click a physical radio preset the content for that preset immediately starts playing. If you were going to implement that with MPD/empcd keys it requires three actions - clear the current playlist, load the new playlist, start playback.

Similarly saving a playlist requires two actions - delete the existing playlist, then save the new one.

I've got this working as a proof of concept with ldolse/empcd@6f0f329.

However that is a hack as it doesn't have any of the error/state checking of the other empcd functions - I wanted to use something like the existing F_CMDG(fn, f), to string together calls with proper error checking but it was getting beyond my C skills.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.