RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    USB volume controll not working in retropie

    Scheduled Pinned Locked Moved Help and Support
    usbaudiovolume control
    15 Posts 3 Posters 1.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mituM
      mitu Global Moderator
      last edited by

      @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 of triggerhappy (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 running aplay -l). Then supply it to amixer 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
      
      J 1 Reply Last reply Reply Quote 1
      • J
        jameth @mitu
        last edited by

        @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 excited

        However 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!

        1 Reply Last reply Reply Quote 0
        • mituM
          mitu Global Moderator
          last edited by

          @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.

          J 1 Reply Last reply Reply Quote 0
          • J
            jameth @mitu
            last edited by

            @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.

            mituM 1 Reply Last reply Reply Quote 0
            • mituM
              mitu Global Moderator @jameth
              last edited by

              @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.

              J 1 Reply Last reply Reply Quote 1
              • J
                jameth @mitu
                last edited by

                @mitu

                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

                1 Reply Last reply Reply Quote 0
                • mituM
                  mitu Global Moderator
                  last edited by

                  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.

                  J 1 Reply Last reply Reply Quote 1
                  • J
                    jameth @mitu
                    last edited by

                    @mitu

                    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]

                    1 Reply Last reply Reply Quote 1
                    • L
                      levis78
                      last edited by levis78

                      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',0

                      Can you please help me @mitu ?

                      Thanks!

                      L 1 Reply Last reply Reply Quote 0
                      • L
                        levis78 @levis78
                        last edited by levis78

                        @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.

                        L 1 Reply Last reply Reply Quote 0
                        • L
                          levis78 @levis78
                          last edited by

                          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!

                          L 1 Reply Last reply Reply Quote 0
                          • L
                            levis78 @levis78
                            last edited by

                            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
                            
                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post

                            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.