Change 3rd party remote key layout (root require)

Search This thread

DummyPLUG

Senior Member
Dec 18, 2007
517
120
Hong Kong
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 number​
4. 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/keylayout​
7. 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​
 

Attachments

  • keylayout.zip
    60.9 KB · Views: 484
Last edited:
  • Like
Reactions: iaminfa

Kylistar

Member
Jan 4, 2018
6
0
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?
 
Last edited:

DummyPLUG

Senior Member
Dec 18, 2007
517
120
Hong Kong
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?

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
 
  • Like
Reactions: Kylistar

Kylistar

Member
Jan 4, 2018
6
0
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


I did root my nvidia shield. It is supposed to be rooted, I got super user(superSU) installed on it and Everything..
 

Kylistar

Member
Jan 4, 2018
6
0
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.

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!
 
Last edited:

DummyPLUG

Senior Member
Dec 18, 2007
517
120
Hong Kong
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!
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)
 
  • Like
Reactions: Kylistar

Kylistar

Member
Jan 4, 2018
6
0
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)

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.
 

DummyPLUG

Senior Member
Dec 18, 2007
517
120
Hong Kong
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.

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
 
Last edited:

bubbablacksmith

Senior Member
Feb 24, 2017
57
15
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?
 
Last edited:

michau83

Member
Jun 12, 2006
20
1
How do we know the vendor number for external remote? I tried on android box and there is no system under /proc
 

iaminfa

Member
Feb 5, 2020
6
0
how do i set the proper chmod when running the push command to put the file onto the device?
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    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 number​
    4. 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/keylayout​
    7. 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​
    1
    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?

    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
    1
    I did root my nvidia shield. It is supposed to be rooted, I got super user(superSU) installed on it and Everything..

    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.
    1
    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!
    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)