Announcement

Collapse
No announcement yet.

[ 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

    (\__/)
    (='.'=)
    (")_(") This is Bunny. Copy Bunny
    into your signature to help him
    on his way to world domination.

    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

        (\__/)
        (='.'=)
        (")_(") This is Bunny. Copy Bunny
        into your signature to help him
        on his way to world domination.

        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


          • #6
            Hi coolio. I am trying to redefine poweer button on my mele f10 pro remote.
            "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."
            The problem is - there is no such file in that folder?!

            Comment


            • #7
              Originally posted by dincis1 View Post
              Hi coolio. I am trying to redefine poweer button on my mele f10 pro remote.
              "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."
              The problem is - there is no such file in that folder?!
              Any idea, somebody???

              Comment


              • #8
                Originally posted by dincis1 View Post
                Hi coolio. I am trying to redefine poweer button on my mele f10 pro remote.
                "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."
                The problem is - there is no such file in that folder?!
                That file is only for the IR Remote, not for any attached USB (like your Mele Remote) or Bluetooth device.
                And BTW any Rockchip RK3368 (and maybe other Rockchip devices?) do not have a remote.conf file. There IR Remote is set in the Kernel dtd (dts) file.

                But for any USB HID and Bluetooth devices you need only the edit/create the Easy MOD (.kl files) as described above.
                So you only have to find out the vendor & product id of your Mele Remote, then create its /system/usr/keylayout/Vendor_XXXX_Product_XXXX.kl file and set within this file the scancode of your Home button to HOME. You can also make a copy of the Generic.kl, rename it to your Mele Vendor_XXXX_Product_XXXX.kl file and change that file the scancode of your home key to HOME. TO finde out the right scancode check my description for the apps MKR or Gamepad tester above.
                Last edited by cOOLio; 05-23-2017, 13:29.
                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


                • #9
                  I already did change home button on mele wthout problems . I want to get power button to work on mele, but problem is- when testing the power button with gamepad tester or other programs, nothing happens- programm does not show anything. In some other treads i found, that meles remotes power button uses ir signal...dont know does it make any difference?

                  Comment


                  • #10
                    Originally posted by dincis1 View Post
                    I already did change home button on mele wthout problems . I want to get power button to work on mele, but problem is- when testing the power button with gamepad tester or other programs, nothing happens- programm does not show anything. In some other treads i found, that meles remotes power button uses ir signal...dont know does it make any difference?
                    Ohh yes, that is a big different, because all other keys are send via 2,5Ghz to the USB dongle. So very easy to change. But all RK3368 devices have no remote.conf files. (Shame to Rockchip for this proprietary kernel shit). So the only way to get your IR Power key to work, is to program/learn that key to one of the hard coded Ugoos IR Remote scan keys. Because U use the Ugoos Kernel with my Z4 ROM.
                    Therefor the the Z4 Remote will not work. Even not when you add the Z4 IR Keys to it. Not supported by the Ugoos Kernel.

                    These are the IR Key settings of the original kernel resource dtd (dts) files

                    Code:
                    Ugoos RK3368 IR Keys
                    
                    ir_key1 {
                        rockchip,usercode = <0x4040>;
                        rockchip,key_table = <0xf2 0xe8 0xba 0x9e 0xf4 0x67 0xf1 0x6c 0xef 0x69 0xee 0x6a 0xbd 0x66 0xea 0x73 0xe3 0x72 0xe2 0xd9 0xb2 0x74 0xbc 0x71 0xec 0x8b 0xbf 0x190 0xe0 0x191 0xe1 0x192 0xe9 0xb7 0xe6 0xf8 0xe8 0xb9 0xe7 0xba 0xf0 0x184 0xbe 0x175>;
                    };
                    
                    ir_key2 {
                        rockchip,usercode = <0xff00>;
                        rockchip,key_table = <0xeb 0x74 0xa3 0xfa 0xec 0x8b 0xfc 0x67 0xfd 0x6c 0xf1 0x69 0xe5 0x6a 0xf8 0xe8 0xb7 0x66 0xfe 0x9e 0xa7 0x72 0xf4 0x73>;
                    };
                    
                    ir_key3 {
                        rockchip,usercode = <0x1dcc>;
                        rockchip,key_table = <0xee 0xe8 0xf0 0x9e 0xf8 0x67 0xbb 0x6c 0xef 0x69 0xed 0x6a 0xfc 0x66 0xf1 0x73 0xfd 0x72 0xb7 0xd9 0xff 0x74 0xf3 0x71 0xbf 0x8b 0xf9 0x191 0xf5 0x192 0xb3 0x184 0xbe 0x2 0xba 0x3 0xb2 0x4 0xbd 0x5 0xf9 0x6 0xb1 0x7 0xfc 0x8 0xf8 0x9 0xb0 0xa 0xb6 0xb 0xb5 0xe>;
                    };
                    
                    
                    Z4 RK3368 IR Keys
                    
                    ir_key1 {
                        rockchip,usercode = <0x4040>;
                        rockchip,key_table = <0xf2 0xe8 0xba 0x9e 0xf4 0x67 0xf1 0x6c 0xef 0x69 0xee 0x6a 0xbd 0x66 0xea 0x73 0xe3 0x72 0xe2 0xd9 0xb2 0x74 0xbc 0x71 0xec 0x8b 0xbf 0x190 0xe0 0x191 0xe1 0x192 0xe9 0xb7 0xe6 0xf8 0xe8 0xb9 0xe7 0xba 0xf0 0x184 0xbe 0x175>;
                    };
                    
                    ir_key2 {
                        rockchip,usercode = <0x1dcc>;
                        rockchip,key_table = <0xff 0x74 0xf3 0x71 0xfd 0x72 0xf9 0xa5 0xf5 0xa3 0xe9 0xa4 0xf1 0x73 0xfc 0xac 0xf0 0x9e 0xee 0x1c 0xf8 0x67 0xbb 0x6c 0xef 0x69 0xed 0x6a 0xbf 0x8b 0xbe 0x2 0xba 0x3 0xb2 0x4 0xbd 0x5 0xb9 0x6 0xb1 0x7 0xbc 0x8 0xb8 0x9 0xb0 0xa 0xb6 0xb 0xb5 0xe 0xfe 0x3b 0xfa 0x3c 0xf6 0x3d 0xf2 0x3e 0xb7 0x40 0xb3 0x184>;
                    };
                    
                    ir_key3 {
                        rockchip,usercode = <0x1dcc>;
                        rockchip,key_table = <0xee 0xe8 0xf0 0x9e 0xf8 0x67 0xbb 0x6c 0xef 0x69 0xed 0x6a 0xfc 0x66 0xf1 0x73 0xfd 0x72 0xb7 0xd9 0xff 0x74 0xf3 0x71 0xbf 0x8b 0xf9 0x191 0xf5 0x192 0xb3 0x184 0xbe 0x2 0xba 0x3 0xb2 0x4 0xbd 0x5 0xf9 0x6 0xb1 0x7 0xfc 0x8 0xf8 0x9 0xb0 0xa 0xb6 0xb 0xb5 0xe>;
                    };
                    
                    ir_key4 {
                        rockchip,usercode = <0xef10>;
                        rockchip,key_table = <0xa2 0x74 0xe8 0x73 0xec 0x72 0xa6 0x58 0xa5 0x184 0xff 0x9e 0xb9 0xac 0xfa 0x8b 0xbe 0x1c 0xba 0x67 0xaa 0x6c 0xf8 0x69 0xfe 0x6a 0xe5 0xa5 0xa7 0xa4 0xe2 0xa3 0xaf 0x2 0xad 0x3 0xef 0x4 0xb3 0x5 0xb5 0x6 0xee 0x7 0xf0 0x8 0xb1 0x9 0xf2 0xa 0xb0 0xb 0xa0 0x40 0xa1 0xe>;
                    };
                    I do not know which of these Ugoos keys are the right one U have to use. But I think its the usercode 0xff00 (NEC IR code)
                    Becasue this is the only one that is different from the Z4 keys. So in case you can change the NEC IR code of your Remote or Power button to the 0xff00 NEC IR code protocol. You will see in theory also the scan code of the the POWER button. To set it within the ff680030_pwm.kl file. Because that's the *.kl file for the RK3368 IR Remote.
                    Last edited by cOOLio; 05-23-2017, 13:50.
                    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


                    • #11
                      I found this video.



                      Which Power button do you mean? Because it looks like the black POWER button can't be changed.

                      And BTW you can set any other key of your remote, you may not really use, as power button. Just set the scan code of that key U do not really need to POWER.
                      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


                      • #12
                        Originally posted by cOOLio View Post
                        I found this video.



                        Which Power button do you mean? Because it looks like the black POWER button can't be changed.

                        And BTW you can set any other key of your remote, you may not really use, as power button. Just set the scan code of that key U do not really need to POWER.
                        Actually its mele f10 pro I have
                        https://m.youtube.com/watch?v=xuqQemugM1U
                        Last edited by dincis1; 05-24-2017, 00:51.

                        Comment

                        Working...
                        X