In the previous article we installed on a microsd card Libreelec and started the device with this image
Libreelec Image for Amlogic socs
The remote control of the Beelink Minimx III is basic, so to have more keys we decided to associate another remote control to the box.
We chose the following remote control that has more buttons included
According to this document on Amlogic site, although prepared in Chinese, through the use of online translators
It shows that the soc Amlogic natively manages the NEC protocol for remote controls and through remote.conf file we can associate the remote control code to the Linux system events. The map of the codes for the Linux system events is available in the header files of the Linux kernel
As a first step we log on Libreelec in ssh with root/libreelec. Copy the /etc/amremote/libreelec.conf file as remote.conf in /storage/.config folder
1 |
cp /etc/amremote/libreelec.conf /storage/.config/remote.conf |
and edit it as follows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#********************************************************************************************************* #this file is configuration for each factory remote device # work_mode 0 :software mode 1 :hardware mode # repeat_enable 0 :disable repeat 1 :enable repeat # # factory_code each device has it's unique factory code. # pattern:custom_code(16bit)+index_code(16bit) # examble: 0xff000001 = 0xff00(custom cod) 0001 (index) # # release_delay unit:ms.release will report from kernel to user layer after this period of time # from press or repeat triggered. # # debug_enable 0 :debug disable 1 :debug disable # # SW MODE: # bit_count how many bits in each frame # tw_leader_act time window for leader active # tw_bit0 time window for bit0 time. # tw_bit1 time window for bit1 time # tw_repeat_leader time window for repeat leader # REG # reg_base_gen set value for PREG_IR_DEC_BASE_GEN # reg_control set value for PREG_IR_DEC_CONTROL # reg_leader_act set value for PREG_IR_DEC_LEADER_ACTIVE # reg_leader_idle set value for PREG_IR_DEC_LEADER_IDLE # reg_repeat_leader set value for PREG_IR_DEC_REPEAT_IDLE # reg_bit0_time set value for PREG_IR_DEC_BIT0_TIME #************************************************************************************************************* #amlogic NEC remote #factory_code = 0x00680001 work_mode = 0 repeat_enable = 1 release_delay = 150 debug_enable = 1 #reg_control = 0xfbe40 |
Load the new codes of the remote file with the command
1 |
remotecfg /storage/.config/remote.conf |
Press some button of the new remote control and run
1 |
dmesg -c |
In the case of compatible remote control we should see messages as shown below
1 |
remote: Wrong custom code is 0xae517f80 |
The format is as follows: 0xAABBCCCC. Following Amlogic document linked above, the remote control code for a specific key is 0xBB; while defining the remote control code we have to use 0xCCCC0001. AA corresponds to the inverse logic of the command. In the case of the above example
BB = 0x51 = 01010001 in binary. The logical inverse = 10101110 in binary, which is just 0xAE.
AA = 0xAE. Binary = 10101110
The AA code is not used for our remote control configuration.
Press all the buttons on remote control and run the dmesg -c command. In our case we have the following codes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
[ 563.475708@0] remote: Wrong custom code is 0xae517f80 [ 564.273258@0] remote: Wrong custom code is 0xb24d7f80 [ 565.096453@0] remote: Wrong custom code is 0xf6097f80 [ 565.805424@0] remote: Wrong custom code is 0xee117f80 [ 566.450804@0] remote: Wrong custom code is 0xab547f80 [ 567.118602@0] remote: Wrong custom code is 0xb04f7f80 [ 567.963741@0] remote: Wrong custom code is 0xa9567f80 [ 568.631341@0] remote: Wrong custom code is 0x42bd7f80 [ 569.321289@0] remote: Wrong custom code is 0x44bb7f80 [ 570.077504@0] remote: Wrong custom code is 0xb14e7f80 [ 570.953170@0] remote: Wrong custom code is 0xac537f80 [ 571.665000@0] remote: Wrong custom code is 0xe41b7f80 [ 572.354812@0] remote: Wrong custom code is 0xd9267f80 [ 573.163774@0] remote: Wrong custom code is 0xda257f80 [ 573.853329@0] remote: Wrong custom code is 0xf20d7f80 [ 574.520600@0] remote: Wrong custom code is 0xd8277f80 [ 575.210029@0] remote: Wrong custom code is 0xd7287f80 [ 575.988176@0] remote: Wrong custom code is 0xb6497f80 [ 576.633419@0] remote: Wrong custom code is 0xad527f80 [ 577.189905@0] remote: Wrong custom code is 0xce317f80 [ 577.834915@0] remote: Wrong custom code is 0xcd327f80 [ 578.391382@0] remote: Wrong custom code is 0xcc337f80 [ 578.881274@0] remote: Wrong custom code is 0xcb347f80 [ 579.482089@0] remote: Wrong custom code is 0xca357f80 [ 580.060612@0] remote: Wrong custom code is 0xc9367f80 [ 580.550538@0] remote: Wrong custom code is 0xc8377f80 [ 581.195652@0] remote: Wrong custom code is 0xc7387f80 [ 581.730036@0] remote: Wrong custom code is 0xc6397f80 [ 582.242330@0] remote: Wrong custom code is 0xa7587f80 [ 582.865319@0] remote: Wrong custom code is 0xcf307f80 [ 583.554914@0] remote: Wrong custom code is 0xbb447f80 |
The mapping of the remote control in kodi is in the /usr/share/kodi/system/keymaps/remote.xml file.
We mapped the remote control codes to the Linux input events. As an example let’s consider the Power button. The remote control code is
1 |
0x51 |
The KEY_POWER event in the input-event-codes.h file is
1 |
116 |
1 2 3 4 |
key_begin 0x51 116 #Poweroff KEY_POWER key_end |
Between the two data
1 |
0x51 116 |
insert a space, as indicated in Amlogic document linked above . The file used in this case is available at the following link
At the restart of the box Libreleelc reads the new configuration in /storage/.config/remote.conf allowing so the use of the new remote control.