[SOLVED] [TRIGGERHAPPY] Use USB audio dongle's volume buttons in Retropie
-
Hi everyone,
I'm studying since different months how to do works USB dongle's audio button to set the emulation station volume, without success.
I've installed my standard USB audio sound card, and following different tutorials I've setted it as primary sound card.
This is my amixer outputpi@retropie:~ $ amixer Simple mixer control 'Speaker',0 Capabilities: pvolume pswitch pswitch-joined Playback channels: Front Left - Front Right Limits: Playback 0 - 151 Mono: Front Left: Playback 145 [96%] [-1.19dB] [on] Front Right: Playback 145 [96%] [-1.19dB] [on] Simple mixer control 'Mic',0 Capabilities: pvolume pvolume-joined cvolume cvolume-joined pswitch pswitch-joined cswitch cswitch-joined Playback channels: Mono Capture channels: Mono Limits: Playback 0 - 127 Capture 0 - 16 Mono: Playback 0 [0%] [0.00dB] [off] Capture 16 [100%] [23.81dB] [on] Simple mixer control 'Auto Gain Control',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off]
and this is the output of cat
pi@retropie:~ $ cat /etc/asound.conf pcm.card0 { type hw card 0 } ctl.card0 { type hw card 0 } pcm.!default card0
This is my retopie version
pi@retropie:~/RetroPie-Setup $ git show commit fffbe6f160373b7fef7744789f0a56fc46dd6f08 Author: Jools Wills <buzz@exotica.org.uk> Date: Thu Sep 21 13:17:37 2017 +0100 retropie-setup - bump version to 4.3 diff --git a/retropie_packages.sh b/retropie_packages.sh index 819f035..b26d74f 100755 --- a/retropie_packages.sh +++ b/retropie_packages.sh @@ -9,7 +9,7 @@ # at https://raw.githubusercontent.com/RetroPie/RetroPie-Setup/master/LICENSE.md # -__version="4.2.22" +__version="4.3" [[ "$__debug" -eq 1 ]] && set -x
I've tried to follow this guide
amixer -l Note the name of your mixer. Mine was named "Speaker". Now run: git clone https://github.com/Aloshi/EmulationStation.git nano EmulationStation/es-app/src/VolumeControl.cpp Change line 8 from: const char * VolumeControl::mixerName = "PCM"; to match the name of your mixer ("Speaker" in my case): const char * VolumeControl::mixerName = "Speaker"; Press Ctrl+O and Enter to save the file, then Ctrl+X to exit Nano. Then, follow the instructions for building the code from the main Github page: sudo apt-get install libsdl2-dev libboost-system-dev libboost-filesystem-dev libboost-date-time-dev libboost-locale-dev libfreeimage-dev libfreetype6-dev libeigen3-dev libcurl4-openssl-dev libasound2-dev libgl1-mesa-dev build-essential cmake fonts-droid cd EmulationStation cmake . make make install Restart Emulation Station, and now you should be able to control your volume.
But also this method hasn't worked for me
How I can solve this issue?
Thanks for all the help that you can provide me.
Regards
-
@blackjackpsp Hello and welcome to Retropie-Forum. To reduce the time volunteers need to provide help and to frame the question right make sure you read and understood https://retropie.org.uk/forum/topic/3/read-this-first
Thanks.I am not sure do you want to control the volume physically (since you refer to buttons) or the volume controlled by software?
For the former I would go for a potentiometer (https://en.wikipedia.org/wiki/Potentiometer#Audio_control). 50KOhm or the like, get a dual one if you have stereo. Else a single potentiometer will do (Mono). Put the potientiometer between the USB audio device line out and amplifier line in. Some Amps (e.g. some models from Sure Electronics) do have a pinout to attach such a potentiometer on the PCB.
Since the USB audio volume tends to be reset to a default value (by the firmware of USB device) between shutdown/reboot in my case I added
amixer sset 'Headphone' 100%
to/etc/rc.local
(my USB device is registered as 'Headphone').
I control the actual speaker volume with a potentiometer.For the latter I have no idea if it works as you described. Maybe you can pull the author of the hint into this thread?
HTH
-
The latest Emulationstation version has a few improvements in this area, allowing you to choose more than
PCM
as output device. However, judging from your version of RetroPie, you're running a release from more than 1 year ago, so these improvements would not be visible unless you upgrade your Emulationstation version. -
@Lolonois Hi Lolonois,
I want to control the volume by software, by catching usb dongle button pression, and update system volume.Any suggestion in this direction?
thank for very useful response
:)
-
@blackjackpsp you can go the way of "catching usb dongle button pression" but I assume it can be done easier (see second paragraph).
However, if you insist on your approach you should find out if the USB Audio registers also a HID Keyboard (lsusb
). If yes, then you may be lucky and can find which key presses on a keyboard (most likely multimedia enhanced USB keyboard - the ones with dedicated volume keys aso.) the USB audio buttons do recognize. This varies from USB audio device vendor to vendor. IMHO a troublesome solution.I would follow the
amixer sset
aproach which should give you the same result and should be easier to implement:- With a physical keyboard attached you can map commands with
triggerhappy
. e.g.amixer sset '<your device>' 10%+
(or10+
depends on audio device, in this case not theLimits:
output ofamixer
to calculate to percent) for volume up. Define a second keystroke for volume down. - With a acrade button / gamepad only setup you could use e.g.
jslisten
github.com to achieve the same.
HTH
- With a physical keyboard attached you can map commands with
-
Hi lolonois, thanks for very helpful suggestions.
I've tried to trigger the button pressed with triggerhappy's instructionthd --dump /dev/input/*
and I've created a conf file in
/etc/triggerhappy/triggers.d/sound.conf where I've setted as follow/etc/triggerhappy/triggers.d/sound.conf
Change mixer volume when pressing the appropriate keys (or holding them)
KEY_VOLUMEUP 0 /usr/bin/amixer set Speaker 5%+
KEY_VOLUMEUP 1 /usr/bin/amixer set Speaker 5%+
KEY_VOLUMEDOWN 0 /usr/bin/amixer set Speaker 5%-
KEY_VOLUMEDOWN 1 /usr/bin/amixer set Speaker 5%-but after restart the daemon, the button doesn't change the Speaker volume
The single instruction /usr/bin/amixer set Speaker 5%+ worksWhat am I doing wrong?
Thanks in advance for all the help
-
Eat the elephant piece by piece... (remember "how to eat an elephant")
Just some ideas you might try, I never used triggerhappy:
- Try to start triggerhappy not as daemon (omit
--daemon
switch if I understood the sourcethd.c
right) - Add some
fprintf(stderr, "your text")
at least attriggerparse.c
, methodparse_trigger()
andtrigger.c
methodrun_triggers()
recompile or attach a debugger and inspect these two methods. - From the distance I assume your commands are not loaded at all, or for the the system call (see
run_triggers()
you need to use doublequotes, extra question: Do your actions work in triggerhappy if you use no%
and+
, e.g.amixer sset 'Speaker' mute
/unmute
/ absolute number) - Check the issues and pull requests from triggerhappy maybe you ran into one of them, e.g. this issue or this PR
HTH
- Try to start triggerhappy not as daemon (omit
-
Hi @Lolonois ,
I've investigated following the issue in the 4th point, and then the thd worked when I call from command line, so I've inserted in the crontab the command /usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --socket /run/thd.socket --user nobody --deviceglob /dev/input/event* after 1 minute from reboot and the dongle buttons now set the system volume.
The next step will be use the new 4.4 version of retropie and try if the issue has been solved.
Thanks for all the help.
-
@blackjackpsp good to see you have found a workaround as solution. If you think this topic can be marked as solved please do adapt the subject of your inititial post (e.g. replace [HELP] with [Solved]).
If you want you may add Triggerhappy as additional label.Cheers
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.