Skip to content

[Feature Request] Option to use the Fn switch as a hold/lock switch (like an iPod) #882

Open

Description

@westo27

Title: Option to use the Fn switch as a hold/lock switch (like an iPod)

My Brick keeps waking up in my pocket when the power button gets knocked. I end up with a flat battery, or it sits there with the screen on.

The idea is a "Lock device when toggled" option on the FN Switch settings page that makes the switch work like the hold switch on an iPod classic:

Switch on: every button is locked, including power and volume. Pressing anything just shows a padlock.
The game/menu keeps running and the screen times out as normal.
If it's asleep, the power button won't wake it while the switch is on.
Switch off: buttons work again (it doesn't wake the device by itself, you press power like normal).

I've had a go at it here: https://github.com/westo27/NextUI/tree/fn-switch-lock

Quick rundown:

  • New fnSwitchLock config setting, plus the toggle in the FN Switch menu
  • PAD_poll() is now a small wrapper that swallows input while locked, so it covers the menu, settings and in-game without touching each one
  • keymon skips its volume/brightness handling while locked (it reads the setting from minuisettings.txt since it only has msettings)
  • New lock indicator (reuses the existing lock asset) for the menu and in-game overlay
  • PWR_waitForWake() ignores wake while locked, and goes back to deep sleep if it gets woken while still locked
  • The switch is read straight from the GPIO while asleep, because keymon is stopped during sleep so GetMute() doesn't update

A couple of things I wasn't sure about:

It works alongside the other "when toggled" options rather than replacing them. Not sure if lock should override those.
Should the game pause while locked? I left it running like an iPod keeps playing music.

I still need to test it properly on device. Happy to tidy it up and open a PR if it's something you'd want.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions