[How to do instruction] Using FLIRC and other USB input devices for remote control - Printable Version +- Moode Forum (https://moodeaudio.org/forum) +-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3) +--- Forum: FAQ and Guides (https://moodeaudio.org/forum/forumdisplay.php?fid=9) +--- Thread: [How to do instruction] Using FLIRC and other USB input devices for remote control (/showthread.php?tid=3023) |
Using FLIRC and other USB input devices for remote control - TheOldPresbyope - 09-28-2020 Introduction Beginning with release 6.4.2, a software package named triggerhappy has been included in moOde to support the use of commonly available USB volume knobs. As a bonus, its inclusion also makes trivial using the FLIRC IR-to-USB adapter and other USB devices which enumerate as HID input devices. Quoting from the thd (triggerhappy daemon) man page Quote:Triggerhappy is a hotkey daemon that operates on a system wide scale. It watches all configured input devices for key, switch or button events and can launch arbitrary commands specified by the administrator. This Guide is devoted to getting set up with the FLIRC adapter and an IR-remote media controller of your choice. The same setting-up process should apply to other USB input devices such as keyboards and the like. Steps Step 1. Enable the triggerhappy daemon. By default, the daemon is disabled. If you haven’t already enabled it so you can use a USB volume knob then do the following. Go to the m>Configure>Audio config screen and scroll down to USB volume knob. Move the USB volume knob slider to ON and click SET. You’re done. Step 2. Plug the FLIRC into a USB port on your moOde player's RPi if you haven’t already done so. Step 3. Determine the keycode mappings for your IR-remote media controller and FLIRC combination. The FLIRC supports more than one pairing profile. I assume you have read your FLIRC documentation and made choices. All that matters in the following is that the FLIRC emit a keycode for each key you wish to use on your controller. Log into the command line on your moOde player using moOde's built-in Web SSH terminal or using SSH from some other computer. In the home directory, start the command Code: thd --dump /dev/input/event* | tee keycodes.cap While the command is running, press each of the keys you wish to use on the controller, one at a time, noting the order. In response, you’ll see a succession of line pairs appear in the output. When done, type ^C to kill the running command and automatically save the output of this session in the file keycodes.cap. (This capture of the output to a file is solely for convenience. The "| tee keycodes.cap" portion of the command can be skipped.) Here’s an example of the output for just the first key press and release on my controller Code: pi@moode:~ $ thd --dump /dev/input/event* | tee keycodes.cap We are interested in the information on the commented lines (which conveniently are formatted the way we’ll format the lines in our configuration file). Each line beginning with a “#” character reports the keycode emitted by the FLIRC, such as “KEY_A”, and the event code, “1” or “0”, which stand for key pressed and key released, respectively. Finally, the line ends with the string “command” as a placekeeper for the command we want to execute on the event. Step 4. Decide on the programmatic moOde command you want to associate with each keycode. Some obvious candidates are volume up: /var/www/vol.sh -up 5 volume down: /var/www/vol.sh -dn 5 mute/unmute: /var/www/vol.sh -mute play/pause: /usr/bin/mpc toggle play next: /usr/bin/mpc next play previous: /usr/bin/mpc prev add favorites playlist to the end of the queue: /usr/bin/mpc load Favorites clear the queue and add the default playlist: /usr/bin/mpc clear; /usr/bin/mpc load “Default Playlist” Note that capitalization matters; so does using quotes to avoid problems with the shell interpreting spaces in a name. Note also that I specify the full pathname for mpc out of an abundance of caution (old Unix habits die hard). A bare "mpc" will do here. It is possible to get quite baroque but this isn’t a guide to all the ways one can abuse moOde/MPD commands Step 4. Use your favorite Linux text editor---nano, vi, or such---to create a triggerhappy configuration file for your FLIRC and controller. Make it easy on yourself and do this in the home directory. This task becomes marginally easier using the keycodes.cap file we created above. Code: grep ^# keycodes.cap | grep $'\x9'1 > flirc.conf This preselects all the key-press events (code 1). All that remains is to remove the "#" character and substitute your command for the string "command". As an example of the result of this step, here is the content of a trial flirc.conf for my FLIRC/Roku controller combo with a pairing profile of my own. Code: pi@moode:~ $ cat flirc.conf Not shown here is that triggerhappy can detect if a key is held depressed so it is possible to create separate actions for a short press (code 1) and a long press (code 2). Note that triggerhappy aggregates the actions for all the configuration files it finds. In some cases, triggerhappy's advanced modes and tags may be necessary to disambiguate an event. Consult the thd man page for details on modes and tags. Step 5. Copy the flirc.conf to the proper triggerhappy directory (As suggested above, there can be many conf files present. For example, a media.conf file is already present in moOde to handle the USB volume knob.) Code: sudo cp flirc.conf /etc/triggerhappy/triggers.d/flirc.conf Step 6. Restart the triggerhappy daemon so it can pick up the new configuration file. I usually do this by turning the daemon off and then on again on the Audio config page but one can also simply reboot. Step 7. It’s time to start pushing buttons! Debugging Check the moOde log for signs the USB volume knob job didn't run. Check that the triggerhappy daemon process is running. Check the mpd log for telltale signs such as trying to load a nonexistent playlist (maybe because of a capitalization error or missing quotation marks). Final remarks: 1. This Guide supercedes my previous guide. 2. By repeating steps 3-6 it should be possible to add more USB input devices to your stable. RE: Using FLIRC and other USB input devices for remote control - ahlbar75 - 10-22-2020 This worked well for me and I was able to set this up with my Logitech remote quite quickly. I thank you for that! I am writing to ask if it would be possible to map a KEY command to the Moode UI Asterisk * button. I quite like the ability to load a random album and would like to add the ability to do so from my remote if possible. I don't see that I can do this using the mpc <command> function like the other KEY mappings (first time looking at it so I could be wrong too..) so I am guessing the logic behind the Asterisk button is different or more involved. Thoughts? Thanks again!! RE: Using FLIRC and other USB input devices for remote control - TheOldPresbyope - 10-22-2020 (10-22-2020, 08:50 PM)ahlbar75 Wrote: This worked well for me and I was able to set this up with my Logitech remote quite quickly. I thank you for that! Glad to hear this has been working for you. The random play capability is not a basic MPD function, so mpc doesn't include a command for it. Unfortunately, I don't use the random play capability and can't tell you off the top of my head how to invoke it in moOde from the command line. You'll have to ask @Tim Curtis. Good luck. Regards, Kent RE: Using FLIRC and other USB input devices for remote control - sheridat - 10-23-2020 A previous post at this link covers this. http://moodeaudio.org/forum/showthread.php?tid=1592&highlight=random+album+script then read http://moodeaudio.org/forum/showthread.php?tid=2638 RE: Using FLIRC and other USB input devices for remote control - Tim Curtis - 10-23-2020 It's really just a matter of demand for such a feature or a dev wanting to donate their time to implement it. http://moodeaudio.org/forum/showthread.php?tid=3100&pid=26396#pid26396 RE: Using FLIRC and other USB input devices for remote control - ahlbar75 - 10-23-2020 Thanks all, I opened a separate thread: http://moodeaudio.org/forum/showthread.php?tid=3100 sheridat suggested two threads detailing this could be done by installing and using mpdrandom. I have now mapped a button on my remote that selects a random album from my library and starts playing the first song. Thanks again to all! RE: Using FLIRC and other USB input devices for remote control - musiclover - 11-09-2020 One a freshly installed 6.7.1 if I say thd –dump/dev/input/event* | tee keycodes.cap I get Error opening '–dump/dev/input/event*': No such file or directory So I found out that there is a type in the first Code-Box, the command must be like in the second one: thd --dump /dev/input/event* | tee keycodes.cap RE: Using FLIRC and other USB input devices for remote control - musiclover - 11-30-2020 So I managed to activate Flirc on moOde and remote controlling my Pi is working. But the funny thing is: I have to press each button twice before it works. From the command line e. g. "mpc toggle" works perfectly well, but activating it from the remote needs two keystrokes. Anyone any idea? RE: Using FLIRC and other USB input devices for remote control - DRONE7 - 11-30-2020 (Assume you have updated the Flirc Firmware to the latest ?) Plug the flirc into a PC and open the Flirc app. There is a setting for adjusting the key response. Adjust and save then plug back into the Pi. https://support.flirc.tv/hc/en-us/articles/201366933-Double-Key-Presses Otherwise there is an old posting from Jason on the Flirc forum indicating a problem with some remotes and a fix. Ymmv. http://forum.flirc.tv/index.php?/topic/9-double-key-presses/#elControls_19_menu RE: Using FLIRC and other USB input devices for remote control - zOr7gA8 - 12-01-2020 This sounds like a interesting option to test. |