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

Adding additional events into ES

Scheduled Pinned Locked Moved Ideas and Development
development
25 Posts 5 Posters 3.3k 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.
  • R
    RussellB
    last edited by RussellB 5 Dec 2021, 16:57 12 May 2021, 14:49

    Hi all,

    @folly recommended I post this here and look for feedback.

    I've just installed a PixelCade into my custom arcade bartop. Integrating it with ES required a custom version of ES which traps when a user changes systems or changes games so it then call REST services exposed by the PixelCade listener in the ES code to update the marquee.

    While this approach works, it's not very flexible if you want to change the behavior of the PixelCade or do something totally different, so I re-implemented this capability as events:

    system-select - when a system is first displayed or changed. %system_name% %event type% where event type is "gotostart" or "input"
    game-select - when a game is selected after going to the system. %system_name% %rom name% %game name%
    screensaver-game-select - when playing game videos. %system_name% %rom name% %game name%

    So now I've written bash scripts that perform the integration to the Pixelcade and dropped them in the respective folders.

    This was my user story but it's very flexible. I've seen some message threads where people were asking for a startup event other than autostart.sh because that is executed BEFORE ES is started.

    Does anyone else find this functionality useful?

    RussellB

    R 1 Reply Last reply 15 May 2021, 13:39 Reply Quote 2
    • R
      RussellB @RussellB
      last edited by 15 May 2021, 13:39

      Here's an example of what you can do with scripting the game-select, game-start and game-end events.

      https://www.dropbox.com/s/u46mfyii2gm1yud/20210514_085432.mp4?dl=0

      F 1 Reply Last reply 15 May 2021, 16:36 Reply Quote 1
      • F
        Folly @RussellB
        last edited by 15 May 2021, 16:36

        @russellb

        That is very cool indeed !

        R 1 Reply Last reply 16 May 2021, 03:14 Reply Quote 0
        • R
          RussellB @Folly
          last edited by 16 May 2021, 03:14

          @folly So how do I add my changes into the main branch?

          F 1 Reply Last reply 16 May 2021, 09:42 Reply Quote 0
          • S
            svera
            last edited by 16 May 2021, 08:07

            @RussellB this is really cool! To add your changes to ES, you will need to create a pull request against https://github.com/RetroPie/EmulationStation. So, if you haven't worked with Github before, these are the basic steps you need to follow:

            1. Fork ES repository in your Github user space.
            2. Clone ES repo in your system.
            3. Create a new branch naming it as you wish, e.g.: game-system-select-events
            4. Apply changes in your cloned ES repository.
            5. Commit your changes and push them to Github
            6. Open a new pull request from the branch in your fork against retropie:Master, explaining what you did in the description and following whatever guidelines Retropie has.
            7. Wait for your changes to be approved/merged. Be ready to do whatever changes are required until your code is considered fit for merging.

            I know most of what I said here will make no sense if you haven't worked with git and gitHub before, in that case it is better to read something like https://product.hubspot.com/blog/git-and-github-tutorial-for-beginners before diving in.

            Good luck!

            1 Reply Last reply Reply Quote 2
            • F
              Folly @RussellB
              last edited by Folly 16 May 2021, 09:42

              @russellb

              (@svera, nice explanation on the how to ! )

              Making these pull requests is very difficult, if you never done this before !
              Even I have still trouble understanding it and doing this.
              Before going though the process of a pull request, I think, it better to share you code first and make a tutorial for this.
              That way more people can look at it and test it and get out the flaws or add ideas to it.
              Otherwise you will stuck in doing multiple pull request on all changes you will be making.
              My advice, just let it evolve until you are really satisfied, then make a pull request.
              As I understand before, you didn't change things on Emulationstation, am I correct ?
              So if you want to do a pull request you have to do a pull request to the part you want to integrate it to.

              If you are planning to do a pull request, it would be nice if you explain the whole process in this thread so everybody can learn from this.
              I think @svera can be of more help with this, than I can.

              R 1 Reply Last reply 16 May 2021, 20:51 Reply Quote 0
              • R
                RussellB @Folly
                last edited by 16 May 2021, 20:51

                @folly I just cloned from here: https://github.com/RetroPie/EmulationStation.

                I ended up changing six files. I'll post the changes here specifically shortly.

                R 1 Reply Last reply 17 May 2021, 01:12 Reply Quote 0
                • R
                  RussellB @RussellB
                  last edited by 17 May 2021, 01:12

                  @russellb said in Adding additional events into ES:

                  @folly I just cloned from here: https://github.com/RetroPie/EmulationStation.

                  I ended up changing six files. I'll post the changes here specifically shortly.

                  Ok, modified the following files:

                  Scripting.h :

                  int fireEvent(const std::string& eventName, const std::string& arg1="", const std::string& arg2="", const std::string& arg3="");
                  

                  Added a third string variable so I can send "system", "rom name", "game name" as unique parameters. I made it optional so as to not have to change every occurrence.

                  Scripting.cpp:

                                  if (arg1.length() > 0) {
                                      script += " \"" + arg1 + "\"";
                                      if (arg2.length() > 0) {
                                          script += " \"" + arg2 + "\"";
                                          if (arg3.length() > 0) {
                                              script += " \"" + arg3 + "\"";
                                          }
                                      }
                                  }
                  

                  Added putting the third parameter onto the call to the script.

                  ISimpleGameListView.cpp

                  #include "Scripting.h"
                  .
                  .
                  .
                  FileData* cursor = getCursor();
                          SystemData* system = this->mRoot->getSystem();
                          if (system != NULL) {
                              Scripting::fireEvent("game-select", system->getName(), cursor->getFileName(), cursor->getName());
                          }
                  

                  This is at the end of the ::input function to fire the "game-select" event

                  SystemView.cpp:

                  #include "Scripting.h"
                  .
                  .
                  .
                                  if(config->isMappedLike("left", input) ||
                                          config->isMappedLike("right", input) ||
                                          config->isMappedLike("up", input) ||
                                          config->isMappedLike("down", input))
                                          listInput(0);
                                  Scripting::fireEvent("system-select", this->IList::getSelected()->getName(), "input");
                                  if(!UIModeController::getInstance()->isUIModeKid() && config->isMappedTo("select", input) && Settings::getInstance()->getBool("ScreenSaverControls"))
                                  {
                                          mWindow->startScreenSaver();
                                          mWindow->renderScreenSaver();
                                          return true;
                                  }
                  
                  

                  This is at the end of the ::input function to fire the "system-select" event

                  ViewController.cpp:

                  #include "Scripting.h"
                  .
                  .
                  .
                  void ViewController::goToStart()
                  {
                          // If specific system is requested, go directly to the game list
                          auto requestedSystem = Settings::getInstance()->getString("StartupSystem");
                          if("" != requestedSystem && "retropie" != requestedSystem)
                          {
                                  for(auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); it++){
                                          if ((*it)->getName() == requestedSystem)
                                          {
                                                  goToGameList(*it);
                                                  Scripting::fireEvent("system-select", requestedSystem, "requestedsystem");
                                                  return;
                                          }
                                  }
                  
                                  // Requested system doesn't exist
                                  Settings::getInstance()->setString("StartupSystem", "");
                          }
                          goToSystemView(SystemData::sSystemVector.at(0));
                          Scripting::fireEvent("system-select", SystemData::sSystemVector.at(0)->getName(), "gotostart");
                  }
                  

                  This is the "system-select" event of selecting a system at startup

                  SystemScreenSaver.cpp:

                  #include "Scripting.h"
                  .
                  .
                  .
                  void SystemScreenSaver::startScreenSaver()
                  .
                  .
                  .
                  3 points to call the event "screensaver-game-select"
                  

                  I didn't want to put all the code here.

                  Please let me know if you have any questions.

                  RussellB

                  S F 2 Replies Last reply 17 May 2021, 07:31 Reply Quote 1
                  • S
                    svera @RussellB
                    last edited by 17 May 2021, 07:31

                    @russellb the best way to get feedback for your changes is by opening a pull request.

                    Don't clone from https://github.com/RetroPie/EmulationStation but from your fork, that should be https://github.com/<your github user name>/EmulationStation. Create a branch, make your changes there and push that branch back to https://github.com/<your github user name>/EmulationStation. Once that is done, go to https://github.com/RetroPie/EmulationStation/pulls and open a pull request of the branch in your fork against Retropie's master branch. Refer to my previous post if you need more details.

                    When you have created the pull request, the changes you made will be reviewed by Retropie's repository maintainers, and if there's something that can be improved they will drop you a comment in the pull request page. Once everything is fine, your changes will be merged against master.

                    1 Reply Last reply Reply Quote 2
                    • F
                      Folly @RussellB
                      last edited by 17 May 2021, 08:21

                      @russellb

                      C++ isn't my strongest point yet, so I guess a bit here and there.
                      But overall it looks nice !

                      I think you have to go through @svera 's recommendations.
                      Just fork it to your own github, make the changes and do a pull request.

                      R 1 Reply Last reply 17 May 2021, 12:09 Reply Quote 0
                      • R
                        RussellB @Folly
                        last edited by 17 May 2021, 12:09

                        @folly Ok! Will do.

                        R 1 Reply Last reply 17 May 2021, 16:17 Reply Quote 1
                        • R
                          RussellB @RussellB
                          last edited by 17 May 2021, 16:17

                          @folly, @svera

                          "Like the sauce... it's in there!"

                          https://edgewatertech.wordpress.com/2008/08/25/web-20-like-prego-spaghetti-sauce-its-in-there/

                          RussellB (EnsignRutherford)

                          F 1 Reply Last reply 17 May 2021, 18:32 Reply Quote 0
                          • F
                            Folly @RussellB
                            last edited by Folly 17 May 2021, 18:32

                            @russellb

                            Yes I read your link.
                            Bottom line everything can be confusing some times.
                            Did I summarize correct ? ;-)

                            If we can, we will help.

                            R 1 Reply Last reply 17 May 2021, 19:56 Reply Quote 0
                            • R
                              RussellB @Folly
                              last edited by RussellB 17 May 2021, 19:56

                              @folly, @svera - The pull request is now pending so let's see what happens.

                              While doing more testing I found a 'bug', at least what I think is a bug:

                              In ViewController.cpp if there is a startup system specified the event fires for that system. When the bash script gets the event it sets the marquee to the system, e.g. Atari Classics.

                              The problem here is the user interface shows the "Atari Classics" marquee, NOT "720 Degrees" which is the first game selected.

                              I'm missing the "game-select" event for when a startup system is specified. For my purposes, it's a bug and I need to figure out how to get the "current game" in ViewController.cpp or where the first game is set during startup.

                              It's not REALLY a bug as everything works as was designed. I just want to find the spot to fire that event so the bash scripts can capture it too. The bash script can decide to either show the game marquee or the system marquee. I'd rather it there than in the C++ code.

                              R 1 Reply Last reply 18 May 2021, 15:12 Reply Quote 2
                              • R
                                RussellB @RussellB
                                last edited by 18 May 2021, 15:12

                                @folly, @svera Ok I figured it out. Need to add another parameter to game-select and specify "requestedgame". This gives the bash scripts an option to either display the requested game logo or the system logo when a startup system is specified.

                                I'm going to have to redo my pull request.

                                @svera, Can I just cancel it and redo it?

                                R 1 Reply Last reply 19 May 2021, 01:30 Reply Quote 0
                                • R
                                  RussellB @RussellB
                                  last edited by 19 May 2021, 01:30

                                  Done!

                                  F S 2 Replies Last reply 19 May 2021, 06:11 Reply Quote 0
                                  • F
                                    Folly @RussellB
                                    last edited by 19 May 2021, 06:11

                                    @russellb

                                    I am following what you are doing in the pull.
                                    Curious how it goes.

                                    1 Reply Last reply Reply Quote 0
                                    • S
                                      svera @RussellB
                                      last edited by 19 May 2021, 07:50

                                      @russellb you don't need to close and reopen the pull request every time you do changes in the code, just commit and push those changes and the pull request will be updated automatically.

                                      A 1 Reply Last reply 2 Jan 2023, 06:16 Reply Quote 0
                                      • M mitu referenced this topic on 25 Feb 2022, 16:18
                                      • A
                                        alinke @svera
                                        last edited by 2 Jan 2023, 06:16

                                        @svera @RussellB do you know if this one ever made it, specifically the new game-select and system-select event scripts. I did just try the latest 4.8 RetroPie on a Pi 4 but no luck. game-start works fine as it did before , just not these two new ones. They would be super helpful to have for the integration of Pixelcade arcade marquees with RetroPie .

                                        The two events are listed also in the docs https://retropie.org.uk/docs/EmulationStation/#scripting

                                        Thanks!

                                        Al

                                        M 1 Reply Last reply 2 Jan 2023, 08:58 Reply Quote 0
                                        • M
                                          mitu Global Moderator @alinke
                                          last edited by 2 Jan 2023, 08:58

                                          @alinke The events are in - what version (exactly) of RetroPie and EmulationStation are you using ? Make sure you have run an update to have the latest version of EmulationStation.

                                          A 1 Reply Last reply 2 Jan 2023, 20:22 Reply Quote 0
                                          20 out of 25
                                          • First post
                                            20/25
                                            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.

                                            This community forum collects and processes your personal information.
                                            consent.not_received