USB volume controll not working in retropie
-
Hello,
USB audio, again :p
I'm trying to make a console based around the Pi Zero, with a baked-in C-media HS-100 chip. this is the chip in most USB soundcard dongles.
I'm getting sound out of the HS-100, but retropie isn't picking up its volume feedback. to explain a little about the chip: the chip has input pins for volume control, so you could pull the pins low, say with a button, and you get a "volume down / volume up / mute" command that as far as I understand it, is sent back to the OS over the USB connection.
So this is why I think my issue is in RetroPi, I also have a microcontroller on the console, and I've written a script that pin-bashes these HS-100 control pins, as a result of reading a potentiometer, and in Raspberry Pi OS desktop, I have volume controll! I can roll the potentiometer up and down, and the system volume changes accordingly.
I have a couple of leads, but can't make much sense of them.
-
I am seeing the "volume control, mixer elements not found" message in the terminal when launching games, suggesting there's something misconfigured somewhere specifically related to volume control.
-
looking at alsaMixer in raspberry Pi OS where volume control works, it's a later version of Alsa Mixer than the version found in RetroPi, and the "volume level" collum is labeled "master" whereby checking AlsaMixer in RetroPi this element is labeled PWM
Sound on Raspberry Pi seems so involved, so I would be grateful for any expertise :)
thanks!
-
-
You should post how your script controls the volume - what commands it uses to change it.
RetroPie has nothing to do with how the volume works, the OS underneath (RasPI OS Lite) is taking care of that. Your script may be controlling a different audio card, perhaps one of the on-board audio options (headphone/HDMI). -
@mitu thanks again for your help
I have been digging around, and I tried replacing my bit-bashing on the Pico with consumer control hid inputs for volume up and down, and again this all works as desired in Raspberry Pi OS.
However I have just made a breakthrough. after realizing adjusting the volume pot "woke" retropie from its dimmed sleep state, I set about trying to find a way to just print inputs on the command line, to see if my consumer control commands were landing in the OS, I found this post, and ran:
thd --dump /dev/input/*
and it's there! if I roll my pot up and down, I see this:
pi@retropie:~ $ thd --dump /dev/input/* Device /dev/input/by-id not suitable. Device /dev/input/by-path not suitable. Device /dev/input/mice not suitable. Device /dev/input/mouse0 not suitable. EV_KEY KEY_VOLUMEUP 1 /dev/input/event3 # KEY_VOLUMEUP 1 command EV_KEY KEY_VOLUMEUP 0 /dev/input/event3 # KEY_VOLUMEUP 0 command EV_KEY KEY_VOLUMEUP 1 /dev/input/event3 # KEY_VOLUMEUP 1 command EV_KEY KEY_VOLUMEUP 0 /dev/input/event3 # KEY_VOLUMEUP 0 command EV_KEY KEY_VOLUMEDOWN 1 /dev/input/event3 # KEY_VOLUMEDOWN 1 command EV_KEY KEY_VOLUMEDOWN 0 /dev/input/event3 # KEY_VOLUMEDOWN 0 command EV_KEY KEY_VOLUMEDOWN 1 /dev/input/event3 # KEY_VOLUMEDOWN 1 command EV_KEY KEY_VOLUMEDOWN 0 /dev/input/event3 # KEY_VOLUMEDOWN 0 command
there it is! my inputs are landing in the OS, and something has decided the inputs are called volume up and volume down.
Now, any idea why my system volume stubbornly refuses to change when I roll the pot? :p
Any help received with love, I'm very close to completing a very cool project.
-
@jameth said in USB volume controll not working in retropie:
there it is! my inputs are landing in the OS, and something has decided the inputs are called volume up and volume down.
That's normal, it's the event sent by your card. The reason they're not working in RetroPie is because these are not working out-of-the-box outside the desktop environment - as is the case for Raspberry Pi OS that you've tested.
Since
triggerhappy
is installed and it's working with the volume control of your card, all you need is to supply it the commands to be executed when the events are emitted. The home page oftriggerhappy
(here) has examples for this:KEY_VOLUMEUP 1 /usr/bin/amixer set Master 5%+ KEY_VOLUMEDOWN 1 /usr/bin/amixer set Master 5%-
Try using the configuration above and see if your volume pot is working. If now, then you may need to adjust the commands:
-
you may need to supply the audio card number to
amixer
(this can be found by runningaplay -l
). Then supply it toamixer
using the-c <card_no>
parameter. -
you may need to supply the name of the mixer - instead of
Master
, the volume control of the audio card may be named differently. You can list the available controls by running:
amixer -c <card_number> scontrols
-
-
@mitu you absolute gent. This is the way. I have got triggerhappy changing the volume in reaction to the pot, the pieces all work. but nothing is happing "on boot" would you mind helping me configure triggerhappy? I think I am almost there.
I found these instructions to be a little more in-depth, and so far, I have:
Created
/etc/triggerhappy/triggers.d/audio.conf
which contains:KEY_VOLUMEUP 1 /usr/bin/amixer -c 1 set PCM 5%+ KEY_VOLUMEDOWN 1 /usr/bin/amixer -c 1 set PCM 5%-
you were right about needing to specify a card
and running
thd --triggers /etc/triggerhappy/triggers.d/ /dev/input/event*
produces events:Executing trigger action: /usr/bin/amixer -c 1 set PCM 5%- Simple mixer control 'PCM',0 Capabilities: pvolume pswitch pswitch-joined Playback channels: Front Left - Front Right Limits: Playback 0 - 37 Mono: Front Left: Playback 35 [95%] [-2.00dB] [on] Front Right: Playback 35 [95%] [-2.00dB] [on] Executing trigger action: /usr/bin/amixer -c 1 set PCM 5%+ Simple mixer control 'PCM',0 Capabilities: pvolume pswitch pswitch-joined Playback channels: Front Left - Front Right Limits: Playback 0 - 37 Mono: Front Left: Playback 37 [100%] [0.00dB] [on] Front Right: Playback 37 [100%] [0.00dB] [on]
And then upon checking
alsamixer
the audio volume has indeed changed, so we have volume control via pot! very excitedHowever I can't quite work out the steps to get the instructions in my .conf into the deamon proper, not entirely sure what daemons and sockets are, will be busy reading up.
Thanks again so much for your incredible help!
-
@jameth said in USB volume controll not working in retropie:
but nothing is happing "on boot" would you mind helping me configure triggerhappy?
As far as I recall, the
triggerhappy
service should be started on boot automatically, but I don't have a Pi available right now to confirm.Run
systemctrl status triggerhappy.service
and post the output.
-
@mitu ah sorry, so, triggerhappy is up and running, but it's not "looking" at my config file, its not just a case of dropping in a correctly named file in an appropriate directory.
ill do some more digging and reading up. if i get it working ill be sure to post my steps.
-
@jameth said in USB volume controll not working in retropie:
@mitu ah sorry, so, triggerhappy is up and running, but it's not "looking" at my config file, its not just a case of dropping in a correctly named file in an appropriate directory.
See how the service is started, the
systemctl
command for status should tell you - may you need to add the lines to the main.conf
file and not in a separate file. -
pi@retropie:~ $ systemctl status triggerhappy.service ● triggerhappy.service - triggerhappy global hotkey daemon Loaded: loaded (/lib/systemd/system/triggerhappy.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2022-08-17 12:11:15 BST; 1min 20s ago Main PID: 355 (thd) Tasks: 1 (limit: 414) CGroup: /system.slice/triggerhappy.service └─355 /usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --socket /run/thd.socket --user nobody --deviceglob /dev/input/event* Aug 17 12:11:14 retropie systemd[1]: Starting triggerhappy global hotkey daemon... Aug 17 12:11:14 retropie thd[355]: Found socket passed from systemd Aug 17 12:11:15 retropie systemd[1]: Started triggerhappy global hotkey daemon.
so its all up and running, but I feel like my .conf isn't being "loaded in", theres a
th-cmd --add
command listed in the instructions, but the paths they use in the example don't make sense to me :s -
Seems to be an issue with the user used by the service - see https://retropie.org.uk/forum/topic/18133/triggerhappy-daemon-thd-doesn-t-work-on-my-pi-running-retropie-help/31.
You may be able to change it by running
sudo systemctl edit triggerhappy.service
an editor session will open, you need to add the following lines:
[Service] ExecStart= ExecStart=/usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --socket /run/thd.socket --user pi --deviceglob /dev/input/event*
and then save and exit. Restart the service with:
sudo systemctl restart triggerhappy
and see if the commands are taking effect.
-
you've done it.
it works!
I can now change the volume in a game, and this persists through power off/on.
I cannot tell how much this means to me. thank you so much for your support.
I will read up on the post you linked and post a conclusion before marking [solved]
-
Hi, I know this is quite an old thread but I have followed all of the steps and I am still not able to get it to work as I get a permission denied error and I can't get passed it.
This is what I get I run the command:pi@retrocade:~$ sudo /usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --user pi --deviceglob /dev/input/event*
Executing trigger action: /usr/bin/amixer set Master 2%+
Executing trigger action: /usr/bin/amixer set Master 2%+
Home directory not accessible: Permission denied
W: [pulseaudio] core-util.c: Failed to open configuration file '/root/.config/pulse//daemon.conf': Permission denied
W: [pulseaudio] daemon-conf.c: Failed to open configuration file: Permission denied
amixer: Unable to find simple control 'Master',0Can you please help me @mitu ?
Thanks!
-
@mitu for some reason, I only get the permission denied via ssh. If I execute: /usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --user pi --deviceglob /dev/input/event* from the desktop (PIXEL) locally it works perfectly, however when I boot normally into retropie, I turn the knob and nothing happens.
If I go back to the pixel desktop, run the command and launch emulationstation from the terminal it also works.
However, when I reboot and goes back again into retropie, it doesn't work anymore. From retropie I have to go back to the pixel desktop, run the command in terminal and launch emlationstation.For background information, I tried with the triggerhappy.service and it didn't work, so I disabled it and added: nohup /usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --user pi --deviceglob /dev/input/event* & to rc.local as you suggested in your previous thread.
-
Hi @mitu,
While I wait for your help, I tried in to insert nohup /usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --user pi --deviceglob /dev/input/event* & into autostart.sh, but checking ps -ef, the process is not running. I'm not sure I am doing it right.
When inserted into rc.local, checked ps -ef and it's listed there.Thanks!
-
Hi @mitu, I keep digging and find strange stuff, look at this...
pi@retrocade:~$ sudo amixer scontrols Simple mixer control 'HDMI',0 pi@retrocade:~$ amixer scontrols Simple mixer control 'Master',0 Simple mixer control 'Capture',0
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.