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

    Syncing button leds with gameplay

    Scheduled Pinned Locked Moved Help and Support
    led buttonsled cledspicer
    68 Posts 5 Posters 8.1k 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.
    • H
      hopwon @Folly
      last edited by

      @Folly Thanks for the info, I just assuumed Invaders would work! I will download the correct version of Galaga (not sure what version I have but it doesn't work with lr-mame) then I am working on the same game.
      @MeduZaPaT You are correct I had not configured mame for network output. Thanks for the tip

      H 1 Reply Last reply Reply Quote 1
      • H
        hopwon @hopwon
        last edited by

        @hopwon Waaaahooooooo! I did it. Well I have now got -network working for mame and lr-mame

        I could not get the correct ROM version for mame/lr-mame for Galaga so I used Galaxians instead:

        socat - TCP4:0:8000,cr
        mame_start = galaxian
        lamp0 = 1
        lamp0 = 0
        lamp0 = 1
        lamp0 = 0
        lamp0 = 1
        lamp0 = 0
        ...
        ...
        
        

        This behavior is the games starts, put a coin in and it start flashing Start (lamp0 on and off) until Start is pressed and then it stops flashing. As long as there is credit in, when a game ends it starts flashing the Start button (if there is credit, if not, it stays off).
        Now to set up LEDSpicer mame plugin...
        I will update later

        1 Reply Last reply Reply Quote 1
        • H
          hopwon
          last edited by

          @MeduZaPaT Its not producing the output I want, can you check my profile_arcade and inputs file to see if you can figure whats wrong? I can confirm that during testing the games is outputting lamp0 =.... text.

          I am running ledspicer in foreground for debug but its not outputing anything:

          galaxians.xml

          <?xml version="1.0" encoding="UTF-8"?>
          <LEDSpicer
              version="1.0"
              type="Input"
              name="Mame"
          >
                  <map
                      type="Element"                 
                      target="P1_START"   
                      trigger="lamp0 = 0"
                      color="Purple"
                      filter="Normal"
                  />
          </LEDSpicer>
          
          

          profile_arcade.xml

          <?xml version="1.0" encoding="UTF-8"?>
          <LEDSpicer
          	version="1.0"
          	type="Profile"
          	backgroundColor="Black"
          >
          <inputs>
          	<input name="galaxians"/>
          </inputs>
          </LEDSpicer>
          

          I also tried creating a game specific profile with the same results:

          profiles/arcade/galaxians.xml

          <?xml version="1.0" encoding="UTF-8"?>
          <LEDSpicer
          	version="1.0"
          	type="Profile"
          	backgroundColor="Black"
          >
          	<inputs>
          		<input name="galaxians"/>
          	</inputs>
          </LEDSpicer
          

          As a double check I can confirm that P1_START is valid and working via ledspicerd -e

          MeduZaPaTM 1 Reply Last reply Reply Quote 0
          • MeduZaPaTM
            MeduZaPaT @hopwon
            last edited by MeduZaPaT

            @hopwon hey, is only the name for triggers, not the value or the =:
            lamp0 = 0 means TRIGGER with name lamp0, VALUE 0, you only need the name (lamp0 in this case)
            so in ledspicer you should type just this:

                    <map
                        type="Element"                 
                        target="P1_START"   
                        trigger="lamp0"
                        color="Purple"
                        filter="Normal"
                    />
            

            so ledspicer will read that trigger and check the value as 0 = OFF and 1 = ON

            You will find a lot of different triggers coming out of MAME for different games, there is no standard, I have an Excel file I can share with you with most of them (outdated but better than nothing),
            LAMP, LED, LIGHT, TRIGGER, KNOCKER, and a big etc.

            look, this my input for terminator 2 (just a test I did for the this video on YT

            <?xml version="1.0" encoding="UTF-8"?>
            <LEDSpicer
            	version="1.0"
            	type="Input"
            	name="Mame"
            >
            	<map
            		type="Group"
            		target="player 1"
            		trigger="Left_Gun_Red_Led"
            		color="Red"
            		filter="Normal"
            	/>
            	<map
            		type="Group"
            		target="player 1"
            		trigger="Left_Gun_Green_Led"
            		color="Green"
            		filter="Normal"
            	/>
            	<map
            		type="Group"
            		target="player 1"
            		trigger="Left_Flash_1"
            		color="Yellow"
            		filter="Combine"
            	/>
            	<map
            		type="Group"
            		target="player 1"
            		trigger="Left_Flash_2"
            		color="Brown"
            		filter="Combine"
            	/>
            	<map
            		type="Group"
            		target="player 3"
            		trigger="Left_Flash_3"
            		color="Gold"
            		filter="Combine"
            	/>
            	<map
            		type="Group"
            		target="player 3"
            		trigger="Left_Flash_4"
            		color="Orange"
            		filter="Combine"
            	/>
            
            	<map
            		type="Group"
            		target="player 2"
            		trigger="right_Gun_Red_Led"
            		color="Red"
            		filter="Normal"
            	/>
            	<map
            		type="Group"
            		target="player 2"
            		trigger="right_Gun_Green_Led"
            		color="Green"
            		filter="Normal"
            	/>
            	<map
            		type="Group"
            		target="player 2"
            		trigger="right_Flash_1"
            		color="Yellow"
            		filter="Combine"
            	/>
            	<map
            		type="Group"
            		target="player 2"
            		trigger="right_Flash_2"
            		color="Brown"
            		filter="Combine"
            	/>
            	<map
            		type="Group"
            		target="player 4"
            		trigger="right_Flash_3"
            		color="Gold"
            		filter="Combine"
            	/>
            	<map
            		type="Group"
            		target="player 4"
            		trigger="right_Flash_4"
            		color="Orange"
            		filter="Combine"
            	/>
            
            </LEDSpicer>
            

            Hope that this helps
            regards.

            LEDSpicer

            H 2 Replies Last reply Reply Quote 2
            • H
              hopwon @MeduZaPaT
              last edited by

              @MeduZaPaT Thanks I am implementing your suggestions now :)
              Incidently I found that, just for Galaxians there are two LEDs, P1 Start and P2 Start. When looking at the network output from mame I see (with one credit) lamp0 = 0, lamp0 = 1, lamp0 = 0, etc.
              Put two credits in then:
              lamp0 = 1
              lamp1 = 1
              lamp0 = 0
              lamp1 = 0

              So its basically flashing both start buttons on and off.
              Will LEDSpicer accept the whole string or does it not work with spaces in the text?

              MeduZaPaTM 1 Reply Last reply Reply Quote 0
              • H
                hopwon @MeduZaPaT
                last edited by

                @MeduZaPaT said in Syncing button leds with gameplay:

                You will find a lot of different triggers coming out of MAME for different games, there is no standard, I have an Excel file I can share with you with most of them (outdated but better than nothing),
                LAMP, LED, LIGHT, TRIGGER, KNOCKER, and a big etc.

                One project is to wire up a knocker for QBert so would appreciate any and all help and later on Santa is going to bring me some base shakers which will be fun to enable with LEDSpicer....

                MeduZaPaTM 1 Reply Last reply Reply Quote 0
                • H
                  hopwon
                  last edited by

                  Its working! Its WORKING! Oh man I am over the moon, I understand (mostly!) now how it all hangs together and works and it does WORK :)

                  I have to say a massive thanks both of you for supporting this, @Folly & @MeduZaPaT
                  Its been a great education which I will put to good use. I will try to build some cool animations and triggers and whatever I want now :)

                  F 1 Reply Last reply Reply Quote 1
                  • F
                    Folly @hopwon
                    last edited by Folly

                    @hopwon

                    Just an idea.
                    Can you summarise this topic in your first post, like a tutorial or is this too much to ask ?

                    H 1 Reply Last reply Reply Quote 0
                    • H
                      hopwon @Folly
                      last edited by

                      @Folly I feel like I should. To be honest I have been looking for years and apart from the Wiki, there is that post on attractmode and thats it. After all the input from you guys its the least I can do :)

                      F 1 Reply Last reply Reply Quote 0
                      • F
                        Folly @hopwon
                        last edited by

                        @hopwon

                        Would be great ;-)
                        Take your time, no hurry.

                        It's not done yet, I have to look at the Blinker and the Impulse stuff when I can.
                        And most likely more.

                        1 Reply Last reply Reply Quote 0
                        • MeduZaPaTM
                          MeduZaPaT @hopwon
                          last edited by MeduZaPaT

                          @hopwon for the Knocker for QBert and others you have 3 options (maybe more) to connect the solenoid:
                          1 get a USB controller that support high current (like the paddrive)
                          2 build or get a circuit using transistors to control the solenoid.
                          3 use a relay to move the solenoid (also need a driver for the relay).
                          I also need to add a knocker to mine, I have everything but time to connect and test :(

                          LEDSpicer support solenoids BTW :)

                          0444c068-b212-45a1-a812-459913d2cac7-image.png

                          Trying to get the UI done ASAP, makes life easier, and you see things that are really hard to find by reading documentation

                          LEDSpicer

                          H 1 Reply Last reply Reply Quote 0
                          • MeduZaPaTM
                            MeduZaPaT @hopwon
                            last edited by MeduZaPaT

                            @hopwon said in Syncing button leds with gameplay:

                            @MeduZaPaT Thanks I am implementing your suggestions now :)
                            Incidently I found that, just for Galaxians there are two LEDs, P1 Start and P2 Start. When looking at the network output from mame I see (with one credit) lamp0 = 0, lamp0 = 1, lamp0 = 0, etc.
                            Put two credits in then:
                            lamp0 = 1
                            lamp1 = 1
                            lamp0 = 0
                            lamp1 = 0

                            So its basically flashing both start buttons on and off.
                            Will LEDSpicer accept the whole string or does it not work with spaces in the text?

                            in that case you have 2 TRIGGERS: lamp0 and lamp1
                            so you need something like this:

                            ........
                            <map
                            	type="Element"
                            	target="P1_START"
                            	trigger="lamp0"
                            	color="Blue"
                            	filter="Normal"
                            />
                            <map
                            	type="Elemet"
                            	target="P2_START"
                            	trigger="lamp1"
                            	color="Red"
                            	filter="Normal"
                            />
                            ........
                            

                            LEDSpicer

                            1 Reply Last reply Reply Quote 1
                            • H
                              hopwon @MeduZaPaT
                              last edited by

                              @MeduZaPaT said in Syncing button leds with gameplay:

                              @hopwon for the Knocker for QBert and others you have 3 options (maybe more) to connect the solenoid:
                              1 get a USB controller that support high current (like the paddrive)
                              2 build or get a circuit using transistors to control the solenoid.
                              3 use a relay to move the solenoid (also need a driver for the relay).
                              I also need to add a knocker to mine, I have everything but time to connect and test :(

                              I have a UltimateIO which is supposed to be able to drive "high current" but its still limited to 5v. I bought a 5v Solenoid to test but there was lots of heat and smoke so I stopped testing :)
                              I think I will put a relay from the UltimateIO and drive say a 12v soleniod via that. Much safer

                              Like you I have all the parts, just not the time. Future project...

                              MeduZaPaTM 1 Reply Last reply Reply Quote 0
                              • H
                                hopwon @MeduZaPaT
                                last edited by

                                @Folly Small addition to your runcommand-onlaunch.sh to test if an individual game profile exists and if so loads it, if not load ByEmulator

                                #!/bin/bash
                                
                                /home/pi/Lightgun/utils/sindenautostart.sh -a "$1" "$2" "$3" "$4"
                                # Get system name
                                system=$1
                                emulator=$2
                                rom=$3
                                command=$4
                                
                                
                                # rom_bn receives $rom excluding everything from the first char to the last slash '/'
                                rom_bn="${rom##*/}"
                                # rom_bn receives $rom_bn excluding everything from the last char to the first dot '.'
                                rom_bn="${rom_bn%.*}"
                                rom_xml=$rom_bn.xml
                                
                                if [ -f "$system/$rom_xml" ]
                                        then
                                                emitter LoadProfile $system/$rom_bn
                                        else
                                                emitter LoadProfileByEmulator $rom_bn $system
                                fi
                                
                                

                                I've tested some games with "normal" names but I suspect this will be a bit buggy...

                                1 Reply Last reply Reply Quote 1
                                • MeduZaPaTM
                                  MeduZaPaT @hopwon
                                  last edited by MeduZaPaT

                                  @hopwon

                                  lets say you have a Solenoid on the pin # 1 of the ultimateIO
                                  in the config inside the device section, you need something like this:

                                  <element
                                      name="KNOCKER"
                                      solenoid="1"
                                      onTime="75"
                                  />
                                  

                                  Where name is the element name you want to use, solenoid=<pin number> is the pin on the ultimateIO where the solenoid is connected, and onTime is the number of ms to send the electric pulse, 75ms is ok for most solenoids, but others needs more, you can play with this number until you get a good "kick".
                                  solenoids needs to be shutdown after trigger, or they will overheat.

                                  LEDSpicer

                                  H 1 Reply Last reply Reply Quote 1
                                  • H
                                    hopwon @MeduZaPaT
                                    last edited by

                                    @MeduZaPaT said in Syncing button leds with gameplay:

                                    solenoids needs to be shutdown after trigger, or they will overheat.

                                    I did not know this. I think thats why I got a lot of smoke when I last tried

                                    MeduZaPaTM 1 Reply Last reply Reply Quote 1
                                    • MeduZaPaTM
                                      MeduZaPaT @hopwon
                                      last edited by

                                      @hopwon were you able to test the solenoid?

                                      LEDSpicer

                                      H 1 Reply Last reply Reply Quote 0
                                      • H
                                        hopwon @MeduZaPaT
                                        last edited by

                                        @MeduZaPaT nope, not got round to it yet
                                        I got sidetracked by a new build.

                                        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.