Support Custom Remote Controller with Ubuntu 16.04

  • [step 1] Install LIRC Package
  • [step 2] Configuring LIRC and driver module
  • [step 3 (1)] Case 1 : Registering custom remote controller
  • [step 3 (2)] Case 2 : Registering Hardkernel remote controller
  • [step 4] restart lircd service

Install LIRC package. While installing lirc, you will be asked the device type of IR receiver and transmitter.
Since we will set up this later by manual, you can select None.

$ sudo apt-get install lirc

Now you will need to modify /etc/lirc/hardware.conf to specify the configuration to run as a daemon.

$ sudo vi /etc/lirc/hardware.conf

Specify the kernel driver module and its node to read IR signal.

  REMOTE_MODULES="meson-ir"
  REMOTE_DRIVER="default"
  REMOTE_DEVICE="/dev/lirc0"

As well as below to make lircd start on boot.

  START_LIRCD="true"

In order to apply key event to whole system, enable Userspace Input Event while adding –uinput as a parameter of lircd.

  REMOTE_LIRCD_ARGS="--uinput"

All necessary configuration is done, you can simply start the service lirc by command line or reboot the device.

$ sudo service lirc restart
Default hardware.conf
hardware.conf
# /etc/lirc/hardware.conf
#
#Chosen Remote Control
REMOTE="None"
REMOTE_MODULES="meson-ir"
REMOTE_DRIVER="default"
REMOTE_DEVICE="/dev/lirc0"
REMOTE_SOCKET=""
REMOTE_LIRCD_CONF=""
REMOTE_LIRCD_ARGS="--uinput"
 
#Chosen IR Transmitter
TRANSMITTER="None"
TRANSMITTER_MODULES=""
TRANSMITTER_DRIVER=""
TRANSMITTER_DEVICE=""
TRANSMITTER_SOCKET=""
TRANSMITTER_LIRCD_CONF=""
TRANSMITTER_LIRCD_ARGS=""
 
#Disable kernel support.
#Typically, lirc will disable in-kernel support for ir devices in order to
#handle them internally.  Set to false to prevent lirc from disabling this
#in-kernel support. 
#DISABLE_KERNEL_SUPPORT="true"
 
#Enable lircd
START_LIRCD="true"
 
#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD="false"
 
#Try to load appropriate kernel modules
LOAD_MODULES="true"
 
# Default configuration files for your hardware if any
LIRCMD_CONF=""
 
#Forcing noninteractive reconfiguration
#If lirc is to be reconfigured by an external application
#that doesn't have a debconf frontend available, the noninteractive
#frontend can be invoked and set to parse REMOTE and TRANSMITTER
#It will then populate all other variables without any user input
#If you would like to configure lirc via standard methods, be sure
#to leave this set to "false"
FORCE_NONINTERACTIVE_RECONFIGURATION="false"
START_LIRCMD=""

Before runing irrecord, please make sure service lircd should release the node, /dev/lirc0.

root@odroid64:~# sudo kill `pidof lircd`

https://forum.odroid.com/viewtopic.php?f=141&t=27593

Lirc package provide a tool, irrecord, to help registering the buttons of own remote controller. Once the tool is started, for example, you will be asked to press the buttons and it will analyse the signals of your remote controller like protocol type or headers. After this analysis you can start register the buttons one by one.

$ sudo irrecord --device /dev/lirc0 lircd.conf

Once signal analysis is done, you will be asked with the message below to enter the button name to register and press the applicable button. In this step, you can register many buttons as much as you expect to register. If you done, just press enter key on the prompt.

Please enter the name for the next button (press <ENTER> to finish recording)

The tool would ask you more steps to finalize and store the configuration file with the below message.

Successfully written config file.

For example, if you have done whole steps successfully with Hardkernel's stock remote controller, your will have the configuration file like below very similiary.

Now you must copy the configuration file, lircd.conf, to /etc/lirc/ so that lirc service can recognize the button.

$ sudo cp lircd.conf /etc/lirc/lircd.conf

If you use a Hardkernel remote controller, you can use the following lircd.conf.

$ sudo vi /etc/lirc/lircd.conf
lircd.conf
begin remote
 
name odroid
bits 16
flags SPACE_ENC|CONST_LENGTH
eps  30
aeps 100
 
header 9000 4500
one 563 1688
zero 563 564
ptrail 563
pre_data_bits 16
pre_data 0x4DB2
repeat 9000 2250
gap 100000
toggle_bit_mask 0x0
    begin codes
        KEY_LEFT  0x9966
        KEY_RIGHT  0x837C
        KEY_UP  0x53AC
        KEY_DOWN  0x4BB4
        KEY_ENTER  0x738C
        KEY_HOME  0x41BE
        KEY_MUTE  0x11EE
        KEY_MENU  0xA35C
        KEY_BACK  0x59A6
        KEY_VOLUMEDOWN  0x817E
        KEY_VOLUMEUP  0x01FE
        KEY_POWER  0x3BC4
    end codes
end remote

Then, you need to restart lirc service.

$ sudo service lirc restart

If the Lirc daemon is running and drivers are loaded properly, you can test if your remote controller is accepted by the tool irw.

$ irw
000000004db29966 00 KEY_LEFT lircd.conf
000000004db2837c 00 KEY_RIGHT lircd.conf
000000004db253ac 00 KEY_UP lircd.conf
000000004db24bb4 00 KEY_DOWN lircd.conf
000000004db2738c 00 KEY_ENTER lircd.conf

You can check if the daemon is running properly.

$ ps -ax | grep lirc
  678 ?        Ss     0:01 /usr/sbin/lircd --output=/run/lirc/lircd --driver=default --device=/dev/lirc0 --uinput

As well as necessary drivers are loaded.

$ lsmod
Module              Size   Used by
ir_lirc_codec       4468   3
lirc_dev            8576   1 ir_lirc_codec
ir_mce_kbd_decoder  2980   0
ir_sanyo_decoder    1515   0
ir_sony_decoder     1553   0
ir_jvc_decoder      1559   0
ir_rc6_decoder      1911   0
ir_rc5_decoder      1543   0
ir_nec_decoder      1687   0
meson_ir            2927   0