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

    Mapping Controllers in Moonlight

    Scheduled Pinned Locked Moved Help and Support
    moonlight helpnvidia
    15 Posts 2 Posters 3.9k 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.
    • StonedEdgeS
      StonedEdge @mitu
      last edited by StonedEdge

      @mitu said in Mapping Controllers in Moonlight:

      @stonededge said in Mapping Controllers in Moonlight:

      Sorry, which part is commented exactly? I don’t see anything related to the controller or audio that is commented.

      The mapping option seems commented out with the #.

      OK. How do I run moonlight with verbose logging? I’ve just been executing it from the main RetroPie menu front end.

      Edit the emulators.cfg file from /opt/retropie/configs/steam and add the -verbose parameter to the moonlight start command.
      Looking at the moonlight's startup command, I see it relocates $XDG_CONFIG_DIR to /opt/retropie/configs/all/moonlight so try also copying your mapping file in that folder.

      OK, I've added the verbose comment - could I ask you where I can find the log output?

      Regarding the last point, the configuration for my Sparkfun Sparkfun Pro Micro controller was already added under the #Linux category within that repository.

      Within the /dev/shm folder directory, I can show you that the runcommand log returns the following output:

      Parameters: 
      Executing: /opt/retropie/supplementary/moonlight/moonlight.sh stream -config "/home/pi/RetroPie/roms/steam/Steam.ml"
      

      Check out my build logs below:
      Wii SPii (Wii in a GBA SP Shell)
      https://bitbuilt.net/forums/index.php?threads/the-wii-spii.3347/
      Retro Lite CM4
      https://bitbuilt.net/forums/index.php?threads/retro-lite-cm4-a-stonededge-and-dmcke5-collaboration.3934/

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

        @stonededge said in Mapping Controllers in Moonlight:

        OK, I've added the verbose comment - could I ask you where I can find the log output?

        Should be in /dev/shm/runcommand.log ? Looking at the log you posted, there is no -verbose parameter added.
        Try executing the start command manually, after exiting EmulationStation

        /opt/retropie/supplementary/moonlight/moonlight.sh stream -verbose -config "/home/pi/RetroPie/roms/steam/Steam.ml"
        
        StonedEdgeS 1 Reply Last reply Reply Quote 0
        • StonedEdgeS
          StonedEdge @mitu
          last edited by StonedEdge

          @mitu said in Mapping Controllers in Moonlight:

          /opt/retropie/supplementary/moonlight/moonlight.sh stream -verbose -config "/home/pi/RetroPie/roms/steam/Steam.ml"

          Ok, thanks Mitu. That returns the following verbose log, which to me looks like its pairing and detecting the controller. Do you see any issues here? It does seem to loop over the controller twice, saying "Not mapping SparkFun SparkFun Pro Micro as a gamepad" but then proceeds to connect again. As mentioned before, all buttons work, apart from the DPAD itself.

          Moonlight Embedded 2.5.2 (PI;MMAL;ALSA;PULSE;EMBEDDED)
          Searching for server...
          Connect to 100.64.1.21...
          GPU: NVIDIA GeForce RTX 2060, GFE: 3.24.0.126 (gs_04_37_30719632, 7.1.437.0)
          Platform Raspberry Pi (Broadcom)
          Loading mappingfile /opt/retropie/configs/all/moonlight/gamecontrollerdb.txt
          Detected SparkFun SparkFun Pro Micro (030000004f1b00000692000001010000) on /dev/input/event0 as SparkFun SparkFun Pro Micro
          Not mapping SparkFun SparkFun Pro Micro as a gamepad
          Detected SparkFun SparkFun Pro Micro (030000004f1b00000692000001010000) on /dev/input/event1 as SparkFun SparkFun Pro Micro
          Stream 1280 x 720, 60 fps, 10000 kbps
          RTSP port: 48010
          Initializing platform...done
          Resolving host name...done
          Packet size capped at 1KB for remote streaming
          Initializing audio stream...done
          Starting RTSP handshake...Audio port: 48000
          Video port: 47998
          Control port: 47999
          done
          Initializing control stream...done
          Initializing video stream...done
          Initializing input stream...done
          Starting control stream...done
          Starting video stream...done
          Starting audio stream...done
          Starting input stream...Received first audio packet after 0 ms
          Initial audio resync period: 500 milliseconds
          done
          Received first video packet after 0 ms
          Leaving fast audio recovery mode after OOS audio data (214 < 216)
          

          Regarding the audio issue, here is what the verbose log provides when I click a button (which should technically output sound in Steamlink on the client side):

          Unable to recover audio data block 41904 to 41907 (2+0=2 received < 4 needed)
          Unable to recover audio data block 41916 to 41919 (0+1=1 received < 4 needed)
          Network dropped audio data (expected 41906, but received 41920)
          

          Check out my build logs below:
          Wii SPii (Wii in a GBA SP Shell)
          https://bitbuilt.net/forums/index.php?threads/the-wii-spii.3347/
          Retro Lite CM4
          https://bitbuilt.net/forums/index.php?threads/retro-lite-cm4-a-stonededge-and-dmcke5-collaboration.3934/

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

            @stonededge said in Mapping Controllers in Moonlight:

            It does seem to loop over the controller twice, saying "Not mapping SparkFun SparkFun Pro Micro as a gamepad" but then proceeds to connect again

            It's not looping twice, you have 2 event devices with the same name (/dev/input/event0 and /dev/input/event1).
            The message Not mapping SparkFun SparkFun Pro Micro as a gamepad may be the hint of why your mapping is not loaded. The classification is done here. Check with evtest if your gamepad emits the necessary events, my guess is that ABS_X and ABS_Y may be missing and moonlight doesn't consider your controller as a gamepad device.

            StonedEdgeS 1 Reply Last reply Reply Quote 0
            • StonedEdgeS
              StonedEdge @mitu
              last edited by StonedEdge

              @mitu

              Hmm, I am not sure why that is happening. Is there a way to only direct steamlink to read on event 1?

              This is the output of evtest on event 1. Event 0 doesn't return any response to any buttons.

              D-Up: Code 4: 37267
              D-Down: Code 4: -37267
              D-Left: Code 5: -32767
              D-Right: Code 5: +32767

              Since they share the same code, I assume it might not be possible to map it, if the DPAD is set up to act like an analog stick maximum X/Y values?

              Event: time 1643695032.112436, type 3 (EV_ABS), code 4 (ABS_RY), value 32767
              Event: time 1643695032.112436, -------------- SYN_REPORT ------------
              Event: time 1643695032.196429, type 3 (EV_ABS), code 4 (ABS_RY), value 0
              Event: time 1643695032.196429, -------------- SYN_REPORT ------------
              Event: time 1643695033.356351, type 3 (EV_ABS), code 4 (ABS_RY), value 32767
              Event: time 1643695033.356351, -------------- SYN_REPORT ------------
              Event: time 1643695033.450352, type 3 (EV_ABS), code 4 (ABS_RY), value 0
              Event: time 1643695033.450352, -------------- SYN_REPORT ------------
              Event: time 1643695034.512282, type 3 (EV_ABS), code 4 (ABS_RY), value 32767
              Event: time 1643695034.512282, -------------- SYN_REPORT ------------
              Event: time 1643695034.612271, type 3 (EV_ABS), code 4 (ABS_RY), value 0
              Event: time 1643695034.612271, -------------- SYN_REPORT ------------
              Event: time 1643695034.922248, type 3 (EV_ABS), code 4 (ABS_RY), value -32767
              Event: time 1643695034.922248, -------------- SYN_REPORT ------------
              Event: time 1643695035.004241, type 3 (EV_ABS), code 4 (ABS_RY), value 0
              Event: time 1643695035.004241, -------------- SYN_REPORT ------------
              Event: time 1643695035.998177, type 3 (EV_ABS), code 5 (ABS_RZ), value 32767
              Event: time 1643695035.998177, -------------- SYN_REPORT ------------
              Event: time 1643695036.104171, type 3 (EV_ABS), code 5 (ABS_RZ), value 0
              Event: time 1643695036.104171, -------------- SYN_REPORT ------------
              Event: time 1643695036.516148, type 3 (EV_ABS), code 5 (ABS_RZ), value -32767
              Event: time 1643695036.516148, -------------- SYN_REPORT ------------
              Event: time 1643695036.564144, type 3 (EV_ABS), code 5 (ABS_RZ), value 0
              Event: time 1643695036.564144, -------------- SYN_REPORT ------------
              
              

              Check out my build logs below:
              Wii SPii (Wii in a GBA SP Shell)
              https://bitbuilt.net/forums/index.php?threads/the-wii-spii.3347/
              Retro Lite CM4
              https://bitbuilt.net/forums/index.php?threads/retro-lite-cm4-a-stonededge-and-dmcke5-collaboration.3934/

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

                @stonededge said in Mapping Controllers in Moonlight:

                Since they share the same code, I assume it might not be possible to map it, if the DPAD is set up to act like an analog stick maximum X/Y values?

                No, it should work, but your gamepad sends ABS_RX/ABS_RY and not ABS_X/ABS_Y and this makes moonlight ignore the device. This looks like a moonlight issue and you could ask them to augment the gamepad detection to include cases like this. Or you could modify the controller code to send ABS_X/ABS_Y, this will probably change the D-Pad mappings you have already configured.

                StonedEdgeS 1 Reply Last reply Reply Quote 1
                • StonedEdgeS
                  StonedEdge @mitu
                  last edited by StonedEdge

                  @mitu

                  Okay, thanks Mitu for helping find our problem, very much appreciated as always.

                  I will set up my DPAD as hat switches for the time being hopefully, or request the devs to make a change to the code (hopefully its quick and painless).

                  Regarding audio, do you have any idea on how I could solve the no audio issues? I'll try to provide as much information as I can, including my asound.rc contents. I'm using "dmix" as I want to be able to play background music, as well as RetroPie sounds from one device to two sources, without getting a "Device or Resource Busy Error" thrown at me.

                  I've also tried adding "-audio default/sysdefault/dmix" to the command that is run from the moonlight.sh file. I believe it is in the /opt/retropie/supplementary/moonlight/ folder, however this didn't fix anything for me.

                  asound.rc file:

                  pcm.!default {
                    type asym
                    playback.pcm {
                      type plug
                      slave.pcm "dmix"
                    }
                    capture.pcm {
                      type plug
                      slave.pcm "dmix"
                    }
                  }
                  
                  pcm.output {
                    type hw
                    card 0
                  }
                  
                  ctl.!default {
                    type hw
                    card 0
                  }
                  
                  

                  Check out my build logs below:
                  Wii SPii (Wii in a GBA SP Shell)
                  https://bitbuilt.net/forums/index.php?threads/the-wii-spii.3347/
                  Retro Lite CM4
                  https://bitbuilt.net/forums/index.php?threads/retro-lite-cm4-a-stonededge-and-dmcke5-collaboration.3934/

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

                    @stonededge said in Mapping Controllers in Moonlight:

                    Regarding audio, do you have any idea on how I could solve the no audio issues?

                    I don't see any messages regarding the audio output in the log you posted, but if ALSA is working correctly, then maybe you can instruct moonlight to use it instead of MMAL/PulseAudio/other.

                    I'm using "dmix" as I want to be able to play background music, as well as RetroPie sounds from one device to two sources, without getting a "Device or Resource Busy Error" thrown at me.

                    I thought the default ALSA configuration for Pi4 already had built-in mixing (via dmix), as you using the new KMS audio driver ?

                    StonedEdgeS 1 Reply Last reply Reply Quote 0
                    • StonedEdgeS
                      StonedEdge @mitu
                      last edited by StonedEdge

                      @mitu I believe I am still using the fake kms drivers within my config.txt files, but I thought that only referenced the video drivers, not audio.

                      Do you know how to adjust the conf file to use ALSA as the primary audio source? Steam link seems to stream across the audio just fine and playback is perfect. I do notice that NVIDIA HDMI Audio setting is at maximum volume on my host PC, so I don’t think it’s a problem with the host device. I couldn’t find any documentation on the settings and what is available.

                      In order to get two audio outputs with one device, I had to set the astound.rc file to dmix. The default was sysdefault which resulted in the emulationstation navigation sounds and emulator audio being muted, but that is a different issue entirely.

                      Check out my build logs below:
                      Wii SPii (Wii in a GBA SP Shell)
                      https://bitbuilt.net/forums/index.php?threads/the-wii-spii.3347/
                      Retro Lite CM4
                      https://bitbuilt.net/forums/index.php?threads/retro-lite-cm4-a-stonededge-and-dmcke5-collaboration.3934/

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

                        @stonededge said in Mapping Controllers in Moonlight:

                        Do you know how to adjust the conf file to use ALSA as the primary audio source?

                        I don't know - I don't see a list of options for audio in the configuration file.

                        StonedEdgeS 1 Reply Last reply Reply Quote 1
                        • StonedEdgeS
                          StonedEdge @mitu
                          last edited by

                          @mitu I've managed to get audio working now, I just needed to add the "-audio default" command to the below. Hope this helps someone else. Now just to solve the DPAD issue :) Thank you!

                          /opt/retropie/supplementary/moonlight/moonlight.sh stream -verbose -config - audio default "/home/pi/RetroPie/roms/steam/Steam.ml"

                          Check out my build logs below:
                          Wii SPii (Wii in a GBA SP Shell)
                          https://bitbuilt.net/forums/index.php?threads/the-wii-spii.3347/
                          Retro Lite CM4
                          https://bitbuilt.net/forums/index.php?threads/retro-lite-cm4-a-stonededge-and-dmcke5-collaboration.3934/

                          1 Reply Last reply Reply Quote 0
                          • T tuxophil referenced this topic on
                          • 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.