Announcement

Collapse

OUKITEL K6000 Plus Giveaway


You can search for some eggs these days or hide some for your children,
but you won't like to miss the FreakTab Easter Giveaway Action sponsored by EFOX.

Click here to Enter --> https://goo.gl/W6voQw
See more
See less

[ Tutorial ] Redefine any keys of your Android Keybord, Remote Controller, Gamepad to your needs.

Collapse
This is a sticky topic.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [ Tutorial ] Redefine any keys of your Android Keybord, Remote Controller, Gamepad to your needs.

    First of all you can redefine the key of every input device attached and recognized by your Android device. Such input devices like a IR Remote, Bluetooth Keybord and any USB HID (wireless or cable). This means every Keyboard, Remote Controller, Mouse or Gamepad can be modified to your own needs:

    What do you need:
    • Root access to your device
    • Root Explorer (I use ES FIle Explorer)
    • Text Editor (I use the build in editor of ES File Explorer)
    • Terminal
    You can also edit/create your *.kl file on your computer


    Helpfull android tools


    Easy MOD (.kl files)


    General Infos about Android key layout files (.kl)

    Key layout files are located by USB vendor, product (and optionally version) id or by input device name. The following paths are consulted in order:
    • /system/usr/keylayout/Vendor_XXXX_Product_XXXX_Version_XXXX.kl
    • /system/usr/keylayout/Vendor_XXXX_Product_XXXX.kl
    • /system/usr/keylayout/DEVICE_NAME.kl
    • /data/system/devices/keylayout/Vendor_XXXX_Product_XXXX_Version_XXXX.kl
    • /data/system/devices/keylayout/Vendor_XXXX_Product_XXXX.kl
    • /data/system/devices/keylayout/DEVICE_NAME.kl
    • /system/usr/keylayout/Generic.kl
    • /data/system/devices/keylayout/Generic.kl

    When constructing a file path that contains the device name, all characters in the device name other than '0'-'9', 'a'-'z', 'A'-'Z', '-' or '_' are replaced by '_'.

    Source: https://source.android.com/devices/input/key-layout-files.html


    Note: Do not forget to chmod 660 your own created xyz.kl files. Or use ES File Explorer to do so: Mark file (long press) >> More >> Properties >> Permissons [Change] to rw- r- r- = (Read: Owner, Group, Other | Write: Owner)






    List all connected input devices

    Use the following command at a Terminal Emulator or via the Android Debug Bridge (ADB), to find your keyboard in the list and to get the Vendor ID, Product ID, Version ID or Device Name.

    Code:
    cat /proc/bus/input/devices
    A good Android Terminal tool with large font size (to read on a TV screen)
    https://play.google.com/store/apps/d...rminalemulator


    Tipp: You can use also Gamepad tester to do so. Just press the key on the remote you want to mod and it will show you all the needed informations about the Vendor ID, Product ID, Version ID or Device Name at the bottom of the screen.





    Overview of all Android Key Codes

    At the following link you will find a overview of all possible Android key codes, that can be mapped to any ScanCode of your remote control, keybord or game controller in your key layout file.

    Note: When using a the key codes you don't have to use the beginning
    KEYCODE_ at your key layout file.

    Example:
    Code:
    KEYCODE_APP_SWITCH = APP_SWITCH


    List of all key codes >> http://developer.android.com/reference/android/view/KeyEvent.html





    Test your Keys and find the ScanCode

    To check the already set ScanCode of any key, you can use Multilanguage Keymap Redefiner (MKR) or
    Gamepad tester. (see pictures for more details)

    With Gamepad tester you can also create your device own *.kl dummy file for any keyboard or remote controller, straight saved to the right folder. And for sure, this file must be enhanced manually to your needs. But for a Gamepad it can create already the final *.kl file for your Gamepad, so you do not need any other tool (steps)


    MKR Click image for larger version  Name:	Screenshot_2017-04-02-15-57-51.png Views:	1 Size:	24.7 KB ID:	639434
    Click image for larger version  Name:	Screenshot_2017-04-02-15-58-00.png Views:	1 Size:	57.3 KB ID:	639435
    Click image for larger version  Name:	Screenshot_2017-04-02-15-58-45.png Views:	1 Size:	57.2 KB ID:	639436










    Gamepad tester Click image for larger version  Name:	Screenshot_2017-04-02-15-54-24.png Views:	1 Size:	62.3 KB ID:	639437
    Click image for larger version  Name:	Screenshot_2017-04-02-15-55-10.png Views:	1 Size:	34.4 KB ID:	639438






    Enhanced MOD (remote.conf)

    With the following described enhanced modifications you can easily add any IR Remote Controler to also work with your android device. It helps you also in case some keys of your IR Remote aren't working (not set).

    Note: A full description on how to generate your own remote.conf file for any other IR Remote Controler can be found already >> here <<

    The remote.conf file to modify can be found her: system/etc/remote.conf
    Right now we will check only how to add the non working (not set) keys to our needs.

    First we have to check if debug is enabled in your remote.conf file. Because without this setting we will see nothing whats going on/wrong.

    Code:
    debug_enable = 1
    If it is set to 0, change it to 1 and reboot your device.

    Now open a Terminal session and enter the following commands
    Code:
    su
    to get root access

    Code:
    dmesg -c
    to clean all debug messages


    Now click that key on your remote control that does not even work when testing it with MKR or Gamepad tester

    Code:
    dmesg|grep "code is 0x"
    To see only those messages on keys who are not set to our remote.conf file


    You will see right now a masse like this: Wrong custom code is 0xaabbcccc

    So our needed ScanCode to set at remote.conf is: bb

    Now we can set the right ScanCode to our remote.conf and *.kl files like this.


    remote.conf
    Code:
    0xbb 123

    Vendor_XXXX_Product_XXXX.kl
    Code:
    key 123 DPAD_UP

    So 0xbb is the key we press on our remote and 123 is the ScanCode to this key and it is set to in our *.kl file as DPAD_UP



    Tipps & Tricks

    While your are generating your own configurations file I should finally also mention the follwing tipps & tricks I made.

    Android Key Layout files (*.kl)

    The one file who fits them all (Generic.kl)

    There are always already a lot of Key Layout files included to you Android. The most important is the Generic.kl file. Because this file is always used in case there is no other specific file, created only to mach to one specific device. So in case there is no kl file that match to your device Vendor & Device ID or device name, Android will always use the Generic.kl file. So it is not a good idea to change anything to the Generic.kl. Because this could mess up the function of other input devices, that have also no own *.kl file. So it is always better to create a specific key file for each individual input device.

    Error solving while creating your own *kl file
    Sometimes while creating your own key layout files, things do not work as they should. In those cases it is good to now what causes the issue.
    One of my best practice to check if the issue comes from your own created file or not, is to move all already existing *.kl to a sub folder. So the system has only the one file you created. But keep in mind that now no other input device will work anymore until you copy them back to it original folder. And you should always have a mouse attached to your Android device. Becasue this will be the only device that works without any *.kl file.

    Summary: Use a Mouse as input backup & remove all other *.kl files temporary.



    General tipps while editing

    Keep always a copy of the original configurations file as reference, by just renaming the original file like this:
    • remote.conf >> remote.conf_
    • Generic.kl >> Generic.kl_
    Last edited by cOOLio; 04-02-2017, 10:57.
    My contributions to the community
    [ ROMs ] Z4 RK3368 - android TV (ATV) | MXQ PRO 4K - p201 - android TV (ATV) | Yundo Y1 S912 - android TV (ATV) not yet released
    [ Tutorials ] Bootup logo Amlogic S912 devices | Redefine any Keyboard, Gamepad, Remote Control

  • #2
    Good write up!
    Thanks for sharing.

    ​​​​Neomode

    Comment


    • #3
      Welcome ... I did a lot of research to modify/fix all my remote controls, keybords and gamepads. I was wondering why there isn't any of those sources I found, that has it all in one, like a swiss army knife. So I decided to make my own tutorial, where I put all my own experiences to. And maybe it is worth to put this threat as sticky?
      My contributions to the community
      [ ROMs ] Z4 RK3368 - android TV (ATV) | MXQ PRO 4K - p201 - android TV (ATV) | Yundo Y1 S912 - android TV (ATV) not yet released
      [ Tutorials ] Bootup logo Amlogic S912 devices | Redefine any Keyboard, Gamepad, Remote Control

      Comment


      • #4
        Sure this Threat is worth to get a "Sticky" !

        Neomode

        Comment


        • #5
          Yes, very nice thread cOOLio.
          Khadas VIM(S905X), Beelink R68 II(S912), GOLE1(Intel Z8300), NEXBOX T10(Intel Z8300), Ugoos UT3(RK3288) and UT3+(RK3288), R-Box(RK3229-2GB/8GB), Tronsmart S95 Meta(AMLS905), Inphic i7(S905), UBOX(AMLS805), Q7(RK3188T)

          Comment

          Working...
          X