Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to map the auto-rotate lock toggle/switch/setting to a physical button in a device. how do I do that?

On the linux side of android, in linux/input.h, there are different KEY events, SW(switch) events and a lot more. fortunately, the rotation lock is there(SW_ROTATION_LOCK), however it is a switch event type, not a key event type...

Looking in my key layout file (.kl file), all items that are listed there are key events...

On the other hand, the assigned events to these keys are constants in the android framework. looking at where valid key maps are listed, I assume.

What I have done: Registered the physical button to recieve the rotation lock as a switch event on the board configuration settings... (imx6 board) all that's left is on the android side I believe..

so, anyone knows how to map the button to auto-rotation lock/switch?

share|improve this question
You might want to have a look at some of the answers to this previous question: How can I customize the actions associated with my Moto Droid's hardware buttons? – GAThrawn Jan 24 '13 at 10:47
Use AutoInput or Xposed Additions (latter needs Xposed Framework) combined with Tasker to do the job. Use Tasker to create task where the action would be auto-rotate. Attach that task in AutoInput or Xposed Additions. – Firelord Sep 13 '15 at 21:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.