Remove escape to console
  • Hey guys!

    I want to disable using ESC on the main menu to get to the console. Is there a way to do this? I am trying to make my pi run only with a controller. The console would be impossible to escape.

    I just need to make sure someone isn't playing games on my pi and accidently getting to the console.
  • you can, but it will require editing the source code. you need to edit this file:
    /home/pi/pimame/pimame-menu/pmmenu/mainscene.py

    Scroll down near the bottom and find the function called handle_events. It should look like this -> def handle_events(self, events):

    halfway down, you will see where it handles the escape button
    				elif event.key == pygame.K_ESCAPE:
    pygame.quit()
    sys.exit()
    change it to this
    				elif event.key == pygame.K_ESCAPE:
    #pygame.quit()
    #sys.exit()

  • Two things.

    1) How would I reach the console after that? Can I indicate a different key?

    2) Does this also keep the gamepad from exiting the main menu? When you hit B?

    Thanks mholgatem!
  • @jhnwhite: does you controller return characters in the terminal console?
    if so, there's an easy way to return to GUI from terminal. Just let me know.

    @mholgatem: interesting ; is there a "usable keys" reference anywhere? (python doc? pygame doc?) i may tweak this file to manage sound volume rather than using an ugly hack of pmutil.py... :-p
  • @lateo Pretty sure it doesn't. Plus, I want this thing to be usable by other people, which is why I am trying to avoid hitting the console if I can. So far I have a big red button on the top of the pi case that returns to the game list using ESC. I just don't want that button to hit the console if they press it too many times.

    If I can remap this to a key that only appears on a keyboard, then I can still work on the pi when I am at home with my keyboard and mouse.
  • @jhnwhite - You can do a couple of things.
    1) you can add this to your config.yaml
      - label: Exit to Console
    visible: Yes
    full_path: no
    command: ""
    override_menu: yes


    2) you can map some other key to quit out of pimame by changing the first line (from my previous post). change:
    elif event.key == pygame.K_ESCAPE:
    to:
    elif event.key == K_KP_PLUS:
    to assign it to the 'keypad +' key.
    Here is a reference list of pygame key constants http://www.pygame.org/docs/ref/key.html

    Editing the mainscene file will only affect the main menu, it won't change any keypresses for emulators or the romlist scene.
  • Perfect! That is exactly what I need.
    Last thing: The B button on my controller will also exit the main menu. I want to make sure that doesn't happen.

    Thanks for all your help!
  • @jhnwhite - Same area as before, just a bit further down:
    elif event.type == pygame.JOYBUTTONDOWN:
    if event.button == 0:
    self.do_menu_item_action(self.get_selected_item())
    if event.button == 1:
    pygame.quit()
    sys.exit()
    and change it to
    elif event.type == pygame.JOYBUTTONDOWN:
    if event.button == 0:
    self.do_menu_item_action(self.get_selected_item())
    if event.button == 1:
    #pygame.quit()
    #sys.exit()
  • @mholgatem - Looking at option 2 I see something called PiMAME! What's that? ;)
  • @Chad - haha, old habits!
  • @mholgatem 6:00PM:
    thanks for the link :)
  • For the controller part, commenting out pygame.quit() and sys.exit() didn't work. I had to remove everything from the if statement down. It works, but not sure if that messes anything up! Hopefully not.

    Remapped my quit button to Q on my keyboard. Everything is working great now!
  • oops, that's right. Python would expect to see something there, so you would need to comment the 'if event.button == 1:' part out too. sorry bout that. It won't mess anything else up.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!