Fix Fire TV Remote D-pad Center Button on Raspberry Pi 5 Android TV

1. Environment

  • Device: Raspberry Pi 5
  • OS: KonstaKANG LineageOS 24.0 Android TV
  • Android version: Android 17
  • ADB address: 192.168.0.235:5555
  • Remote: Fire TV remote
  • Problem: Pressing the remote’s D-pad Center/Select button in the SmartTube search field did not behave as expected.

2. Identify the remote’s key mapping

Connect to the Android TV using ADB from the Mac:

adb connect 192.168.0.235:5555

Confirm the connected device:

adb devices

The remote appeared as AR Keyboard, with these identifiers:

  • Vendor ID: 0171
  • Product ID: 041e

The center button generated this Linux input event:

EV_MSC MSC_SCAN 00070058
EV_KEY KEY_KPENTER DOWN
EV_KEY KEY_KPENTER UP

KEY_KPENTER corresponds to Linux keycode 96. The Android key layout mapped that keycode to NUMPAD_ENTER, whereas we needed DPAD_CENTER.

3. Confirm the active key layout

Run:

adb -s 192.168.0.235:5555 shell dumpsys input

Find the remote’s entry. It showed:

Name: "AR Keyboard"
KeyLayoutFile: /vendor/usr/keylayout/Generic.kl

This confirmed that Android was using the vendor’s Generic.kl file for the remote.

4. Enable root access and remount system partitions

Run these commands:

adb -s 192.168.0.235:5555 root
adb -s 192.168.0.235:5555 remount

Expected results included messages such as:

adbd is already running as root
Remount succeeded

The exact remount messages may vary.

5. Back up the original key layout

Do not skip the backup.

adb -s 192.168.0.235:5555 shell cp /vendor/usr/keylayout/Generic.kl /vendor/usr/keylayout/Generic.kl.bak

This preserves the original file so the change can be reversed.

6. Change keycode 96 to DPAD_CENTER

Run:

adb -s 192.168.0.235:5555 shell "sed -i 's/^key 96    NUMPAD_ENTER$/key 96    DPAD_CENTER/' /vendor/usr/keylayout/Generic.kl"

This replaces the existing mapping:

key 96    NUMPAD_ENTER

with:

key 96    DPAD_CENTER

Verify the change:

adb -s 192.168.0.235:5555 shell "grep -n 'key 96' /vendor/usr/keylayout/Generic.kl"

Confirm that the output shows:

key 96    DPAD_CENTER

7. Reboot Android TV

adb -s 192.168.0.235:5555 reboot

Wait for Android TV to restart, reconnect ADB if needed, and test the remote.

8. Test the result

Open SmartTube, navigate to the search field, and press the Fire TV remote’s D-pad Center/Select button.

Result: The button worked as expected after changing the keycode mapping and rebooting.

9. Restore the original mapping if needed

This modification changes the vendor’s generic key layout, so other input devices that use Generic.kl may also be affected. If you notice unwanted keypad behavior, restore the backup:

adb -s 192.168.0.235:5555 root
adb -s 192.168.0.235:5555 remount
adb -s 192.168.0.235:5555 shell cp /vendor/usr/keylayout/Generic.kl.bak /vendor/usr/keylayout/Generic.kl
adb -s 192.168.0.235:5555 reboot

Important notes

  • The working change was made to /vendor/usr/keylayout/Generic.kl.
  • We also created device-specific files named Vendor_0171_Product_041e.kl in the vendor and system keylayout directories, but Android continued to report that it was using Generic.kl. Those device-specific files were not what ultimately fixed the issue.
  • The change maps keypad Enter (keycode 96) to DPAD_CENTER for any device using this generic layout, not just the Fire TV remote.
  • If repeating this on another LineageOS build, first inspect the active key layout and its existing keycode 96 mapping. Paths and mappings can differ between builds.

Leave a Reply

Your email address will not be published. Required fields are marked *