A quick guide on how to remap (app) buttons on Android TV remotes

This guide shows how I did it with the TV that I use. Some steps may not be the same for your TV.
Requirements
Connecting to your TV with ADB
I won't go into details of how to connect to your TV using ADB, so please look up this guide here:

Installing KeyMapper
- Download the KeyMapper APK. (Preferably into the scrcpy folder, so you won't have to enter the path in the next step.)
- Run
adb install <Path to KeyMapper-x.x.x.apk>
. It should show something like "Installed" or "Success". - Now you need to give the app some permissions. Use the following commands:
adb shell settings put secure ENABLED_ACCESSIBILITY_SERVICES io.github.sds100.keymapper/io.github.sds100.keymapper.service.MyAccessibilityService
adb shell pm grant io.github.sds100.keymapper android.permission.WRITE_SECURE_SETTINGS
KeyMapper is now installed!
Setting up KeyMapper
- KeyMapper will probably not appear in the default app list of your Android TV. Go into
settings > apps
and search for KeyMapper. From there you can open the app. - Use scrcpy to see and interact with the screen on your pc. (Just run
scrcpy.exe
while being connected to your TV with ADB.) - KeyMapper will tell you on top something like
The accessability service isn't enabled!
. Just press on theFix
button, the app should then fix it itself. (This is why we've set the permissions.) - The second warning
Your mappings will stop working randomly!
will be there forever, as the app is mainly for Aandroid phones and Samsung, Huawei, Xiaomi and co. add some optimization stuff. At least that's for me, and I can't remove it.
Remapping a key
Keep in mind that you WILL need to do this via scrcpy as you can't do everything with your remote.
- Press the big plus at the bottom of the screen.
- Press
Record trigger
. Then you have 5 seconds to press the button on your remote that you want to remap. - Once the trigger was added, you can go to
Actions
(which is at the top) and pressAdd action
. Here you can select various actions. I usedLaunch app
. There you get a list of apps that you can launch. Sadly, not every app is listed there. - and I don't know why. - When everything is set, you can press
Save
and you're done!