I am using an AT&T Tilt2 with stock ROM. I am not being able to get a key on the hardware keyboard to remap to CTRL.
I have tried manually editing the eT9.Rhodium.Cingular_US.kmap.txt file (using 0x11 for the value). I have also tried using the Rhodium Keyboard Controller. Neither seem to do the trick. The key I remap (tried OK, home, and several others) stops doing the original function. Instead of what I would expect for CTRL it just does nothing.
For now I have mapped fn-C -> CTRL-C and such, but I would like to get a key to actually map to CTRL.
Any ideas on how to get this to work?
I agree.
Bump for more interest please.
Anyway to add CTRL to the stock SIP touch keyboards too?
I miss my Ctrl-A (select all) / Ctrl-C (copy) / Ctrl-V (paste) amongst other common keyboard commands too!
~J
im afraid you will have to flash custom rom to enable ctrl remapping
For the kmap bit did you use the 0x11 as the second value? IE did you change it to something like:
{0xEC 0x11 0x00 0x00 0x00 0x00} //example for the FN key remap.
Also make sure to use something like Notepad to modify the file. It needs to be saved as unicode.
Some custom ROMs, which are not based on HTC roms, but compiled form Android Source support the Bluetooth HID profile, thus support well known and common normal Bluetooth keyboards.
I've tested Cyanogenmod and OpenDesire.
However, I was unsatisfied with the keyboard layout. I've found no key for return, needed some special 'Umlaute' for my German layout, etc.
Here's what I've found to fix all this:
1. Description what can be changed:
Android Open Source Project: Keymaps and Keyboard Input
Until now I don't know the internal differences between the key map and character map files. Sure, both look different, both can and must be changed for different reasons. The key map if you want to change actions and also alter phone buttons, the character map for modifying the full layout. But with the key map you could also alter parts of the layout, so it's not that clear for me. However.
2. Altering Key Map Layout
If you don't specify a keylayout file, Android will default to /system/usr/keylayout/qwerty.kl
Click to expand...
Click to collapse
So I took a look at this file, changed it, and it worked
Here a nice explanation of this file, explained are the different commands, too.
[GUIDE] How to Remap Hardkey Actions || Custom App Launching
What we not know, the key number of our physical BT keyboard, so what's the number of ESC? For this, I've found following site, which seems to contain the correct scan codes, used in Android: (note, the values are in HEX!!)
http://www.marjorie.de/ps2/scancode-set1.htm
So if we take a look at ESC:
Key: ESC Make: 01 --> in decimal, stays 01
We just have to add following line to the key map layout file:
key 1 BACK WAKE_DROPPED
and we have a back key.
3. Altering Character Map file
To change characters and change the whole layout, it seems as if we have to alter the character Map file. (/system/usr/keychar/qwerty.kcm.bin)
Sadly, this fact makes editing the file somehow difficult:
Resource Binary File Format
The file snippet above [see first link] gets converted to the following [a binary file] by the makekcharmap tool as part of the build process.
Click to expand...
Click to collapse
I have no idea what this tool is, nor how to revert it back, so we have to edit the binary file. Luckily, one user's done the hard work already, again:
Changing to a non-english keyboard layout [cupcake support]
The easiest method is to use some kind of hexeditor, so you see what you do and can enter the character code of special characters easily, I used the one in Notepad++
Then you can alter the layout just as you like. Because I have a special english keyboard with which I want to type german Umlaute, too, I changed
A.2.a.A.#..
to
A.2.a.A.ä.Ä.
So I can type an 'ä' by holding the 'Alt' key and pressing a. Typing 'Ä' by holding Shift+Alt and typing 'a'.
Unlimited possibilities
Tips:
To alter both files you can use ADB and an editor on your computer.
Or you can alter the files directly on the phone, without any additional hardware. You only need Root Explorer to open, change and save the files directly on the phone.
Drawbacks of changing the layout:
Haven't seen some yet
Use as your own risk! a wrong keylayout may totally disable the input device. Tested on Shield TV 2017 16GB
If you are using 3rd party remote on Shield TV some key may not work as intent, or you want to remap the key for another function, for example I had a xiaomi remote (just $4 dollar) which the home key not working.
Although you use custom IME (such as mkr Multilanguage Keymap Redefiner) or some keyboard remap app (such as buttons remapper), which work but not perfect, some function may not work such as double press the home button to show recent app list, or conflict with shield tv controller button (buttons remapper disable the voice search button on my shield controller), and you may need to change every time for each different remote/controller.
Luckly android allow you to use specific key layout for each different remote.
1. flash the developer image, which is pre-rooted, or root it yourself
2. adb shell
3. cat /proc/bus/input/devices
Now you will have a list of connected remote/controller, take a note of the Vendor number and the Product number4. adb pull /system/usr/keylayout
5a. modify a exist keylayout file, or create a new one. The file name should be Vendor_XXXX_Product_XXXX.kl, Don't change the Generic.kl
5b. use any keytest app to check the key scancode, I am using "Multilanguage Keymap Redefiner"
for example my xiaomi remote home key scancode is "102", which map to MOVE_HOME by default, so I create a new file "Vendor_2717_Product_3200.kl", the file will be like this:key 28 DPAD_CENTER
key 102 HOME
key 103 DPAD_UP
key 105 DPAD_LEFT
key 106 DPAD_RIGHT
key 108 DPAD_DOWN
key 114 VOLUME_DOWN
key 115 VOLUME_UP
key 116 POWER
key 127 MENU
key 158 BACK
Any key not listed will be disable, so make sure you have all key listed
6. copy the file back to shield tv:
adb root
adb disable-verity
adb reboot
adb root
adb remount
adb push "layout file" /system/usr/keylayout7. reboot.
P.S. Don't change the Generic.kl, change the keylayout file one at each time
Shield TV remote Home button is map to HOME, and the dpad center is map to DPAD_CENTER, so other remote which map to MOVE_HOME and ENTER (such as my xiaomi remote) will need this mod
The shield TV come with lot of keylayout file for many different controller/remote, I see MI, wii,xbox 360, but there seems no amazon
I had attach the keylayout file pull from my sheild tv, may be you can take a look which controller/remote is support offically
I cant do adb remount, it says I have to be root, and when I do adb root first it seems to pass but it still says I have to be root when i try adb remount.
How do I set my /system to r/w instead of r/o? I have tried adb mount o rw,remount /system but it wont do anything.. also the command you tell me to use, "adb disable-verity" says:
disable-verity only works for userdebug builds
Can you please help me?
Kylistar said:
I cant do adb remount, it says I have to be root, and when I do adb root first it seems to pass but it still says I have to be root when i try adb remount.
How do I set my /system to r/w instead of r/o? I have tried adb mount o rw,remount /system but it wont do anything.. also the command you tell me to use, "adb disable-verity" says:
disable-verity only works for userdebug builds
Can you please help me?
Click to expand...
Click to collapse
you need to root it yourself or using the developer firmware in here:
https://developer.nvidia.com/gameworksdownload#?search=SHIELD
note that future OTA may fail because it will send you normal firmware even you are on developer firmware
DummyPLUG said:
you need to root it yourself or using the developer firmware in here:
note that future OTA may fail because it will send you normal firmware even you are on developer firmware
Click to expand...
Click to collapse
I did root my nvidia shield. It is supposed to be rooted, I got super user(superSU) installed on it and Everything..
Kylistar said:
I did root my nvidia shield. It is supposed to be rooted, I got super user(superSU) installed on it and Everything..
Click to expand...
Click to collapse
you mean mount -o remount,rw /system didn't work? but I suppose it can't as verity will prevent it, I hear SU in 7.0 will disable verity but I didn't try it before, sorry about this.
DummyPLUG said:
you mean mount -o remount,rw /system didn't work? but I suppose it can't as verity will prevent it, I hear SU in 7.0 will disable verity but I didn't try it before, sorry about this.
Click to expand...
Click to collapse
I actually got the kl file into the system/usr/keylayout directory now, using TWRP
with these steps:
Reboot to Bootloader
Type “adb reboot bootloader” and hit enter. The Shield TV should reboot into the bootloader screen.
Fastboot with TWRP
Type “fastboot devices” and make sure your Shield TV is visible.
If your Shield TV is listed, type “fastboot boot twrprecovery.img”
in the TWRP i can chose mount and check system, then i was able to move the .kl file from the sdcard to the keylayout directory, still my nvidia shield doesnt give it the new settings.. its given the same configuration as my nvidia controllers. I have double checked that Vendor nr and Product nr is the same as the controllers.
here's my .kl file:
# ps4
key 304 BUTTON_X
key 305 BUTTON_A
key 306 BUTTON_B
key 307 BUTTON_Y
key 308 BUTTON_L1
key 309 BUTTON_R1
key 310 BUTTON_L2
key 311 BUTTON_R2
key 312 BACK
key 313 HOME
key 314 BUTTON_THUMBL
key 315 BUTTON_THUMBR
key 316 BUTTON_START
looks correct?
Thanks for your time!
Kylistar said:
I actually got the kl file into the system/usr/keylayout directory now, using TWRP
with these steps:
Reboot to Bootloader
Type “adb reboot bootloader” and hit enter. The Shield TV should reboot into the bootloader screen.
Fastboot with TWRP
Type “fastboot devices” and make sure your Shield TV is visible.
If your Shield TV is listed, type “fastboot boot twrprecovery.img”
in the TWRP i can chose mount and check system, then i was able to move the .kl file from the sdcard to the keylayout directory, still my nvidia shield doesnt give it the new settings.. its given the same configuration as my nvidia controllers. I have double checked that Vendor nr and Product nr is the same as the controllers.
here's my .kl file:
# ps4
key 304 BUTTON_X
key 305 BUTTON_A
key 306 BUTTON_B
key 307 BUTTON_Y
key 308 BUTTON_L1
key 309 BUTTON_R1
key 310 BUTTON_L2
key 311 BUTTON_R2
key 312 BACK
key 313 HOME
key 314 BUTTON_THUMBL
key 315 BUTTON_THUMBR
key 316 BUTTON_START
looks correct?
Thanks for your time!
Click to expand...
Click to collapse
Yes TWRP can write into system, but last time when I try it trigger the verity protection sometime, don't investigate it though as I am lazy and just use the developer build since then. (another reason I semi brick my shield a few time with twrp)
the.kl looks correct, to see what is the problem try remove one of those key from the .kl, if shield load the file correctly that key should be disable, if not then the .kl file is not work.
I can't remember if the file need to be in unix EOL style or not, that means if you edit it in windows notepad it may not work, try notepad++ or pspad. (I may mix up with bt_config.conf, which I use to maually pair my xiaomi remote)
DummyPLUG said:
Yes TWRP can write into system, but last time when I try it trigger the verity protection sometime, don't investigate it though as I am lazy and just use the developer build since then. (another reason I semi brick my shield a few time with twrp)
the.kl looks correct, to see what is the problem try remove one of those key from the .kl, if shield load the file correctly that key should be disable, if not then the .kl file is not work.
I can't remember if the file need to be in unix EOL style or not, that means if you edit it in windows notepad it may not work, try notepad++ or pspad. (I may mix up with bt_config.conf, which I use to maually pair my xiaomi remote)
Click to expand...
Click to collapse
It looks like my shield wont recognize the files im putting in there, I tried replacing the Generic file with a modified one, after that the ps4 controller wont work at all, Before it just had the wrong buttons, then i tried changing back to the original file and the shield wont read it.
This should mean the reason my new .kl file for the ps4 controller wasnt recognized because of this.
Any idea what I do now? How do I get it to recognize the files? How do I get at least the generic back if that is not possible?
And yes, I do use pspad.
Kylistar said:
It looks like my shield wont recognize the files im putting in there, I tried replacing the Generic file with a modified one, after that the ps4 controller wont work at all, Before it just had the wrong buttons, then i tried changing back to the original file and the shield wont read it.
This should mean the reason my new .kl file for the ps4 controller wasnt recognized because of this.
Any idea what I do now? How do I get it to recognize the files? How do I get at least the generic back if that is not possible?
And yes, I do use pspad.
Click to expand...
Click to collapse
If you replace the generic file and it didn't work this mean the file is something wrong, the first thing I come in my mind is the file still using windows (CRLF) not Unix (LF), but as you said even you copy the original .kl back to shield it still didn't work then may be the dm-verity kick in
if it is dm-verity kick in the best and easiest way to recovey is flash the firmware again, as it is hard to modify the current system block to have the same hash as original one
I am having the same issue as above. My Shield doesn't recognize the changes made to the .kl file I edited.
I have a rooted Shield running on the latest Shield software 7.0.2 and a Fire TV Stick Remote connected.
I used cat /proc/bus/input/devices to see the remote uses vendor 1949 product 0404 key layout.
I went to system/usr/keylayouts, navigated to that kl file and then modified the 2 keys I wanted to change. Rewind and fast forward. I changed them to VOL_DOWN and VOL_UP.
I saved the changes and rebooted.
However they still act as MEDIA_REWIND and MEDIA_FAST_FORWARD.
I have verified the changes are still showing in the key layout file. I don't understand why it's not working.
The last time I rooted my Shield, I was using another Fire TV remote (the Alexa Voice Remote), which uses 1949 0407.kl file.
I modified that one to make the same changes and it worked. I could control the volume.
Since then though, I've factory reset the Shield am rooted onced again and this time I am using this fire tv stick remote, but can't seem to get the changes to the key layout file to actually take affect and I don't understand why it's not working. What is different than when I modified the other remote? Makes no sense.
EDIT: Ok so I figured it out basically right after making this post. I was trying to use VOL_UP and VOL_DOWN, which I could have sworn was the correct key code and what I used with my other Fire TV remote before I factory reset. However I tried again, this time though using VOLUME_UP and VOLUME_DOWN and it worked properly.
Damn, I'm dumb. Now it's working exactly how I wanted it to.
I am guessing by using the wrong key code, thus rendering it useless, it was falling back to the key code used for the same key ID in the generic.kl file?
thanks, i will try
How do we know the vendor number for external remote? I tried on android box and there is no system under /proc
how do i set the proper chmod when running the push command to put the file onto the device?
Thanks for this, but I am trying to use Mi remote with voice control
Everything works except the Google assistant button, it brings up assistant but doesn't detect any voice from remote.
Can something similar be done with an IR remote?
I'd love to have more buttons that I could use for all kinds of automations.
Thanks!
How to open app using this method? Suppose I want to open google chrome, how would I do that? @DummyPLUG
it seems that while adding non-remappable assistant buttons is a growing trend, solutions aren't easy to find, however the solution is real simple, you just have to modify the keymap file...
I successfully managed to get the button detected by flashing XperiaGAButtonRemap through magisk, and I'm pretty sure the same solution works for a bunch of other phones also, it even has code that should allow flashing through custom recoveries also.
all you have to do is "install from storage" in magisk manager, select the zip, and reboot.
what that zip does, is it adds /system/vendor/usr/keylayout/gpio-keys.kl (overriding /system/usr/keylayout/gpio-keys.kl because /vendor has higher priority) and replaces the ASSISTANT key with PROG_BLUE, which is a dummy key, you can remap that with any remapper app or module, or you could edit the zip, and change it directly to something like CAMERA, if that's all you want.
here's what the file will look afterwards, if you're curious:
key 115 VOLUME_UP
key 114 VOLUME_DOWN
key 102 HOME
key 528 FOCUS
key 766 CAMERA
key 457 PROG_BLUE
the original file has copyright notice for The Linux Foundation, from 2013, but all other keys map the same, so it's highly likely most phones (at least the AOSP-adjacent ones) just have hooks for the ASSISTANT key, but still rely on the universal keymap file
thanks a lot!worked just fine,
big ups!!!
Hello, sorry for the question, does this work on Android 12?
SHANOA_zasha said:
Hello, sorry for the question, does this work on Android 12?
Click to expand...
Click to collapse
I've just tested and yes it works in A12