glint-box icon indicating copy to clipboard operation
glint-box copied to clipboard

Reset switch

Open brandtdaniels opened this issue 13 years ago • 11 comments

Since there are no buttons to spare on an NES or SNES controller and ideally we don't want to have a keyboard attached, a switch to exit the game is necessary.

Two options for switches:

Option 1:

really easy to implement. Acts as a hard reset switch to reset the whole RPi.

http://raspi.tv/2012/making-a-reset-switch-for-your-rev-2-raspberry-pi

Option 2:

More difficult, uses the GPIO pins, a minor circuit involved, and a program in kernel space.

compile: git://github.com/petrockblog/SNESDev-RPi.git

setup to start at boot.

hook up switch

brandtdaniels avatar Dec 24 '12 00:12 brandtdaniels

Let me know how your experiments go here. I hope to eventually build kits that are the full-blown console experience (a pre-built SD card along with an RPi, a case, a controller, and all the cables), not just the software. So I'm definitely curious to find out what the cost/complexity tradeoffs are here.

jefflunt avatar Dec 24 '12 04:12 jefflunt

Needed to instal SNESDev-Rpi:

apt-get -y install git
export PIHOME="/home/pi"
wget http://www.open.com.au/mikem/bcm2835/bcm2835-1.14.tar.gz
tar -zxvf bcm2835-1.14.tar.gz
mkdir $PIHOME/supplementary
mv bcm2835-1.14 $PIHOME/supplementary/
pushd $PIHOME/supplementary/bcm2835-1.14
./configure
make clean
make
make install
popd
rm bcm2835-1.14.tar.gz 
mkdir -p $PIHOME/supplementary/SNESDev-Rpi
git clone "git://github.com/petrockblog/SNESDev-RPi.git" "$PIHOME/supplementary/SNESDev-Rpi"
pushd $PIHOME/supplementary/SNESDev-Rpi/
if [[ ! -f "$PIHOME/supplementary/SNESDev-Rpi/bin/SNESDev" ]]; then
         __ERRMSGS="$__ERRMSGS Could not successfully compile SNESDev."  
     else
         cp "$PIHOME/supplementary/SNESDev-Rpi/bin/SNESDev" /usr/local/bin/
     fi    
popd
#enable SNESDev on boot polling only button
if [[ ! -f "/etc/init.d/SNESDev" ]]; then
   if [[ ! -f "$PIHOME/supplementary/SNESDev-Rpi/bin/SNESDev" ]]; then
      echo "Cannot find SNESDev binary. Please install SNESDev."    
   else
      chmod +x "$PIHOME/supplementary/SNESDev-Rpi/scripts/SNESDev"
      cp "$PIHOME/supplementary/SNESDev-Rpi/scripts/SNESDev" /etc/init.d/
   fi
   cp "$PIHOME/supplementary/SNESDev-Rpi/bin/SNESDev" /usr/local/bin/
fi    
#ARG 2 is polling button only
sed "/etc/init.d/SNESDev" -i -e 's|^DAEMON_ARGS.*|DAEMON_ARGS="2"|g'
# This command installs the init.d script so it automatically starts on boot
update-rc.d SNESDev defaults
# This command starts the daemon now so no need for a reboot
service SNESDev start    
echo "avoid_safe_mode=1" >> /boot/config.txt
echo "input_exit_emulator = escape" >> $PIHOME/.retroarch/retroarch.cfg
echo "rewind_enable = true" >> $PIHOME/.retroarch/retroarch.cfg
echo "input_rewind = r" >> $PIHOME/.retroarch/retroarch.cfg

brandtdaniels avatar Dec 28 '12 00:12 brandtdaniels

The button works great!!!! I laid it out on a breadboard....I also ordered the GPIO adapter from Florian (petrockblog)

Used an Omron B3F-1000 momentary tactile button

[ P1-1 (3.3vdc) ] ----> [ -- Button -- ] ----> [ P1-11 (GPIO17) ] ----> [ 20% 10K Ohm Resistor ] ----> [ P1-9 (GND) ]

Here is how it's used:

  • press and hold: send “r” key (for rewind function of RetroArch)
  • press and release three times: send “ESC”
  • press and release five times: shutdown

brandtdaniels avatar Dec 28 '12 02:12 brandtdaniels

So when the button is pressed five times and the system shuts down, there is still a red power light that is on. I read that if you use a reset switch at jumper P6 on the pi that it can also power the system back up from a halt, so I tried it and it works. A button at jumper P6 would act as a reset switch and a boot from halt switch.

brandtdaniels avatar Jan 06 '13 09:01 brandtdaniels

I've also been thinking about the extra buttons, I have a Logitech F310 gamepad that I bought because it looks like it has enough keys for all the consoles I want to emulate. The nice thing is that it has an extra button that I assign to "hotkey" in retroarch: http://forum.themaister.net/viewtopic.php?pid=1065#p1065 Then I make other buttons do things like exit, save, restore, reset. Seems to work like a charm.

adrianmoisey avatar Jan 06 '13 10:01 adrianmoisey

That's the kind of controls I'm interested in as well - customizing my setup to allow save/restore etc.

I may also be considering, in addition to selling kits, to offer an arcade stick option that provides enough buttons for all that extra stuff. That would be a separate kit option, however. In that scenario I would support, out of the box, two controller setups. Looks like the udev option to select a config based on the controller may be something that's going to make us end up supporting hundreds of controllers.

Maybe it won't be all that bad - maybe the community will standardize around 10 controllers or something. :S

-Jeff

On Sun, Jan 6, 2013 at 4:25 AM, Adrian Moisey [email protected]:

I've also been thinking about the extra buttons, I have a Logitech F310 gamepad that I bought because it looks like it has enough keys for all the consoles I want to emulate. The nice thing is that it has an extra button that I assign to "hotkey" in retroarch: http://forum.themaister.net/viewtopic.php?pid=1065#p1065 Then I make other buttons do things like exit, save, restore, reset. Seems to work like a charm.

— Reply to this email directly or view it on GitHubhttps://github.com/normalocity/glint-nes/issues/23#issuecomment-11926677.

jefflunt avatar Jan 06 '13 16:01 jefflunt

Someone posted this in the RPi forums a little bit ago. I didn't know this is how the exit emulator hotkeys worked, but apparently it's totally possible to exit the emulator without a keyboard right now. We just have to set both options in the retroarch.cfg file.

http://forum.themaister.net/viewtopic.php?pid=1065#p1065

jefflunt avatar Jan 07 '13 21:01 jefflunt

made a change to main.c in SNESDev-Rpi:

1 press to exit retrorarch 2 press to shutdown the pi

                                if (btnPressCtr==1) {
                                        //send_key_event(uinh, KEY_R,0);
                                        // Sending ESC
                                        send_key_event(uinh, KEY_ESC,1);
                                        usleep(50000);
                                        send_key_event(uinh, KEY_ESC,0);
                                } else if (btnPressCtr==2) {
                                        // shutting down
                                        pollButton = 0;
                                        pollPads = 0;
                                        send_key_event(uinh, KEY_F4,1);
                                        usleep(50000);
                                        send_key_event(uinh, KEY_F4,0);
                                        system("shutdown -t 3 -h now");
                                } /*else if (btnPressCtr==3) {
                                        // Sending ESC
                                        send_key_event(uinh, KEY_ESC,1);
                                        usleep(50000);
                                        send_key_event(uinh, KEY_ESC,0);
                                } else if ( btnPressCtr==5 ) {
                                        // shutting down
                                        pollButton = 0;
                                        pollPads = 0;
                                        send_key_event(uinh, KEY_F4,1);
                                        usleep(50000);
                                        send_key_event(uinh, KEY_F4,0);
                                        system("shutdown -t 3 -h now");
                                }*/

What else would be useful to us?

brandtdaniels avatar Jan 09 '13 06:01 brandtdaniels

I think that's pretty good. The main thing I want is for exiting retroarch to be the least number of presses, since it's the most common task.

Everything else, I think, can be done via the glint-es menu, but I definitely like the double press to shutdown thing.

-Jeff

On Wed, Jan 9, 2013 at 12:47 AM, Brandt Daniels [email protected]:

made a change to main.c in SNESDev-Rpi:

1 press for exit retrorarch 2 press to shutdown the pi

if (btnPressCtr==1) { //send_key_event(uinh, KEY_R,0); // Sending ESC send_key_event(uinh, KEY_ESC,1); usleep(50000); send_key_event(uinh, KEY_ESC,0); } else if (btnPressCtr==2) { // shutting down pollButton = 0; pollPads = 0; send_key_event(uinh, KEY_F4,1); usleep(50000); send_key_event(uinh, KEY_F4,0);

                                system("shutdown -t 3 -h now");
                        } /*else if (btnPressCtr==3) {
                                // Sending ESC
                                send_key_event(uinh, KEY_ESC,1);
                                usleep(50000);
                                send_key_event(uinh, KEY_ESC,0);
                        } else if ( btnPressCtr==5 ) {
                                // shutting down
                                pollButton = 0;
                                pollPads = 0;
                                send_key_event(uinh, KEY_F4,1);
                                usleep(50000);
                                send_key_event(uinh, KEY_F4,0);

                                system("shutdown -t 3 -h now");
                        }*/

What else would be useful to us?

— Reply to this email directly or view it on GitHubhttps://github.com/normalocity/glint-nes/issues/23#issuecomment-12033572.

jefflunt avatar Jan 09 '13 14:01 jefflunt

I've been struggling to get the exit emulator function working properly in the retroarch.cfg.

The following code results in that pressing the "start(5)" button without the use of the hotkey button "select(6)" still activates the exit command which of course is undesirable.

#Exit back to rom list
input_enable_hotkey_btn = "6"
input_exit_emulator_btn = "5"

I was hoping that I could just use "input_player2_exit_emulator_btn = "5" so that I could use the start button on the player 2 controller, but alas that failed to work :(

There's other ways I can achieve the reset, but the above method imo would be the best.

DNA64 avatar Aug 22 '13 08:08 DNA64

2 player support is broken in the January release, which I'm guessing is the reason why the second controller solution doesn't work. On Aug 22, 2013 3:36 AM, "DNA64" [email protected] wrote:

I've been struggling to get the exit emulator function working properly in the retroarch.cfg.

The following code results in that pressing the "start(5)" button without the use of the hotkey button "select(6)" still activates the exit command which of course is undesirable.

#Exit back to rom list input_enable_hotkey_btn = "6" input_exit_emulator_btn = "5"

I was hoping that I could just use "input_player2_exit_emulator_btn = "5" so that I could use the start button on the player 2 controller, but alas that failed to work :(

There's other ways I can achieve the reset, but the above method imo would be the best.

— Reply to this email directly or view it on GitHubhttps://github.com/jefflunt/glint-box/issues/23#issuecomment-23075463 .

jefflunt avatar Aug 22 '13 12:08 jefflunt