Syncing button leds with gameplay
-
On which hardware do you run retropie ?
lr-mame can be installed from binary when using rpi.Tell me, what script did you make to count the inserted coins and do you use a joystick or keyboard ?
-
@Folly said in Syncing button leds with gameplay:
On which hardware do you run retropie ?
First post:
... I am using LEDSpicer on RPI4.
-
@Folly said in Syncing button leds with gameplay:
Tell me, what script did you make to count the inserted coins and do you use a joystick or keyboard ?
A bit nasty but:
I used inputseeker running in background to grep for a credit button being pressed on(6=P1, 7=P2 in my case) and when it successfully finds a 6 or 7 it increments a counter +1.
You can do it with awk also but I got tired and when to bed :) -
@Folly said in Syncing button leds with gameplay:
lr-mame can be installed from binary when using rpi.
Installing it now
-
I will look at ledspicer with inputseeker again.
Seem a really nice package but I have to take some time to dig into it.
Hopefully I will grasp it. -
I uninstalled my previous install of LEDspice.
This I what I did :
cd ~/Downloads/LEDSpicer-development/ ./autogen.sh ./configure --prefix=/usr --sysconfdir=/etc --enable-raspberrypi make sudo make install sudo usermod -a -G users pi #replace user with your username sudo usermod -a -G input pi #replace user with your username sudo cp /usr/share/doc/ledspicer/examples/21-ledspicer.rules /etc/udev/rules.d/ sudo chmod 744 /etc/udev/rules.d/21-ledspicer.rules sudo udevadm control --reload-rules && sudo udevadm trigger sudo cp /usr/share/doc/ledspicer/examples/ledspicer.conf /etc ledspicerd -v ledspicerd -d sudo ledspicerd -d #seems to be the way to go with RaspberryPi
Running with -d gives :
Program terminated by error: Empty devices sectionAdded the controller name in /etc/ledspicer.conf :
<devices name="RaspberryPi" boardId="1" > </devices>
or
<devices> name="RaspberryPi" boardId="1" </devices>
Still no dice.
Any help would be appreciated.
-
@Folly You need to manually create your ledspicer.conf, I've attached mine to give you some idea (sorry admins no pastebin!), But basically the file maps pins #'s on your LED controller to an "Element", you can then create groups of Elements and address either the group or Element...
FYI On this controller I have 2 x Joystick + Trackball, each player has 8 buttons, plus start, credit, hotkey and exit.
pi@pacman:~ $ cat /etc/ledspicer.conf <?xml version="1.0" encoding="UTF-8"?> <LEDSpicer version="1.0" type="Configuration" fps="30" port="16161" colors="webColors" loglevel="Info" userId="1000" groupId="1000" craftProfile="true" > <devices> <device name="UltimarcUltimate" boardId="1" > <element name="P1_BUTTON1" red="54" green="53" blue="52" defaultColor="Red" /> <element name="P1_BUTTON2" red="57" green="56" blue="55" defaultColor="VeryDarkMagenta" /> <element name="P1_BUTTON3" red="60" green="59" blue="58" defaultColor="Blue" /> <element name="P1_BUTTON4" red="63" green="62" blue="61" defaultColor="Yellow" /> <element name="P1_BUTTON5" red="66" green="65" blue="64" defaultColor="Salmon" /> <element name="P1_BUTTON6" red="69" green="68" blue="67" defaultColor="Lime" /> <element name="P1_BUTTON7" red="72" green="71" blue="70" defaultColor="Violet" /> <element name="P1_BUTTON8" red="75" green="74" blue="73" defaultColor="VeryDarkYellow" /> <element name="P1_START" red="79" green="80" blue="81" defaultColor="DarkOrange" /> <element name="P1_CREDIT" red="93" green="92" blue="91" defaultColor="DarkOrange" /> <element name="P1_TRACKBALL" red="28" green="29" blue="30" defaultColor="Cyan" /> <element name="P1_JOYSTICK1" red="49" green="50" blue="51" defaultColor="Lime" /> <element name="HOTKEY" led="85" /> <element name="EXIT_KEY" led="88" /> <element name="P2_CREDIT" red="84" green="83" blue="82" defaultColor="DarkOrange" /> <element name="P2_START" red="78" green="77" blue="76" defaultColor="DarkOrange" /> <element name="P2_BUTTON1" red="4" green="5" blue="6" defaultColor="Red" /> <element name="P2_BUTTON2" red="7" green="8" blue="9" defaultColor="Green" /> <element name="P2_BUTTON3" red="10" green="11" blue="12" defaultColor="Blue" /> <element name="P2_BUTTON4" red="13" green="14" blue="15" defaultColor="Yellow" /> <element name="P2_BUTTON5" red="16" green="17" blue="18" defaultColor="Salmon" /> <element name="P2_BUTTON6" red="19" green="20" blue="21" defaultColor="Lime" /> <element name="P2_BUTTON7" red="22" green="23" blue="24" defaultColor="Violet" /> <element name="P2_BUTTON8" red="25" green="26" blue="27" defaultColor="VeryDarkYellow" /> <element name="P2_JOYSTICK1" red="1" green="2" blue="3" defaultColor="HotPink" /> </device> </devices> <restrictors> <restrictor name="ServoStik" boardId="1" player="1" joystick="1" /> <!-- Player 2 with ServoStik --> <restrictor name="ServoStik" boardId="1" player="2" joystick="1" /> </restrictors> <layout defaultProfile="default"> <group name="whole board"> <element name="P1_JOYSTICK1"/> <element name="P1_TRACKBALL"/> <element name="P1_START"/> <element name="P1_CREDIT"/> <element name="P1_BUTTON1"/> <element name="P1_BUTTON2"/> <element name="P1_BUTTON3"/> <element name="P1_BUTTON4"/> <element name="P1_BUTTON5"/> <element name="P1_BUTTON6"/> <element name="P1_BUTTON7"/> <element name="P1_BUTTON8"/> <element name="P2_JOYSTICK1"/> <element name="P2_BUTTON1"/> <element name="P2_BUTTON2"/> <element name="P2_BUTTON3"/> <element name="P2_BUTTON4"/> <element name="P2_BUTTON5"/> <element name="P2_BUTTON6"/> <element name="P2_BUTTON7"/> <element name="P2_BUTTON8"/> <element name="P2_CREDIT"/> <element name="P2_START"/> </group> <group name="Player1"> <element name="P1_JOYSTICK1"/> <element name="P1_TRACKBALL"/> <element name="P1_START"/> <element name="P1_CREDIT"/> <element name="P1_BUTTON1"/> <element name="P1_BUTTON2"/> <element name="P1_BUTTON3"/> <element name="P1_BUTTON4"/> <element name="P1_BUTTON5"/> <element name="P1_BUTTON6"/> <element name="P1_BUTTON7"/> <element name="P1_BUTTON8"/> </group> <group name="Player2"> <element name="P2_JOYSTICK1"/> <element name="P2_BUTTON1"/> <element name="P2_BUTTON2"/> <element name="P2_BUTTON3"/> <element name="P2_BUTTON4"/> <element name="P2_BUTTON5"/> <element name="P2_BUTTON6"/> <element name="P2_BUTTON7"/> <element name="P2_BUTTON8"/> <element name="P2_CREDIT"/> <element name="P2_START"/> </group> <group name="Players"> <element name="P1_JOYSTICK1"/> <element name="P1_TRACKBALL"/> <element name="P1_START"/> <element name="P1_CREDIT"/> <element name="P1_BUTTON1"/> <element name="P1_BUTTON2"/> <element name="P1_BUTTON3"/> <element name="P1_BUTTON4"/> <element name="P1_BUTTON5"/> <element name="P1_BUTTON6"/> <element name="P1_BUTTON7"/> <element name="P1_BUTTON8"/> <element name="P2_JOYSTICK1"/> <element name="P2_BUTTON1"/> <element name="P2_BUTTON2"/> <element name="P2_BUTTON3"/> <element name="P2_BUTTON4"/> <element name="P2_BUTTON5"/> <element name="P2_BUTTON6"/> <element name="P2_BUTTON7"/> <element name="P2_BUTTON8"/> <element name="P2_CREDIT"/> <element name="P2_START"/> </group> <group name="Whole board as a circle"> <element name="HOTKEY"/> <element name="P1_CREDIT"/> <element name="P1_START"/> <element name="P1_JOYSTICK1"/> <element name="P1_BUTTON5"/> <element name="P1_BUTTON1"/> <element name="P1_BUTTON6"/> <element name="P1_BUTTON2"/> <element name="P1_BUTTON7"/> <element name="P1_BUTTON3"/> <element name="P1_BUTTON8"/> <element name="P1_BUTTON4"/> <element name="P1_TRACKBALL"/> <element name="P2_JOYSTICK1"/> <element name="P2_BUTTON5"/> <element name="P2_BUTTON1"/> <element name="P2_BUTTON6"/> <element name="P2_BUTTON2"/> <element name="P2_BUTTON7"/> <element name="P2_BUTTON3"/> <element name="P2_BUTTON8"/> <element name="P2_BUTTON4"/> <element name="P2_CREDIT"/> <element name="P2_START"/> </group> <group name="Ctrl keys"> <element name="HOTKEY"/> <element name="P1_CREDIT"/> <element name="P1_START"/> <element name="P2_CREDIT"/> <element name="P2_START"/> <element name="EXIT_KEY"/> </group> <group name="TopRow"> <element name="P1_CREDIT"/> <element name="P1_START"/> <element name="HOTKEY"/> <element name="EXIT_KEY"/> <element name="P2_CREDIT"/> <element name="P2_START"/> </group> </layout> </LEDSpicer>
-
@Folly said in Syncing button leds with gameplay:
I uninstalled my previous install of LEDspice.
This I what I did :
cd ~/Downloads/LEDSpicer-development/ ./autogen.sh ./configure --prefix=/usr --sysconfdir=/etc --enable-raspberrypi make sudo make install sudo usermod -a -G users pi #replace user with your username sudo usermod -a -G input pi #replace user with your username sudo cp /usr/share/doc/ledspicer/examples/21-ledspicer.rules /etc/udev/rules.d/ sudo chmod 744 /etc/udev/rules.d/21-ledspicer.rules sudo udevadm control --reload-rules && sudo udevadm trigger sudo cp /usr/share/doc/ledspicer/examples/ledspicer.conf /etc ledspicerd -v ledspicerd -d sudo ledspicerd -d #seems to be the way to go with RaspberryPi
Running with -d gives :
Program terminated by error: Empty devices sectionAdded the controller name in /etc/ledspicer.conf :
<devices name="RaspberryPi" boardId="1" > </devices>
or
<devices> name="RaspberryPi" boardId="1" </devices>
Still no dice.
Any help would be appreciated.
Make sure when you are starting for the first time, run the daemon in foreground (-f) as it is the best way to troubleshoot. Its quite verbose in its output so if there is a problem you should get a good indication of exactly what it is.
-
Thanks, will have a look when I am using my pi.
-
@Folly So I managed to get the command line options passed to lr-mame based on the info you provided. I can now see that (I am using Missile Command as a test), led0=0, led1=0, led0=1 led1=1, repeating in the console for any button press.
This tells me (I think) that mame is making two led's flash and thats it. No specific output regarding credit or I could be wrong.From runcommand.log using -output console
led0 = 1 led0 = 0 led0 = 1 led0 = 0 led0 = 1 led0 = 0 led0 = 1 led0 = 0 led0 = 1 led1 = 1 led1 = 0 led0 = 0
These represent a button press, I think one press = 4 log entries
-
Yes indeed that is correct.
It's jsut how the original hardware worked and that is implemented in mame.
It's basically the same with thegalaga
example I used before, only here you have to add 2 credits for 1 player and 4 credits for 2 players.What you want is not implemented in mame so you need to get the information in an other way just like you did with
inputseeker
.
I tested that and indeed reading event becomes very easy but you need to add a whole script for doing stuff with that information.I see the problem getting some uniform data for every game it seems a bit different.
Basically it could mean that for every game you need to make a script.If you want more advanced ways you could look at mame lua plugin scripts.
With that you might be able to extract data in a different / better way.
FYI I used them for tests but I never wrote them. -
@Folly @MeduZaPaT talks about doing the part to make credit flash here:
If there was a way to set a counter or write to an output, then that's the solution...
-
Ok, I used your ledspicer.conf and customised it for use with RaspberryPi (GPIO).
For error sake I made all red, green and blue use the same pin (red=4, green=5 and blue=6) and added an empty profile which is explained over here.Now I don't get errors anymore when running :
ledspicerd -d
Then I tried :
ledspicerd -f
That gave me :
2023-09-21 21:23:41 initCheckPermitted: +---------------------------------------------------------+ |Sorry, you don't have permission to run this program. | |Try running as root, e.g. precede the command with sudo. | +---------------------------------------------------------+ Program terminated by error: Failed to initialized Raspberry PI GPIO
So now I know RaspberryPi needs running with sudo, like this :
sudo ledspicerd -f
I might have to check ledspicer.conf again for correct values and then I have to add some game profiles.
Would like to check first if the mame "-output network" is detected without using emulationstation.sudo ledspicerd -f should do that trick right ?
Will have look later again.
-
@Folly the -f option runs in foreground so yes, you should see something...
-
@hopwon said in Syncing button leds with gameplay:
These represent a button press, I think one press = 4 log entries
Missed that part.
No they aren't really button presses.
On the other end you could see it that way but inserting a coin while playing the game does nothing.
Takinggalaga
as example, it's that led0 goes on and off after inserting a coin and when the start button is not pressed yet and not playing the game.
Formissile
that is 2 coins (led0) and 4 coins(led1). -
Was able to test the led on GPIO pin 4 with this :
pi@raspberrypi:~ $ sudo ledspicerd -l Test LEDs (q to quit) Select a Led (r to reset, q to quit): 4 Select a Led (r to reset, q to quit): r Select a Led (r to reset, q to quit): q
So basically
ledspicer
is working.
Have to look at the game profiles now. -
It seems very hard to understand the docs and how everything actually works ;-(
I am struggling with creating a single game input xml in /usr/share/ledspicer/profiles/arcade.
I added galaga in /usr/share/ledspicer/profiles/profile_arcade.xml like this :<?xml version="1.0" encoding="UTF-8"?> <LEDSpicer version="1.0" type="Profile" backgroundColor="Black" > <inputs> <input name="galaga"/> </inputs> </LEDSpicer>
I tried to begin with the example from here.
Though I have to edit the file somehow as it is not accepted.
Do you have an example for me ?
Or, do you know what to edit ?I read over here that you can also use a "craftProfiles" option for multiple games.
"LEDSpicer will attempt to use the pre-scraped data from mame (gameData.xml) along with controls.ini (if available) and colors.ini (if available) to set lighting based on the games control scheme. So... one profile_arcade.xml file to manage thousands of roms."They also use the emitter part.
Is that nessesary to use ? -
@Folly I use craft profiles, it only works for mame. You need a profile in the profiles dir called profile_arcade.xml and then you call emitter from "runcommand_onstart.sh" with LoadProfileByEmulator
Craft profiles really take the heavy lifting out of LEDSpicer config and its an awesome feature.
This is my profile_arcade.xml - there is nothing in it...
<?xml version="1.0" encoding="UTF-8"?> <LEDSpicer version="1.0" type="Profile" backgroundColor="Black" > </LEDSpicer>
After that LEDSpicer takes care of the rest.
I'll try and do a bit more of a write up but Friday night is calling! But check out this link for a guide on as I used it to eventually decode and get LEDSpicer running...
-
I want to get it working before I implement in emulationstation.
Ok, so I do need the emitter.
First I started with :
sudo ledspicerd -f
So for galaga I tried the command but got an error :
pi@raspberrypi:~ $ emitter LoadProfileByEmulator galaga arcade Error: Failed to open device 0xd209:0x1700 id 1 Failed to execute rotator 2 1 '2' 1 1 '2'
The led that I attached burns but there is no other effect when starting galaga.
Any ideas ?All commands are done over 3 terminal consoles.
-
I am really not sure if I should spend more time on this.
Ledspicer seems a really nice and advanced program but I am missing the bigger picture on how it works and how all configs and xml's are connected to each other.
Perhaps I will ditch the elements from the ledspicer.conf except one.
That way I can see if 1 element will react if not I will probably stop trying.Ps.
I have send a message to @MeduZaPaT hope he can help.
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.