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

    GPIO triggered by retroachievements?

    Scheduled Pinned Locked Moved Ideas and Development
    cheevosretroachievemen
    18 Posts 4 Posters 4.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.
    • SanoS
      Sano @meleu
      last edited by Sano

      @meleu AFAIK (but I may be wrong) tail -f use inotify if no sleep interval is specified ;)

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

        @sano looks like using tailf has a little advantage over tail -f

        Look what I found on man tailf:

               tailf  will print out the last 10 lines of the given file and then wait
               for this file to grow.  It is similar to tail -f but  does  not  access
               the  file  when  it  is  not  growing.  This has the side effect of not
               updating the access time for the file, so a filesystem flush  does  not
               occur periodically when no log activity is happening.
        
               tailf  is  extremely  useful  for monitoring log files on a laptop when
               logging is infrequent and the user desires that the hard disk spin down
               to conserve battery life.
        

        Buuuuut, we would need to pipe the output of that command to a grep looking for awarded cheevos and then trigger the command to do GPIO magic. I have no idea how we could do that.

        The answer on that superuser.com link I posted makes me believe that using inotify-tools has a good solution for that. But I didn't have a chance to try it yet (away from my Linux now).

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

          So from the looks of it, RetroArch must monitor the state fo the game, and when a criteria is met, it awards the cheevo and tries to contact the website to update your profile?
          so it would seem that the same piece of code that causes retroarch to contact the website or display the onscreen achievment notification, could in theory toggle the GPIO pin.

          And nope , i havent played around with the achievements yet. I will do.

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

            @spruce_m00se said in GPIO triggered by retroachievements?:

            So from the looks of it, RetroArch must monitor the state fo the game, and when a criteria is met, it awards the cheevo and tries to contact the website to update your profile?

            Yes. Pasting here what I said above putting in bold what I want you to pay atention:

            • when you do what is needed to earn the cheevo, RetroArch
              • shows a message on the screen;
              • if you're running RetroArch with --verbose it writes that message on the log;
              • tries to register your cheevo on the site;
                • if RetroArch can't register you earned the cheevo on the site, it keeps trying until it succeed or RetroArch terminates.

            so it would seem that the same piece of code that causes retroarch to contact the website or display the onscreen achievment notification, could in theory toggle the GPIO pin.

            Well, I really think that doing what you want via bash (or maybe python), checking the log, is a way simpler than implementing a custom C code in RetroArch. But if you really feel confident for implement this in C, then go ahead. The source code file you need to edit in RetroArch is cheevos/cheevos.c.

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

              @meleu is that source code file available for view on a windows pc? whilst away from the pi. I will have a butchers at it, I have only dont programming in arduino, but you never know, I may be able to work it out.

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

                @spruce_m00se said in GPIO triggered by retroachievements?:

                @meleu is that source code file available for view on a windows pc?

                You can see it on any device with a browser and internet access:
                https://github.com/libretro/RetroArch/blob/master/cheevos/cheevos.c

                But man... Look what happenned when Vegeta saw the difference in difficulty between doing what you want changing RetroArch code in C and writing a small script to check the logs:

                over9000

                • Useful topics
                • joystick-selection tool
                • rpie-art tool
                • achievements I made
                spruce_m00seS 2 Replies Last reply Reply Quote 0
                • spruce_m00seS
                  spruce_m00se @meleu
                  last edited by

                  @meleu hahahahahahahaha vegetas a girl anyway

                  1 Reply Last reply Reply Quote 0
                  • spruce_m00seS
                    spruce_m00se @meleu
                    last edited by

                    @meleu do you know who wrote the code for the cheevos?

                    meleuM 1 Reply Last reply Reply Quote 0
                    • spruce_m00seS
                      spruce_m00se
                      last edited by

                      static void cheevos_unlocked(void *task_data, void *user_data, const char *error)
                      {
                      cheevo_t *cheevo = (cheevo_t *)user_data;

                      if (error == NULL)
                      {
                      RARCH_LOG("CHEEVOS awarded achievement %u.\n", cheevo->id);
                      }

                      starting at line 2126, this seems to show signs of being a good place to start looking. maybe the code needed to do the GPIO pin can be added to an IF statement somewhere.

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

                        @spruce_m00se said in GPIO triggered by retroachievements?:

                        @meleu do you know who wrote the code for the cheevos?

                        @spruce_m00se yes, this guy here wrote the most part (maybe 95% or more). I wrote some small contributions (other libretro guys too). And Twinaphex is like a quality control boss of RetroArch code (the one who merge most of the PRs).

                        If you by chance convince leiradel to insert such code in cheevos.c (wich I think very hard), I'm pretty sure that Twinaphex wouldn't merge it in the master branch.

                        Keep in mind that RetroArch is intended to run in several platforms/architectures. Like Raspberry Pi, x86, PlayStation 3, PlayStation Vita, Nintendo 3DS, Nintendo Wii U, Android, etc... The application you want is a really really really edge case for a little niche of RetroArch users in Raspberry Pi...

                        Please, tell me: why not bash/python?

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

                          @meleu said in GPIO triggered by retroachievements?:

                          Please, tell me: why not bash/python?

                          @spruce_m00se well, you didn't give me the answer to that question but you know, this is about cheevos and shell scripting... How can I sleep when there's something related with these two subjects pending?

                          Here is a prove of how simple is to make what you want via bash:

                          #!/bin/bash
                          # This script is just a proof of concept of what is being discussed here:
                          # https://retropie.org.uk/forum/topic/11793/gpio-triggered-by-retroachievements
                          #
                          # Before using this script you need to install inotify-tools:
                          #    sudo apt-get install inotify-tools
                          #
                          # meleu - July/2017
                          
                          readonly file=/dev/shm/runcommand.log
                          
                          while inotifywait -qq -e modify "$file" ; do
                              if tail -1 "$file" | grep "CHEEVOS awarding cheevo"; then
                                  echo "PUT HERE THE COMMAND TO FLASH THE FANCY LIGHTS! YOU GOT A CHEEVO!!"
                              fi
                          done
                          
                          • Useful topics
                          • joystick-selection tool
                          • rpie-art tool
                          • achievements I made
                          NamErehWonN 1 Reply Last reply Reply Quote 0
                          • NamErehWonN
                            NamErehWon @meleu
                            last edited by

                            @meleu Ooh, that's nifty. I bet I could use this to trigger some kind of popup that's more akin to what you'd see on a PlayStation or X-Box.

                            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.