How to use ir remote on android

8,523 views
Skip to first unread message

Tom Cubie

unread,
Jan 11, 2013, 5:12:40 AM1/11/13
to cubie...@googlegroups.com
Hi,

The cubieboard has an IR receiver but do not come with a IR remote,
one friend of me in China asked if he can control his cubieboard with
unused key on the TV remote, then he can use one remote to control
both TV and the board.

First i found that the IR driver has some ir code check in
https://github.com/linux-sunxi/linux-sunxi/blob/sunxi-3.0/drivers/input/keyboard/sun4i-ir.c#L459

After disabling the ir code check, i can get event from two ir remote
here i have. To test if your remote can be recognized, you can try the
following:

connect your board via mini usb cable

adb pull drivers/input/keyboard/sun4i-ir.ko sun4i-ir.ko.bak
adb shell mount -o remount,rw /system
wget http://tom.linux-sunxi.org/cubieboard/sun4i-ir.ko #built with
IR_CHECK_ADDR_CODE undefined.
adb push sun4i-ir.ko /system/vendor/modules/
adb reboot

then you can test the remote with android getevent
adb shell
root@android:/ #
root@android:/ #
root@android:/ # getevent
add device 1: /dev/input/event4
name: "sun4i-ir"
add device 2: /dev/input/event3
name: "HID 1220:0008"
could not get driver version for /dev/input/mouse0, Not a typewriter
add device 3: /dev/input/event2
name: "HID 1220:0008"
add device 4: /dev/input/event0
name: "sun4i-keyboard"
could not get driver version for /dev/input/mice, Not a typewriter
add device 5: /dev/input/event1
name: "axp20-supplyer"

Now press the remote, if the remote can be recognized, there will be
something like,
/dev/input/event4: 0001 000c 00000001
/dev/input/event4: 0000 0000 00000000
/dev/input/event4: 0001 000c 00000002
/dev/input/event4: 0000 0000 00000001
/dev/input/event4: 0001 000c 00000000
/dev/input/event4: 0000 0000 00000000

000c is the code of the key pressed.

Now you can define this key's function in android.
adb pull /system/usr/keylayout/sun4i-ir.kl
edit sun4i-ir.kl you will see something like:
key 79 BACK WAKE_DROPPED
You can assign the function of key you just pressed to anything you
like, but notice that getevent shows the code in HEX, but sun4i-ir.kl
is decimal.

This may solve the volume key worry and the zoom and pinch problem
reported in the g+ community.

--
Keep simple, stay foolish.

Diogo Carvalho

unread,
May 24, 2013, 4:50:04 AM5/24/13
to cubie...@googlegroups.com
Hi,
 
I'm using the image TvBox 2.2 and I don't have replaced the sun4i-ir.ko with yours.
With getevent I can see the remote be recognized.
I have remaped the keys in sun4i-ir.kl but it doesn't work.
Some keys on my remote control are writing numbers and letters, and in sun4i-ir.kl there are no defined keys that work like a keyboard.
So it is possible that the sun4i-ir.kl is not used and it use another keylayout file?

Egoitz Esteban

unread,
Jun 6, 2013, 6:49:04 AM6/6/13
to cubie...@googlegroups.com
Doesnt work with sony bravia IR Remote :(
Message has been deleted

Kiran Kumar chintagumpala

unread,
Jun 20, 2013, 8:12:06 AM6/20/13
to cubie...@googlegroups.com
Hi,

This works awesome for me. But i have problem with power.


With IR remote  I am able to switch off the board but unable to wake up.


Please tell me how to wake up the board with IR remote.

Thanks
Kiran Kumar

Patrick Wood

unread,
Jun 20, 2013, 10:14:14 AM6/20/13
to cubie...@googlegroups.com
I'm not sure that's possible. You may have to put the board into a low power sleep mode, e.g., CPU @60mhz, video, net, usb powered down, etc.

Kiran Kumar chintagumpala

unread,
Jul 5, 2013, 1:43:58 AM7/5/13
to cubie...@googlegroups.com
Hi Patrick,

Sorry for delay reply and thanks for your reply. We will try this.

Murat Jumashev

unread,
Nov 9, 2013, 12:06:28 PM11/9/13
to cubie...@googlegroups.com
Hi, Tom,

In CubieTruck getevent looks like this:

root@android:/ # getevent
add device 1: /dev/input/event2
  name:     "vmouse"
could not get driver version for /dev/input/mouse0, Not a typewriter
add device 2: /dev/input/event1
  name:     "sun7i-ir"
add device 3: /dev/input/event0
  name:     "sw-keyboard"
could not get driver version for /dev/input/mice, Not a typewriter
add device 4: /dev/input/event3
  name:     "axp20-supplyer"

Should we use new sun7i-ir.ko ?

пятница, 11 января 2013 г., 16:12:40 UTC+6 пользователь Tom Cubie написал:

Patrick Wood

unread,
Nov 10, 2013, 12:56:14 PM11/10/13
to cubie...@googlegroups.com
Yes, but newer kernels will have the merged sunxi-ir instead.

Murat Jumashev

unread,
Nov 15, 2013, 11:18:51 PM11/15/13
to cubie...@googlegroups.com
Hey Patrick, 
Thanks! Can you give more information on this, please? I cannot couple IR remote with my CubieTruck.

воскресенье, 10 ноября 2013 г., 23:56:14 UTC+6 пользователь Patrick Wood написал:

cubie...@gmail.com

unread,
Dec 24, 2013, 10:15:06 PM12/24/13
to cubie...@googlegroups.com
Hi.
Exactly how to undefined IR_CHECK_ADDR_CODE.
I'm going to build
sun7i-ir.ko

Felix Hsiao

unread,
Feb 19, 2014, 3:07:21 AM2/19/14
to cubie...@googlegroups.com
Dear All,

Anyone has sun7i-ir.ko with undefined IR_CHECK_ADDR_CODE and related sun7i-ir.kl for cubieboard2? Or direct me how build them. I'd like to develop a android app to get the ir event and do some actions.

Thanks.

Felix

nayden penev

unread,
Apr 5, 2014, 2:31:32 AM4/5/14
to cubie...@googlegroups.com
Here is mine build for 3.4.39

If you want to compile it yourself find the "ir-keymap.h" file in "linux-3.4/drivers/input/keyboard" and comment following line:

#define IR_CHECK_ADDR_CODE.

Recompile, upload it to your board replacing the old one and edit the key layout according to the IR remote you got. 

Python Jungle

unread,
Dec 16, 2014, 4:26:35 AM12/16/14
to cubie...@googlegroups.com
You make it for Cubieboard2?

On my Cubietruck (3.4.39) this module can't loading.
"Exec format error"

суббота, 5 апреля 2014 г., 9:31:32 UTC+3 пользователь nayden penev написал:
Reply all
Reply to author
Forward
0 new messages