[Tutorial FEB 2021] Add any IR remote to android 9 based atvXperience

Post your great articles here :)
Post Reply
xijunw
Posts: 4
Joined: Sat Jan 23, 2021 6:33 pm
Answers: 0
Been thanked: 3 times

#1

Table of Contents
|. Facts
II. Steps by Steps
III. Trouble shooting

I. Facts

- Any IR remote (NEC protocol) can be used on android 9 based atvXperience; (Most remotes sold on amazon or aliexpress are NEC IR remote.)
- atvXperience support multiple remotes simultaneously;


In this tutorial, I will demonstrate how to add any IR remote to TV boxes with atvXperience and make it work easily by yourself.
Googling a configuration file is not recommended since the file could be using Key_codesdefined totally different even the scan_codes are correct.

First of all, I will make it short for experienced users, then I will explain step by step for fresh players.

3 Steps to make a remote work on TV box with atvXperience (android 9 based.)
A. Find, edit or make the right configuration file for the remote in the proper format;(see further details below)
B. Put it under /vendor/etc , name it as remote.tab5 following 4 remote.tabx files already there; (file name does not matter at all as long as it is properly configured into the core service)
C. Configure it with /vendor/bin/remotecfg with root by executing

Code: Select all

$ /vendor/bin/remotecfg -c /vendor/etc/remote.cfg -t /vendor/etc/remote.tab5
Then the remote should be working immediately without rebooting the box or any other action.

II. Steps by steps

1. The format of the remote configuration file

Code: Select all


## Amlogic NEC remote

custom_name   = remote-df00    # Any name is OK; Including device code is recommended for debug reason
custom_code   = 0xdf00  # df00 is the device code; prefix with "0x"
release_delay = 80 

fn_key_scancode    = 0x03 # MOUSE
cursor_left_scancode  = 0x47 # LEFT
cursor_right_scancode = 0x07 # RIGHT
Cursor_up_scancode    = 0x1a # UP
Cursor_down_scancode  = 0x48 # DOWN
Cursor_ok_scancode    = 0x06 # OK

mouse_begin

  0 0x47 # LEFT
  1 0x07 # RIGHT
  2 0x1a # UP
  3 0x48 # DOWN

mouse_end

key_begin

## BASIC TV CONTROL
  0x1c 116 # POWER
  0x5c 114 # VOLUME_DOWN (VOL-)
  0x5d 115 # VOLUME_UP (VOL+)
  0xf3 113 # MUTE (KBUTTON)

## DAPD and FUNCTION KEYS
  0x47 105 # LEFT
  0x07 106 # RIGHT
  0x1a 103 # UP
  0x48 108 # DOWN
  0x06 97  # ENTER (OK)

  0x0a 1   # RETURN or BACK
  0x42 102 # HOME
  0x18 139 # MENU
  
  0x4b 121 # REWIND  |<<
  0x4f 120 # FORWARD >>|
  0x01 119 # PLAY PAUSE
  0x5f 62  # HELP
  0x41 20  # WEB EXPLORER

## NUMBERS

  0x54 2   # 1
  0x16 3   # 2
  0x15 4   # 3
  0x50 5   # 4
  0x12 6   # 5
  0x11 7   # 6
  0x4c 8   # 7
  0x0e 9   # 8
  0x0d 10  # 9
  0x0c 11  # 0

repeat_key_begin

## ADD MORE IF YOU WANT
## USUALLY ONLY FOLLOWING KEYS NEED REPEAT
  0x47 105 # LEFT
  0x07 106 # RIGHT
  0x1a 103 # UP
  0x48 108 # DOWN
  0x5c 114 # VOLUMEDOWN (VOL-)
  0x5d 115 # VOLUMEUP (VOL+)

repeat_key_end

key_end

What you need to know:

A. custom_code the device code the unique ID of the remote which you have to find out (see below)
B. scan_code The first column in the key section and any other 0x?? code are called scan_code. The NEC protocol translate the physical IR signal into the code that is received by TV box and Linux core;
C. key_code The second column in the key section are called key_code, each key_code correspond to a action or event which is defined by the keylayout file (.kl) under /vendor/usr/keylayout
D. The above remote configuration file must accompanied with a remote.cfg file which is already included in atvXperience under /vendor/etc


2. How to find the device code and scan_code by yourself
This is the most reliable way to make a correct configuration file for a remote and it is strongly recommended to do by yourself.
(To be working on)

3. How to upload the configuration file into the TV box and put it under /vendor/etc
(To be working on)

4. How to run linux command to configure the remote without using developer's adb tool
(To be working on)

III. Trouble shooting

I will add discussion here. Feel free to ask questions related to remote here.
MagHiro
Posts: 2
Joined: Tue Apr 20, 2021 10:53 am
Answers: 0

#2

Everything worked as it should, but how do I wake up the device, power button just turned off the device but can't turn it back on. And I have to execute the script every time my device turn back on otherwise it will not run
goul
Posts: 1
Joined: Fri Dec 17, 2021 11:50 am
Answers: 0

#3

MagHiro wrote: Thu Apr 22, 2021 3:09 am Everything worked as it should, but how do I wake up the device, power button just turned off the device but can't turn it back on. And I have to execute the script every time my device turn back on otherwise it will not run
I solved by adding the command at init. Search for

Code: Select all

service remotecfg4 /vendor/bin/remotecfg -t /vendor/etc/remote.tab4
.
eg.
/vendor/etc//init/hw/init.amlogic.rc
Duplicate the remote4 config for remote5
Lpfxh123
Posts: 2
Joined: Wed Jan 25, 2023 2:13 am
Answers: 0
Has thanked: 1 time

#4

please help me :grinning:
In what position to add the correct. I open init.amlogic. I don't know where to add it

在什么位置添加正确。我打开init.amlogic。不知道在什么位置添加
User avatar
em3ka
Moderator
Posts: 1835
Joined: Sun Jul 15, 2018 11:43 am
Answers: 0
Has thanked: 108 times
Been thanked: 370 times

#5

Add it following existing entries, or at the end of init.amlogic.rc script
service remotecfg /vendor/bin/remotecfg /vendor/etc/remote.conf
class main
oneshot
seclabel u:r:remotecfg:s0

service remotecfg1 /vendor/bin/remotecfg -t /vendor/etc/remote.tab1
class main
oneshot
seclabel u:r:remotecfg:s0

service remotecfg2 /vendor/bin/remotecfg -t /vendor/etc/remote.tab2
class main
oneshot
seclabel u:r:remotecfg:s0
.
.
.
service remotecfg5 /vendor/bin/remotecfg -t /vendor/etc/remote.tab5
class main
oneshot
seclabel u:r:remotecfg:s0
Lpfxh123
Posts: 2
Joined: Wed Jan 25, 2023 2:13 am
Answers: 0
Has thanked: 1 time

#6

thank you for your help
谢谢您的帮助
shaneui04
Posts: 5
Joined: Sun Oct 30, 2022 8:11 am
Answers: 0

#7

xijunw wrote: Tue Feb 09, 2021 9:00 am Table of Contents
|. Facts
II. Steps by Steps
III. Trouble shooting

I. Facts

- Any IR remote (NEC protocol) can be used on android 9 based atvXperience; (Most remotes sold on amazon or aliexpress are NEC IR remote.)
- atvXperience support multiple remotes simultaneously;


In this tutorial, I will demonstrate how to add any IR remote to TV boxes with atvXperience and make it work easily by yourself.
Googling a configuration file is not recommended since the file could be using Key_codesdefined totally different even the scan_codes are correct.

First of all, I will make it short for experienced users, then I will explain step by step for fresh players.

3 Steps to make a remote work on TV box with atvXperience (android 9 based.)
A. Find, edit or make the right configuration file for the remote in the proper format;(see further details below)
B. Put it under /vendor/etc , name it as remote.tab5 following 4 remote.tabx files already there; (file name does not matter at all as long as it is properly configured into the core service)
C. Configure it with /vendor/bin/remotecfg with root by executing

Code: Select all

$ /vendor/bin/remotecfg -c /vendor/etc/remote.cfg -t /vendor/etc/remote.tab5
Then the remote should be working immediately without rebooting the box or any other action.

II. Steps by stepsgb whatsapp

1. The format of the remote configuration file

Code: Select all


## Amlogic NEC remote

custom_name   = remote-df00    # Any name is OK; Including device code is recommended for debug reason
custom_code   = 0xdf00  # df00 is the device code; prefix with "0x"
release_delay = 80 

fn_key_scancode    = 0x03 # MOUSE
cursor_left_scancode  = 0x47 # LEFT
cursor_right_scancode = 0x07 # RIGHT
Cursor_up_scancode    = 0x1a # UP
Cursor_down_scancode  = 0x48 # DOWN
Cursor_ok_scancode    = 0x06 # OK

mouse_begin

  0 0x47 # LEFT
  1 0x07 # RIGHT
  2 0x1a # UP
  3 0x48 # DOWN

mouse_end

key_begin

## BASIC TV CONTROL
  0x1c 116 # POWER
  0x5c 114 # VOLUME_DOWN (VOL-)
  0x5d 115 # VOLUME_UP (VOL+)
  0xf3 113 # MUTE (KBUTTON)

## DAPD and FUNCTION KEYS
  0x47 105 # LEFT
  0x07 106 # RIGHT
  0x1a 103 # UP
  0x48 108 # DOWN
  0x06 97  # ENTER (OK)

  0x0a 1   # RETURN or BACK
  0x42 102 # HOME
  0x18 139 # MENU
  
  0x4b 121 # REWIND  |<<
  0x4f 120 # FORWARD >>|
  0x01 119 # PLAY PAUSE
  0x5f 62  # HELP
  0x41 20  # WEB EXPLORER

## NUMBERS

  0x54 2   # 1
  0x16 3   # 2
  0x15 4   # 3
  0x50 5   # 4
  0x12 6   # 5
  0x11 7   # 6
  0x4c 8   # 7
  0x0e 9   # 8
  0x0d 10  # 9
  0x0c 11  # 0

repeat_key_begin

## ADD MORE IF YOU WANT
## USUALLY ONLY FOLLOWING KEYS NEED REPEAT
  0x47 105 # LEFT
  0x07 106 # RIGHT
  0x1a 103 # UP
  0x48 108 # DOWN
  0x5c 114 # VOLUMEDOWN (VOL-)
  0x5d 115 # VOLUMEUP (VOL+)

repeat_key_end

key_end

What you need to know:

A. custom_code the device code the unique ID of the remote which you have to find out (see below)
B. scan_code The first column in the key section and any other 0x?? code are called scan_code. The NEC protocol translate the physical IR signal into the code that is received by TV box and Linux core;
C. key_code The second column in the key section are called key_code, each key_code correspond to a action or event which is defined by the keylayout file (.kl) under /vendor/usr/keylayout
D. The above remote configuration file must accompanied with a remote.cfg file which is already included in atvXperience under /vendor/etc


2. How to find the device code and scan_code by yourself
This is the most reliable way to make a correct configuration file for a remote and it is strongly recommended to do by yourself.
(To be working on)

3. How to upload the configuration file into the TV box and put it under /vendor/etc
(To be working on)

4. How to run linux command to configure the remote without using developer's adb tool
(To be working on)

III. Trouble shooting

I will add discussion here. Feel free to ask questions related to remote here.
Check if your device supports a wake-up feature through the IR remote. Some Android TV boxes may have a setting in their system that allows the IR remote to wake up the device from sleep or standby mode. Look for this setting in your device's power management or input settings.
Post Reply