How to configure the Mouse button action in Android 11

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to configure the Mouse button action in Android 11

Jump to solution
234 Views
subash_p
Contributor III

Hi,

I'm using an imx8mp custom board running Android 11. I need to change the MOUSE_SECONDARY button as BACK. I modified the .kl file to change the action ofMOUSE_SECONDARY, but it's not working, is there any other way to change the MOUSE_SECONDARY action?


Thanks & Regards,
Subash P.

0 Kudos
Reply
1 Solution
181 Views
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi,

This could be done with two different ways: 1. framework layer, 2 kernel event system.

For such remapping on aosp framework, you may need to modify synthesizeButtonKeys function in https://android.googlesource.com/platform/frameworks/base/+/a45746e/services/input/InputReader.cpp, filter the mouse MOUSE_SECONDARY event , mapping it to KEYCODE_BACK.

For kernel event system, you need write a service to map BTN_RIGHT to KEY_BACK, then the aosp can always get KEY_BACK event while you click mouse BTN_RIGHT.

Best Regards,
Zhiming

View solution in original post

1 Reply
182 Views
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi,

This could be done with two different ways: 1. framework layer, 2 kernel event system.

For such remapping on aosp framework, you may need to modify synthesizeButtonKeys function in https://android.googlesource.com/platform/frameworks/base/+/a45746e/services/input/InputReader.cpp, filter the mouse MOUSE_SECONDARY event , mapping it to KEYCODE_BACK.

For kernel event system, you need write a service to map BTN_RIGHT to KEY_BACK, then the aosp can always get KEY_BACK event while you click mouse BTN_RIGHT.

Best Regards,
Zhiming

%3CLINGO-SUB%20id%3D%22lingo-sub-2200540%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EHow%20to%20configure%20the%20Mouse%20button%20action%20in%20Android%2011%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2200540%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI'm%20using%20an%20imx8mp%20custom%20board%20running%20Android%2011.%20I%20need%20to%20change%20the%20MOUSE_SECONDARY%20button%20as%20BACK.%20I%20modified%20the%20.kl%20file%20to%20change%20the%20action%20ofMOUSE_SECONDARY%2C%20but%20it's%20not%20working%2C%20is%20there%20any%20other%20way%20to%20change%20the%20MOUSE_SECONDARY%20action%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20%26amp%3B%20Regards%2C%3CBR%20%2F%3ESubash%20P.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2200540%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EAndroid%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ei.MX%208%20Family%20%7C%20i.MX%208QuadMax%20(8QM)%20%7C%208QuadPlus%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ei.MX%208M%20%7C%20i.MX%208M%20Mini%20%7C%20i.MX%208M%20Nano%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2201512%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20How%20to%20configure%20the%20Mouse%20button%20action%20in%20Android%2011%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2201512%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3CBR%20%2F%3E%3CBR%20%2F%3EThis%20could%20be%20done%20with%20two%20different%20ways%3A%201.%20framework%20layer%2C%202%20kernel%26nbsp%3Bevent%20system.%3C%2FP%3E%0A%3CP%3EFor%20such%20remapping%20on%20aosp%20framework%2C%20you%20may%20need%20to%20modify%20%3CSTRONG%3EsynthesizeButtonKeys%20%3C%2FSTRONG%3Efunction%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fandroid.googlesource.com%2Fplatform%2Fframeworks%2Fbase%2F%2B%2Fa45746e%2Fservices%2Finput%2FInputReader.cpp%2C%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fandroid.googlesource.com%2Fplatform%2Fframeworks%2Fbase%2F%2B%2Fa45746e%2Fservices%2Finput%2FInputReader.cpp%2C%3C%2FA%3E%26nbsp%3Bfilter%20the%20mouse%20%3CSPAN%3EMOUSE_SECONDARY%26nbsp%3B%3C%2FSPAN%3Eevent%20%2C%20mapping%20it%20to%20KEYCODE_BACK.%3C%2FP%3E%0A%3CP%3EFor%20kernel%20event%20system%2C%20you%20need%20write%20a%20service%20to%20map%26nbsp%3BBTN_RIGHT%20to%26nbsp%3BKEY_BACK%2C%20then%20the%20aosp%20can%20always%20get%26nbsp%3BKEY_BACK%20event%20while%20you%20click%20mouse%26nbsp%3BBTN_RIGHT.%3CBR%20%2F%3E%3CBR%20%2F%3EBest%20Regards%2C%3CBR%20%2F%3EZhiming%3C%2FP%3E%3C%2FLINGO-BODY%3E