fg1998
Posts: 6
Joined: Tue Apr 30, 2013 3:12 pm
Location: Brazil

How to Halt Pi in Advance Menu with gamepads - no keyboard

Tue Apr 30, 2013 3:42 pm

Hi everyone, this is my first post after a while as a forum reader.

I use my pi as a Mame/Stella retro-console with no keyboard - Yes, a real console with gamepads. I just plug into my TV and looks like a dedicate gaming machine.

But I spend some time figuring out how to shutdown/Reboot my Pi when I was on gamepads. There is no way to type 'sudo halt' or 'sudo reboot' and the only way is turn off the pi by removing the power cord. No good.

So I make a very simple way to solve this problem, and this is the solution I found

1 - A create a generic emulator on ADVMENU called UTIL like this

Code: Select all

emulator "Util" generic "/bin/bash" "%p"
emulator_roms "Util" "/home/pi/emulators/util/script"
emulator_altss "Util" "/home/pi/emulators/util/snap"
As we can see, it´s a fake emulator point to 'bash', the raspbian default command prompt. So I created a two scripts to run as emulators in advmenu. The first one is a script to act as a emulator to HALT the Pi and have only this (called 'halt')

Code: Select all

sudo halt
The second is the reboot script (called 'reboot')

Code: Select all

sudo reboot
So now we have two scripts in /home/pi/emulators/util/script (or wherever you want) "halt" and "reboot" and a generic emulator point to "bash". Notice you can (really you must) put some snaps on the util/snap folder to decorate your advmenu.

Lets see how its works .. The line

Code: Select all

emulator "Util" generic "/bin/bash" "%p"
will run the 'roms' (actually the scripts) with the "bash", so we will get someting like this

Code: Select all

/bin/bash halt
Cause Bash can interpret the file script and commands like the typed ones in the keyboard. And we got a "sudo halt" and the system will halt. The same way reboot script will do the job.

It´s a simple way (and the only I found) to solve this, and I can say it´s working fine for me now. I Also make some modifications on advmenu sorce code to avoid users to press the button 1 on gamepad and the advmenu ends (and return to Bash). For my console, the only way to Halt system is using advmenu and in the "util" emulator run the "halt" ROM.

This how this looks like

Image

You can see this post and another Pi stuff in my blog, but only in portuguese ... Sorry :(
http://fg1998.wordpress.com

Regards
fg1998

Return to “Gaming”