RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Getting the rom name and emulator

    Scheduled Pinned Locked Moved General Discussion and Gaming
    pi model v3pythonscriptretropiesetup
    82 Posts 5 Posters 18.8k 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.
    • D
      daveyman123
      last edited by

      https://gyazo.com/fdca868affb3ecd1f7c6f6accf2bd267
      gif showing progress so far

      1 Reply Last reply Reply Quote 0
      • meleuM
        meleu @cyperghost
        last edited by

        @cyperghost said in Getting the rom name and emulator:

        @daveyman123 I think you better give the 20 bucks to @meleu and he buys me a Caipirinha :)

        Let me know when you come to Rio de Janeiro and we'll drink some Caipirinhas and try to find some arcade to play Street Fighter or something. :)

        • Useful topics
        • joystick-selection tool
        • rpie-art tool
        • achievements I made
        cyperghostC 1 Reply Last reply Reply Quote 0
        • cyperghostC
          cyperghost @meleu
          last edited by cyperghost

          @meleu Don't make any jokes! My company got's a branch office in south america. For three or four weeks a company pal was in Rio to sell goods and he visited his girlfriend there. So it could happen I'm in :) It's unlikly but never say never :)

          SFII? I was more addicted to MK! But for the Caipis sake :)

          meleuM 1 Reply Last reply Reply Quote 1
          • SanoS
            Sano
            last edited by Sano

            You could try something like

            sleep 5
            while [$(pidof retroarch)]
                do
                *script to scroll once*
                sleep 5
            done
            

            Lauched in background by runcommand-onstart.

            cyperghostC 1 Reply Last reply Reply Quote 1
            • D
              daveyman123
              last edited by

              20 bucks to @meleu it is

              1 Reply Last reply Reply Quote 0
              • meleuM
                meleu @cyperghost
                last edited by

                @cyperghost it's not a joke! Consider yourself invited. Any game is fun with enough alcohol and friends. :-)

                • Useful topics
                • joystick-selection tool
                • rpie-art tool
                • achievements I made
                1 Reply Last reply Reply Quote 1
                • meleuM
                  meleu
                  last edited by

                  Let's get back on topic...

                  @daveyman123 usually your python script scrolls the text only once or keeps looping the text?

                  • Useful topics
                  • joystick-selection tool
                  • rpie-art tool
                  • achievements I made
                  D 1 Reply Last reply Reply Quote 0
                  • cyperghostC
                    cyperghost @Sano
                    last edited by cyperghost

                    @sano I think it isn't a matter of the retroarch-PID more that the script does anyting.
                    But it's a nice catch to end a process by watching the retroarch-PID.

                    @meleu and me descriped also ways to terminate a running script :)

                    And thanks for the invitation. It's very unlikely that I ever enter brazil, but as I said never say never and market development changes quickly. My next stops will be more east .... romania, bulgaria, russia, belarussia...

                    1 Reply Last reply Reply Quote 1
                    • D
                      daveyman123 @meleu
                      last edited by

                      @meleu
                      scrolls the text once. I would like it to eventually loop. but right now it stops as soon as the game actually launches

                      meleuM cyperghostC 2 Replies Last reply Reply Quote 0
                      • meleuM
                        meleu @daveyman123
                        last edited by meleu

                        @daveyman123 got it. I'll try something when I get home (it means 4 or 5 hours).

                        • Useful topics
                        • joystick-selection tool
                        • rpie-art tool
                        • achievements I made
                        D 1 Reply Last reply Reply Quote 0
                        • D
                          daveyman123 @meleu
                          last edited by

                          @meleu
                          oh gosh

                          I may have it figured out by then ;)

                          meleuM 2 Replies Last reply Reply Quote 0
                          • cyperghostC
                            cyperghost @daveyman123
                            last edited by cyperghost

                            @meleu @daveyman123 It's late here - going to sleep.
                            Good night mates

                            @daveyman123
                            That's the wrong intention. The script should do the loop not a bash file. The bash file should only tell changes. Because you always load the python interpreter again and again and this will waste resources and even the python language gives you much much controll over strings. So I would rather use python intead of bash.

                            @meleu will certainly find an easy and working solution ;)

                            1 Reply Last reply Reply Quote 0
                            • meleuM
                              meleu @daveyman123
                              last edited by

                              @daveyman123 said in Getting the rom name and emulator:

                              I may have it figured out by then ;)

                              better yet!

                              • Useful topics
                              • joystick-selection tool
                              • rpie-art tool
                              • achievements I made
                              1 Reply Last reply Reply Quote 0
                              • cyperghostC
                                cyperghost @daveyman123
                                last edited by

                                @daveyman123 said in Getting the rom name and emulator:

                                I will look into cyperghost's loop.sh example again and see if that works to put the python script in there

                                The loop example is useless. You should look the runcommand-onstart.shand how scripts are called and running in background. If you were able to readout files you can simply write the romname via echo $3 to a file or you can directly call the python script with $3 command.

                                I think @meleu will do a nice job but meanwhile you can also try to find a solution. I'm 100% sure you find one!
                                Good night

                                1 Reply Last reply Reply Quote 0
                                • meleuM
                                  meleu @daveyman123
                                  last edited by meleu

                                  @daveyman123 Here are some ideas to let you find the solution yourself...

                                  Use this code as inspiration for your runcommand-onstart.sh:

                                  # getting the rom name with no full path and no extension
                                  rom_name="$(basename "${3%.*}")"
                                  
                                  # running the python script in background
                                  sudo /path/to/python/code.py "$rom_name" &
                                  

                                  This one as inspiration for your runcommand-onend.sh:

                                  # killing the python script
                                  sudo pkill -f "/path/to/python/code.py"
                                  

                                  And this one as inspiration for your python script:

                                  #!/usr/bin/python
                                  
                                  # I don't know if it's right, just used @daveyman123 code as example
                                  from UHScroll import *
                                  import unicornhat as unicorn
                                  
                                  import time sys
                                  
                                  while True:
                                      # I have no idea if this command is right, I just used @daveyman123 code as example
                                      unicorn_scroll(sys.argv[1], 'white', 255, 0.2)
                                  
                                      # I have no idea if 5 seconds is OK, adapt it to your needs
                                      time.sleep(5)
                                  
                                  
                                  • Useful topics
                                  • joystick-selection tool
                                  • rpie-art tool
                                  • achievements I made
                                  D 1 Reply Last reply Reply Quote 0
                                  • D
                                    daveyman123 @meleu
                                    last edited by

                                    @meleu
                                    there is still the problem of (i dont know if i mentioned it) the unicorn only scrolls through ONCE (even if i include a loop in python) then it will play a random sequence of lights. I.E. it reads "JIM" or "GOLDEN" in "GOLDENEYE". But as soon as the game launches it freezes or plays random lights.

                                    My fear is it has something to do with the pins being messed with by retropie. I have not tried to replicate the problem on raspbian.. but I may have to try that.

                                    What I have tried:
                                    making sure audio isnt interfering with the unicorn hat pins (i.e. setting the audio output to hdmi)
                                    and obviously have tried making the python script run in the background

                                    1 Reply Last reply Reply Quote 0
                                    • SanoS
                                      Sano
                                      last edited by Sano

                                      @meleu said in Getting the rom name and emulator:

                                      sudo /path/to/python/code.py "$rom_name" &

                                      Try to modify this line like this :

                                      sudo nohup /path/to/python/code.py "$rom_name" &
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • D
                                        daveyman123
                                        last edited by

                                        @Sano
                                        nohup was nohelp... lol

                                        something is happening at the level of the pins i believe

                                        1 Reply Last reply Reply Quote 0
                                        • SanoS
                                          Sano
                                          last edited by Sano

                                          Ok sorry, could you try

                                          nohup sudo /path/to/python/code.py "$rom_name" &
                                          

                                          (possibly with quotes)
                                          I'm pretty sure it's because the parent process (runcommand-onstart) terminates before game launch, so the child are killed, including your script.
                                          This could be solved with the use of nohup, if I ever remember the correct syntax with sudo...

                                          D meleuM 3 Replies Last reply Reply Quote 0
                                          • D
                                            daveyman123 @Sano
                                            last edited by

                                            @sano

                                            does nothing when i do that

                                            my hunch is it has to do with the support for GPIO controllers in retropie. I could be wrong

                                            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.