GPIO triggered by retroachievements?
-
@sano looks like using
tailf
has a little advantage overtail -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). -
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.
-
@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
. - when you do what is needed to earn the cheevo, RetroArch
-
@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.
-
@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.cBut 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:
-
@meleu hahahahahahahaha vegetas a girl anyway
-
@meleu do you know who wrote the code for the cheevos?
-
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.
-
@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?
-
@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
-
@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.
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.