[GUIDE] [ROOT] How to make your headset buttons be recognized by the Operating System - Xiaomi Mi Max Guides, News, & Discussion

This guide will show you how to make a custom keyboard layout file so your OS will correctly recognize your headset buttons. Other guides have focused on modifying the generic.kl file, but this guide will show you how to make the keyboard layout file specific for your headset device.
You will need to be rooted to use all of the tools and install the file.
For background information, please google "android keyboard layout file" The first hit should be an android developer page about keyboard layout files. (I'm not able to post links)
I'm using a Xiaomi Mi Max and a Xiaomi headset with three buttons, but the guide should work for any combination of phone or headset.
1. Download keytest.apk (you'll need to google it or look for it on github)
Open the app, plugin your headset and press the buttons. The most important information given is the scanCode. Write down the scanCode for each button.
These are the numbers I had:
Top Button = 257
Middle Button = 226
Bottom Button = 258​2. Download Kernal Adiutor from the play store.
Open Kernal Adiutor and go to the input tab. At the bottom of the list of input devices you should see something related to your sound card and hopefully see a Button Jack and Headset Jack.
I saw this device listed: msm8976-tashalite-snd-card Button Jack
Your device will probably have a different name.​3. Create the .kl file.
a. Naming of the file.
The naming of the file is very crucial and must be exactly as listed in the Kernal Adiutor. Mine was: msm8976-tashalite-snd-card_Button_Jack.kl
Spaces should be replaced with underscores and it does appear to be case sensitive.
b. Contents of the file.
The file only needs to have 3 lines:
Code:
key 257 MEDIA_PREVIOUS
key 226 HEADSETHOOK
key 258 MEDIA_NEXT
4. Install the file.
The file needs to be installed at /system/usr/keylayout using a root explorer. For example: ES Explorer, Total Commander. ​
5. Reboot
6. Download Jays Headset Control or Headset Button Controller or any of the other headset controller apps from the Play Store. The app will recognize the MEDIA_PREVIOUS and MEDIA_NEXT and you can give the button presses additional functions, even beyond the functions found in MiUI.
Edit: If you don't want to use a third party app, you can create the file so the top and bottom button control the volume directly.
Code:
key 257 VOLUME_UP
key 226 HEADSETHOOK
key 258 VOLUME_DOWN

scurrvy2020 said:
4. Install the file.
The file needs to be installed at /system/usr/keylayout using a root explorer. For example: ES Explorer, Total Commander. ​
Click to expand...
Click to collapse
and don't forget to check permissions on your .kl file they must be -rw-r--r-- and o root g root

Thank you so much! I searched for hours for a solution to my problem that my Xiaomi headset control buttons do not function properly on my Mi Max device running Lineage OS until I found this. This really rescued me out of great disappointment as I use the headset alot and Lineage OS is really nice that apart from the problem mentioned above that really upsets me . I don't know it is the OS or my headset that is the problem but it is fixed now. Btw the the second post about setting the permissions is crucial as well, I tried 2 times not realizing that I had to do that, and of course it didn't work. Thank you so much guys. I wish you a nice day! :good:

Hi.. I follow your steps but still I failed to recognize my headset button on my Mi Max running RR rom N.
And I would like to ask you about your 2nd post
"and don't forget to check permissions on your .kl file they must be -rw-r--r-- and o root g root"
Can you please explain this on an easy way. Thanks

enzy29 said:
Hi.. I follow your steps but still I failed to recognize my headset button on my Mi Max running RR rom N.
And I would like to ask you about your 2nd post
"and don't forget to check permissions on your .kl file they must be -rw-r--r-- and o root g root"
Can you please explain this on an easy way. Thanks
Click to expand...
Click to collapse
Ok i used for this ES File Explorer
i.imgur.com/3POnumx.png (can't post image now)

I'm Mi Max 2 user and tried to use this method on it. I tried with HavocOS 2.4 and HavocOS 2.9 unofficial. It doesn't work. Keytest recognizes vol up and down buttons when I press them (code for vol up and down is 114 and 115 respectively), but after creating file nothing happens. Permissions for file are correct. File created in Solid Explorer. What can be the solution? What I'm doing wrong?

Related

Unlock phone with optical joystick?

After searching I discovered this thread:
h t t p: / /forum.xda-developers.com/showthread.php?t=703539
What would need to be done to port this to the Incredible? I'd really like to be able to unlock the phone with the optical joystick (without using a 3rd party app, they don't work consistently).
Thanks for any info.
i would also love this feature in a rom if possible
We had the same idea i just started a thread on the same subject i'll delete mine if i get an answer. I believe I can get this to work I just don't know where to locate the keypad file on the incredible.
The keypad.kl file or are you talking about something else? I tried modifying the keypad.kl file but that doesn't do it.
I was talking about the keypad file i'm trying to edit it also right now.
It won't work. I was able to edit the file and get the settings to stick but my understanding is that file is for physical keyboards. I read somewhere (can't remember where) that it would need to be a kernel update to enable this setting.
well i can verify that editing the keypad file doesn't work. this was my first attempt at editing a file myself i got really excited when I found that other post about remapping the keypad because i hate using the power button. it was fun trying
Did you guys push the file over when you were in your phone or in recovery, if you did it when you are in the phone, nothing will stick.
I did it in recovery, before we even had unrevoked2 tool. I did this: renamed the original file and used cat /sdcard/incrediblec-keypad.kl > /system/usr/keylayout/incrediblec-keypad.kl to create the edited file in the correct directory. The changes stick after a reboot but hitting the joystick doesn't wake the phone.
The joystick seems to be controlled by a kernel setting, not this file.
I'd love to be able to do this, because the front buttons are much more accessible than the power button.
My change definitely took because the power button wouldn't work after I edited the file so I had to revert back to original file.
Wouldn't it be possible to have the power button work normally but also assign the wake function to the optical button as well?
Yes but it would require a kernel setting change. I have no clue how to modify kernels.

Trying to change menu button to app switcher (Hyperdrive)q

I'm running the hyperdrive rom and would like to change the menu button to the recent apps button, and the longpress home to google now like S5. I found an xposed module that does this but only for the note 3. Anyone have a solution for this?
Jaydawgx7 said:
I'm running the hyperdrive rom and would like to change the menu button to the recent apps button, and the longpress home to google now like S5. I found an xposed module that does this but only for the note 3. Anyone have a solution for this?
Click to expand...
Click to collapse
I can change the menu key to recent apps but not sure about longpress home.
Using a root File Explorer open generic.kl in system/user/keylayout with a text editor.
Go to key 139 and replace 'MENU' with 'APP_SWITCH'. Reboot and you're done.
For google now it should just be a matter of finding the appropriate key.
marxses said:
I can change the menu key to recent apps but not sure about longpress home.
Using a root File Explorer open generic.kl in system/user/keylayout with a text editor.
Go to key 139 and replace 'MENU' with 'APP_SWITCH'. Reboot and you're done.
For google now it should just be a matter of finding the appropriate key.
Click to expand...
Click to collapse
Thanks for getting me in the right direction here. However, when I alter the generic.kl file at all, both capacitive buttons quit working after a reboot. I tried replacing the altered file with a backup i made, rebooted, and they still don't work. The only way to restore function of the buttons is to reflash the rom. Any idea as to why? This seemed like an easy change.... (also tried editing the file via notepad++ on the pc with the same result)
Jaydawgx7 said:
Thanks for getting me in the right direction here. However, when I alter the generic.kl file at all, both capacitive buttons quit working after a reboot. I tried replacing the altered file with a backup i made, rebooted, and they still don't work. The only way to restore function of the buttons is to reflash the rom. Any idea as to why? This seemed like an easy change.... (also tried editing the file via notepad++ on the pc with the same result)
Click to expand...
Click to collapse
What file explorer are you using? ES explorer?
After editing and especially if you're pasting in a back up you need to make sure the files permissions are set to rw-r--r--
I personally used the text editor from Rom Tool Box Lite . Make sure there aren't any extra spaces and there should be no # in front of the key.
I just remapped and put them back to normal a few times and I'm not having any problems.
Let me know how you get on.
marxses said:
What file explorer are you using? ES explorer?
After editing and especially if you're pasting in a back up you need to make sure the files permissions are set to rw-r--r--
I personally used the text editor from Rom Tool Box Lite . Make sure there aren't any extra spaces and there should be no # in front of the key.
I just remapped and put them back to normal a few times and I'm not having any problems.
Let me know how you get on.
Click to expand...
Click to collapse
Thanks! I was using ES file Explorer... I don't know what happened amongst text editors, but the rom tool box text editor did the trick... I appreciate your time and patience. Now it's time to figure out how to change long press home to Google now... Thanks again
Jaydawgx7 said:
Thanks! I was using ES file Explorer... I don't know what happened amongst text editors, but the rom tool box text editor did the trick... I appreciate your time and patience. Now it's time to figure out how to change long press home to Google now... Thanks again
Click to expand...
Click to collapse
All good, glad you got it sorted.
Another option is home2shortcut it uses double tap instead of long press, just tried it for kicks and it works really well, quite snappy

[GUIDE][ROOT] Swap Menu and Back capacitive keys

I post this little guide to help those who - like me - prefer a "Nexus-like" experience while keep using the capacitive buttons.
- 1 - Turn off capacitive buttons backlight
1a) using your preferred root file manager go to /sys/class/leds/button-backlight/brightness
1b) edit the file "brightness" and set the text to "0", save and exit
1c) edit the file "max_brightness" and set the text to "0", save and exit
- 2 - Swap buttons functions
2a) using your preferred root file manager go to /system/usr/keylayout
2b) open for editing the file "Generic.kl"
2c) find the string "key 139 MENU" and replace with "key 139 BACK"
2d) find the string "key 158 BACK" and replace with "key 158 MENU", save and exit
2e) reboot
Credits:
This page turning off the backlight.
This page for swapping keys funcions.
Added to OnePlus One index thread:
[INDEX] OnePlus One Resources Compilation Roll-Up
Transmitted via Bacon
Thank you sure makes it easier on us lefties
64 pieces of bacon yummy?
If you turn off capacitive buttons backlight, wouldn't be difficult to press them since they are quite small?
i do this since i changed my n4 for an OPO and preferred to stick on the nexus keys layout
the drawback is that if you remove the capacitive menu key you don't have access to menu on chrome and other apps that don't show overflow (3 dots) menu buttons
here is the thread where i asked about infos but nobody helped so far
http://forum.xda-developers.com/oneplus-one/help/force-app-overflow-3-dots-menu-to-appear-t3003731
and here below there's 3 flashable zip files for CM12 with the following setup:
nexus-like keys (back-home-recents)
inverted keys (back-home-menu)
stock keys (menu-home-back)
if you use CM12, my advise is to use the "inverted" one and remap "menu" to "recents" from Cyanogenmod button settings, so you can also set up "menu" option if longpress or double tap
AH thanks alot OP really needed this
etoy said:
i do this since i changed my n4 for an OPO and preferred to stick on the nexus keys layout
the drawback is that if you remove the capacitive menu key you don't have access to menu on chrome and other apps that don't show overflow (3 dots) menu buttons
here is the thread where i asked about infos but nobody helped so far
http://forum.xda-developers.com/oneplus-one/help/force-app-overflow-3-dots-menu-to-appear-t3003731
and here below there's 3 flashable zip files with the following setup:
nexus-like keys (back-home-recents)
inverted keys (back-home-menu)
stock keys (menu-home-back)
Click to expand...
Click to collapse
I flashed the nexus- like keys zip inside of TWRP recovery, and now NONE of my capacitive or physical buttons are working. How do I fix it?
Kevlang said:
I flashed the nexus- like keys zip inside of TWRP recovery, and now NONE of my capacitive or physical buttons are working. How do I fix it?
Click to expand...
Click to collapse
what ROM are you using? the ones i posted are for CM12
here's attached a "revert to stock" zip for CM11S
etoy said:
what ROM are you using? the ones i posted are for CM12
here's attached a "revert to stock" zip for CM11S
Click to expand...
Click to collapse
Thanks, i was running 11s. Not to worry though, I decided that was an opportune time to flash CM12, and problem solved.
To clarify, those original 3 zips should be safe to use now that I'm running CM12?
Do i just flash using TWRP?
Kevlang said:
Thanks, i was running 11s. Not to worry though, I decided that was an opportune time to flash CM12, and problem solved.
To clarify, those original 3 zips should be safe to use now that I'm running CM12?
Do i just flash using TWRP?
Click to expand...
Click to collapse
i personally use CM12 and flash the "inverted" one myself with TWRP 2.8.4.1 everyday when i update nightlies.
just compared my Generic.kl stock file with the one on latest 0121 nightly and they're identical so yes, i guarantee it's safe to flash them
Giocarro said:
- 1 - Turn off capacitive buttons backlight
1a) using your preferred root file manager go to /sys/class/leds/button-backlight/brightness
1b) edit the file "brightness" and set the text to "0", save and exit
1c) edit the file "max_brightness" and set the text to "0", save and exit
.
Click to expand...
Click to collapse
There is the option under settings / buttons on CM12
etoy said:
i do this since i changed my n4 for an OPO and preferred to stick on the nexus keys layout
the drawback is that if you remove the capacitive menu key you don't have access to menu on chrome and other apps that don't show overflow (3 dots) menu buttons
here is the thread where i asked about infos but nobody helped so far
http://forum.xda-developers.com/oneplus-one/help/force-app-overflow-3-dots-menu-to-appear-t3003731
and here below there's 3 flashable zip files for CM12 with the following setup:
nexus-like keys (back-home-recents)
inverted keys (back-home-menu)
stock keys (menu-home-back)
if you use CM12, my advise is to use the "inverted" one and remap "menu" to "recents" from Cyanogenmod button settings, so you can also set up "menu" option if longpress or double tap
Click to expand...
Click to collapse
Can I apply one of your zip to oxygenos?
Paninno12 said:
Can I apply one of your zip to oxygenos?
Click to expand...
Click to collapse
to be honest, i don't know if the origin file is the same.
you should compare the file from my "revert" zip and yours, it's located in
/system/usr/keylayout/Generic.kl
if they are identical, then you can proceed.
if not, you can send it to me and i'll prepare a zip for O²
Paninno12 said:
Can I apply one of your zip to oxygenos?
Click to expand...
Click to collapse
i compared the Generic.kl files between O² and CM12, they're identical so you can flash my zip without any worries
etoy said:
i compared the Generic.kl files between O² and CM12, they're identical so you can flash my zip without any worries
Click to expand...
Click to collapse
Working perfectly! Thanks
Works on marshmallow as well, in case anyone wondered.
etoy said:
i do this since i changed my n4 for an OPO and preferred to stick on the nexus keys layout
the drawback is that if you remove the capacitive menu key you don't have access to menu on chrome and other apps that don't show overflow (3 dots) menu buttons
here is the thread where i asked about infos but nobody helped so far
http://forum.xda-developers.com/oneplus-one/help/force-app-overflow-3-dots-menu-to-appear-t3003731
and here below there's 3 flashable zip files for CM12 with the following setup:
nexus-like keys (back-home-recents)
inverted keys (back-home-menu)
stock keys (menu-home-back)
if you use CM12, my advise is to use the "inverted" one and remap "menu" to "recents" from Cyanogenmod button settings, so you can also set up "menu" option if longpress or double tap
Click to expand...
Click to collapse
Thanks, Inverted working great on Bliss Pop.
Suppose to : long press [Home] key, open recent menu...
So how I can change it to long press [Menu] key to open recent menu?!
Thanks, one of the experiences I'm missing from Nexus devices
Hi,
can anyone tell me how it is to be done on Oneplus X with CM 12.1.
I am able to configure Menu and Home buttons via settings, but I cannot swap location or configure Back button.
Editing Generic.kl did not work, I think it might be overridden by the cyanogen mod settings?
thanks
freaksworth

MOD Boost Volume Headphones Z1 Compact D5503 14.6.A.1.236 (Required Root)

MOD Boost Volume Headphones Z1 Compact D5503 14.6.A.1.236 (Required Root)
1 - Check Root Device!
2 - Download ES File Explorer (Google Play)
3 - Open ES File Explorer and accept permissions Root.
4 - Open Tools and mark Root Explorer.
5 - Come Back Local, and / Device next Open System after etc
6 - Paste file mixer_paths.xml (include link end post) and Replace existing File. (if you do not understand look at the attached images in the post.)
7 - Restart your Device
8 - Finish!
if by chance, your phone is muted after restart, follow These steps.
Open ES File Explorer, browse by location> / Device> System> etc and select mixer_paths.xml on file, go to properties, rw-rw-rw Then permissions and click change and tick all the boxes in Read and Write click ok and restart your device.
to better understand, look at the steps in the last images attached in the post.
DOWNLOAD MOD > https://mega.nz/#!5hkCVLBb!bJZqhuukE8SAX1uWGggHY0vBkPA2yw7zWPXGKaBzjpo
Thanks hicked for your work on this mod.
I followed the instructions but used Root Browser instead of ES Browser. (I don't know if this made a difference)
After the restart audio failed to work on the internal speaker or on earphones. It gave me an "audio stopped" mesaage
I accessed mixer_paths.XML through Root Browser and changed the permissions to the same as in my attached image. After another reboot audio worked again, and was noticibly louder through the earphones. Also tested on my Bluetooth speaker and on my Bluetooth headphones and they seem to be louder now too.
Great work!
Sent from my KFFOWI using XDA Free mobile app
reboot after no sound :/ please help
-TsT- said:
reboot after no sound :/ please help
Click to expand...
Click to collapse
did you change permissions ?
-TsT- said:
reboot after no sound :/ please help
Click to expand...
Click to collapse
if by chance, your phone is muted after restart, follow These steps.
Open ES File Explorer, browse by location> / Device> System> etc and select mixer_paths.xml on file, go to properties, rw-rw-rw Then permissions and click change and tick all the boxes in Read and Write click ok and restart your device.
to better understand, look at the steps in the last images attached in the post.
I think it's too loud. Sound is distorted in max volume.
Thanks for this.
But I can't install it.
I am having android 4.4.4. My phone is rooted but I dont remember if I installed custom rom o not lol.
I love my z1 compact and it still working perfectly, I bought it in 2014 in Germany, I rooted it my self and never updated it for fear of bugs and problems with the battery.
My only problem whit the phone was that the sound is quite low, so I would like to try this. But I cant paste the file into the system/etc.
I think its because I dont have the privilege to rewrite the files in the system folder. I can activate the root explorer in the Es file explorer but wont let me change the r/w mount. When I check the read and write option nothing happens. Press accept, open it again and its still on read option... I tried with other explorers too without success.
Could it be because the super su isnt updated? When I open super su a message appears saying that the binaries arent updated. When I try to update it fails...
Thanks for your time and advice.
Finally I can use HyperX Cloud 2 with my Z1 Compact! With original file my phone don't have enough power to power them.Thank you so much man!

[How-To] REMAP CAPACITIVE BUTTONS ON GALAXY S6 [ROOT]

HOW TO REMAP CAPACITIVE BUTTONS ON GALAXY S6​
If you're left handed like me, then you might wanna remap your capacitive buttons if you use the back key more often than the multitask button.
You can remap many other buttons such as volume keys and the power button, just use some logic and you'll figure it out.
As we progress on, you'll realize that there are many more things you can remap other than the physical buttons.
!!!DISCLAIMER!!!
I'm not responsible if this doesn't work for you!
I'm not responsible if your capacitive buttons don't work!
!!!DISCLAIMER!!!
1. You'll need root access for this, otherwise it won't let you edit the file
2. Go to Play Store and download the app called Total Commander (you can use any other file manager that supports root, but this one worked best for me)
3. Open the app, and go to File system root
4. Go to data folder and when it asks you, grant it the permissions
5. Go back and go to the system folder, then to the usr folder and then to the keylayout folder
6. Long press on the Generic.kl file and click on Open as, then on Text and then select Totalcmd Editor
7. Now click on the magnifying glass icon without an arrow in the top right corner
8. Search for the word BACK, but select the Whole Words checkbox
9. Change it to APP_SWITCH (make sure it's capitalized!)
10. Search again for the word MENU and change it to BACK (there may be two MENU words in the file so search twice)
11. Search for the word APP_SWITCH and change it to BACK
12. Click on the Floppy disk icon on the top of the window and then click OK
13. Exit and close the application
14. Reboot your device and enjoy!​
What do you change the second MENU in the file??
Sent from my SM-G925W8 using XDA-Developers mobile app
thatsupnow said:
What do you change the second MENU in the file??
Sent from my SM-G925W8 using XDA-Developers mobile app
Click to expand...
Click to collapse
Change both MENU words to BACK.
thatsupnow said:
What do you change the second MENU in the file??
Sent from my SM-G925W8 using XDA-Developers mobile app
Click to expand...
Click to collapse
Oh, and I see that you may be using CM, I'm not, so I'm not pretty sure if the files are same. I used stock ROM on my Galaxy S6, but I'm pretty sure any other ROM would work, as long as you have the S4 or S5 or S6 or even S7 and the latest version.

Categories

Resources