Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

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 http://developer.android.com/reference/android/view/KeyEvent.html 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

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.