In the previous post I created some power logging programs so that I can view the power cycles of my RaspberryPi (Check out that post here). I finished by setting up one of the programs to run at boot up. In this post I will be combining the remaining two programs with the menu of EmulationStation.
The file that has to be edited is GuiMenu.cpp. This is the file that holds all the information for the menu when you call up it up EmulationStation. Since everything changed after the new update the first thing that I had to do was locate this file.
pi@raspberry ~ $ sudo find / -name GuiMenu.cpp /opt/retropie/supplementary/EmulationStation/es-app/src/guis/GuiMenu.cpp pi@raspberry ~ $ |
Once I found the location I went into that directory and made a backup of the file just incase.
pi@raspberry ~ $ cd /opt/retropie/supplementary/EmulationStation/es-app/src/guis pi@raspberry /opt/retropie/supplementary/EmulationStation/es-app/src/guis $ sudo cp GuiMenu.cpp GuiMenu.cpp.bak |
I opened up the file with
pi@raspberry /opt/retropie/supplementary/EmulationStation/es-app/src/guis $ sudo nano GuiMenu.cpp |
and found that this version is programmed a lot different than the previous one. After a little bit of reading through this file I found the two lines that I have to edit. Below I copied the whole section and made the two lines of interest bold and yellow.
addEntry(“QUIT”, 0x777777FF, true, [this] { auto s = new GuiSettings(mWindow, “QUIT”); Window* window = mWindow; ComponentListRow row; row.makeAcceptInputHandler([window] { window->pushGui(new GuiMsgBox(window, “REALLY RESTART?”, “YES”, [] { if(system(“sudo shutdown -r now”) != 0) LOG(LogWarning) << “Restart terminated with non-zero result!”; }, “NO”, nullptr)); }); row.addElement(std::make_shared(window, “RESTART SYSTEM”, Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); s->addRow(row); row.elements.clear(); row.makeAcceptInputHandler([window] { window->pushGui(new GuiMsgBox(window, “REALLY SHUTDOWN?”, “YES”, [] { if(system(“sudo shutdown -h now”) != 0) LOG(LogWarning) << “Shutdown terminated with non-zero result!”; }, “NO”, nullptr)); }); row.addElement(std::make_shared(window, “SHUTDOWN SYSTEM”, Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); s->addRow(row); if(Settings::getInstance()->getBool(“ShowExit”)) { row.elements.clear(); row.makeAcceptInputHandler([window] { window->pushGui(new GuiMsgBox(window, “REALLY QUIT?”, “YES”, [] { SDL_Event ev; ev.type = SDL_QUIT; SDL_PushEvent(&ev); }, “NO”, nullptr)); }); row.addElement(std::make_shared(window, “QUIT EMULATIONSTATION”, Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); s->addRow(row); } mWindow->pushGui(s); }); |
I was in luck since it looks like these are regular bash commands, just like how they would be types in the terminal! I simply changed them so that instead of calling out a shut down it will call up my programs. Below shows those two lines changed; I listed the whole section again so that it might be easier to understand what I did.
addEntry(“QUIT”, 0x777777FF, true, [this] { auto s = new GuiSettings(mWindow, “QUIT”); Window* window = mWindow; ComponentListRow row; row.makeAcceptInputHandler([window] { window->pushGui(new GuiMsgBox(window, “REALLY RESTART?”, “YES”, [] { if(system(“python /home/pi/programs/power_reset_log.py”) != 0) LOG(LogWarning) << “Restart terminated with non-zero result!”; }, “NO”, nullptr)); }); row.addElement(std::make_shared(window, “RESTART SYSTEM”, Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); s->addRow(row); row.elements.clear(); row.makeAcceptInputHandler([window] { window->pushGui(new GuiMsgBox(window, “REALLY SHUTDOWN?”, “YES”, [] { if(system(“python /home/pi/programs/power_off_log.py”) != 0) LOG(LogWarning) << “Shutdown terminated with non-zero result!”; }, “NO”, nullptr)); }); row.addElement(std::make_shared(window, “SHUTDOWN SYSTEM”, Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); s->addRow(row); if(Settings::getInstance()->getBool(“ShowExit”)) { row.elements.clear(); row.makeAcceptInputHandler([window] { window->pushGui(new GuiMsgBox(window, “REALLY QUIT?”, “YES”, [] { SDL_Event ev; ev.type = SDL_QUIT; SDL_PushEvent(&ev); }, “NO”, nullptr)); }); row.addElement(std::make_shared(window, “QUIT EMULATIONSTATION”, Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); s->addRow(row); } mWindow->pushGui(s); }); |
This is a powerful file and a lot can be down with this once you site down and understand what is going on. You can change the whole menu up or just change the colors! I might end up re-visiting this file in the future.
I saved and exited with:
Ctrl+X Y Enter |
Now the file has been edited we have to re-compile the program. This is an important step to do so that the changes actually effect.
I have to back out a few directories to the main EmulationStation on and then run the make command.
pi@raspberry /opt/retropie/supplementary/EmulationStation/es-app/src/guis $ cd ../../../.. pi@raspberry /opt/retropie/supplementary/EmulationStation $ sudo make |
This will take a while so I ran it over night. The good news is that once you do it once, every other time will only take a few minutes!
I rebooted with
pi@raspberry /opt/retropie/supplementary/EmulationStation $ sudo reboot |
and in EmulationStation I tested the two menu items that I edited and found they still worked! I exited out of EmulationStation and I checked the log file and found that everything was in fact logging!
pi@raspberry ~ $ cd programs pi@raspberry ~/programs $ cat power_log.txt System powered on on Sat Sep 20 23:00:31 2014 System powered off on Sat Sep 20 23:02:21 2014 System powered on on Sat Sep 20 23:02:47 2014 System powered on on Thu Sep 25 17:46:37 2014 System restarted on Thu Sep 25 17:56:27 2014 System powered on on Thu Sep 25 17:56:52 2014 pi@raspberry ~/programs $ |
That’s it! It seems a lot more complicated than it is and this could save you a lot of troubleshooting down the line if you take some added time now to set up some logging file. You can even log every single option in here if you wanted!
Check out these other helpful links:
Mapping Controllers (1 of 3): For EmulationStation
Mapping Controllers (2 of 3): Mapping Controllers to a File
Mapping Controllers (3 of 3): Setting up Controllers in RetroArch
Auto detecting controllers in EmulationStation 2.0+
RetroPie: Adding game roms, BIOS files, and enabling save states
Setting up GameBoy Advance for RetroPie
Adding a XBMC tab in EmulationStation
Adding an Apps tab in EmulationStation
Setting up Playstation for RetroPie
Creating power logs for EmulationStation (1 of 2)
Creating power logs for EmulationStation (2 of 2)