Create remote.conf from scratch

  • I have a new TX3-Pro (S905X- Android 6) box. I run it with kszaq 7.0.2.009 version (thanks to kszaq, great job!). The only problem I had was that the remote control didn’t work at all. Also copying remote.conf from the Android /etc folder to libreelec /storage/.config didn’t help. I thought a while, that may be the device tree (dtb) was wrong for my box but this wasn’t. It was the remote.conf. It seems to me, that Android 6 uses a remote configuration different from the /system/etc/remote.conf.

    After ‘googleing’ a while, I found a description from a openelec user. He build a romete.conf from scratch for a WeeTeck-Box. I tried and it works. I was able to generate a working remote.conf for my box and now may remote works perfectly. Another benefit is, I was able to do my preferred key mapping.

    I’ve seen a lot of posts regarding a not working remote-control. Hopefully my post will help a little bit.

    1) Peparation
    Copy a remote.conf file to libreelec Configuration folder over SSH :
    /storage/.config
    or using Windows shares:
    \\your_box_IP\Configuration

    You can either use my file from the post or the file from your Android. If you use your file, take care that:

    • all lines between key_begin and key_end are deleted or marked as comment (leading #)
    • debug_enable = 1


    2) Set Factory Code
    Open the /storage/.config/remote.conf in any editor. You can also use the windows share \\your_box_IP\Configuration.
    Open a SSH session to your box (I use putty for this. User root, password libreelec).
    Type ‘dmesg –c’ in the ssh terminal. Ignore the message, it’s only for clearing the cache.
    Press any key in your remote control and directly dmesg -c in the ssh terminal. You will get something like this:

    Code
    wrong custom code is 0xXXYYZZZZ

    Go to the editor with the remote.conf. You will find a line like this:

    Code
    factory_code = 0x12340001

    Change the factory_code with this 0xZZZZ0001 (ZZZZ is the digits you have got as 'wrong custom code is' from the ssh above).
    For example if you get in the dmesg wrong custom code is 0x14fg76ad then your factory_code should be 0x76ad0001.
    Save the remote.conf and type 'remotecfg remote.conf' in the shell (or reboot your box). Factory code is set.

    3) Key Map
    Open the remote.conf in editor and the ssh in 2nd window again. Type Type ‘dmesg –c’ in the ssh terminal and ignore the message.
    Press any key in your remote control and directly dmesg -c in the ssh terminal. You will now get something like this:

    Code
    remote: scancode is 0x0043,invalid key is 0x0000.


    If you get this, the Factory code was set correctly.

    Now you can start the do the keymapping. In my remote.conf file, you’ll find the lines between key_begin and key_end likes this:
    # 0xca 116 ;POWER
    # 0x07 105 ;KEY_LEFT
    Start with the fist line. Press the POWER button on your remote. Type dmesg -c in the ssh terminal. You will now get something like this:

    Code
    remote: scancode is 0x0043,invalid key is 0x0000.

    Change the 1st line in the remote.conf to
    0x43 116 ;POWER
    This means:
    - removing the leading # (line is active)
    - change 0xca to 0x43 (change old/wong remote code with the correct code.)
    - keep 116 (this is the linux code for POWER button).You need to do this for all lines in the file. Don’t forget to save from time to time.

    Do this for all lines in the file.
    If you have no corresponding button on the remote, keep the line unchanged or delete it.
    If you have keys on the remote with no corresponding line in the file, you can create a new line. For this, you need to now the right linux code. In the link below, you’ll find all avalible codes. Not all of them work in Kodi, so you need to play a bit with the codes.
    linux/input-event-codes.h at master · torvalds/linux · GitHub

    If you set the code for all buttons on your remote, save the remote.conf and and type 'remotecfg remote.conf' in the shell (or reboot your box). Key Maping is done.

    4) Mouse
    If you like to use the mouse function on your remote, you have to define one key on your remote as mouse key. To get the mouse working, you also need to set the values in the upper section of the remote.conf. This are the lines you need to change. The '0x25' is the value you need to change with the value you got bavk from the ‘dmesg –c’. You also need to remove the leading '#'.



    5) repeat key section
    This is for keys on your remote where you like to have a repeat function if you press the key and keep it pressed. The only thing you need to do is to copy the relevant lines from the key section into the repeat_key section. I did it with the for lines for 'left', 'right', 'up', 'down'.

    Edited once, last by ippon (April 22, 2017 at 12:26 PM).

  • great tutorial guy,all work!

    i have a question, i want add on the remote control a shortcut to scan video library and clean video library(on 2 different button),do u know the code? i search on google but i find nothing

    thanks


  • i have a question, i want add on the remote control a shortcut to scan video library and clean video library(on 2 different button),do u know the code? i search on google but i find nothing

    Install the Add-on Keymap Editor. It's in the official Kodi repository, so it's not hard to find. Using this Add-on, which will be installed under Programs, you can set any key on your remote control to control a certain function of your choosing in Kodi. Of course the key on the remote should give out a signal that is recognised by the box to do so.

    Edited once, last by Bruur (January 17, 2017 at 9:46 AM).

  • Install the Add-on Keymap Editor. It's in the official Kodi repository, so it's not hard to find. Using this Add-on, which will be installed under Programs, you can set any key on your remote control to control a certain function of your choosing in Kodi. Of course the key on the remote should give out a signal that is recognised by the box to do so.

    I have already tried to use keymap editor but it does not work, the buttons assigns them but do not change their basic function, in fact, to remap some functions on the remote I've used this method, for example: play stop pause. I took from your example, the command file to go into my favorites that is not a function present in the standard linux commands and I think there are also codes to scan the library, but I can not find what they are.

  • I have already tried to use keymap editor but it does not work, the buttons assigns them but do not change their basic function, in fact, to remap some functions on the remote I've used this method, for example: play stop pause. I took from your example, the command file to go into my favorites that is not a function present in the standard linux commands and I think there are also codes to scan the library, but I can not find what they are.


    You're talking about kodi's built-in functions.
    eg

    Code
    UpdateLibrary(video)

    Edited once, last by trogggy (January 17, 2017 at 2:46 PM).


  • I still don't understand why Keymap editor is being brushed off that quickly. Just install it and go to: Global > Other > Update Video Library

    It does not work, check for example to a number key function that wilt but he does not, I also tried to add on the remote control play pause stop but with keymap editor did not work, instead going to change the remote.config files have succeeded!