My hack of the day: an Infrared remote for XBMC / Debian

I now have xbmc installed on my server, which is plugged into my monitor via a looong extension cable. Having a wireless mouse for controlling used to be OK, but it got kind of annoying to find a flat surface every time you wanted to pause the movie or browse through directories.

So I thought it would be nice to attach an IR pickup and preferably use the unused buttons of my Samsung T240HD TV’s remote. When in PC monitor mode, the TV does not use it’s directional keys, OK, Escape and none of the Colored buttons, so mapping these would be perfect.

To use IR you need two things: 1. an InfraRed receiver and 2. some software to go with it. In my case I did not have a nice usb IrDA, so I had to make my own. Luckily it’s quite simple. All you need is and infrared pickup diode(old tv or whatever) and +5V to power it. The computer will pick up the signals via your computer’s audio line-in port. You simply build this contraption and hook it up to you line-inport:

You can get +5V from any of your power connectors, if you have a multimeter make sure you have the correct tension before connecting everything to your sound card.

When everything is done, you can test it by enabling the Line-In playback on your PC and pressing some buttons. If everything is set up correctly you will hear strange noises when the IR receiver picks up any signals.

Now for the fun part: using LIRC to map unknown IR signals to keyboard events.

1. Install LIRC using aptitude or whatever, and make sure the programs irrecord and irxevent are installed.

2. You need to start up irrecord so you can test your connection and records some IR events.(i have mi input on the right channel of the sound input, depending on how you’ve set up your rig yours mith use the l parameter)

irrecord –driver audio_alsa –device hw@44100,r myConfigFileToBe

This will fire up irrecord and you can name your buttons after each successful read. You will also get a new config file which contains the codes of your remote.

Once this is done, it is time to test it:

1. Run the lirc daemon

lircd –driver audio_alsa –device hw@44100,r pathToYourConfigFileThatWasJustCreated

2. run irw


When you push buttons on your remote, irx will look them up in your config file and display the appropriate events.

All we need now is to map this input to keyboard events. You do this by using a program called irxevent. Once the lirc daemon is running, you can start irxevent by supplying a config file which contains the mappings: you need to create this file manually!

Create a blank text file, and enter any number of mappings in the following form:

prog = irxevent
config = Key Page_Up CurrentWindow

prog = irxevent
button = InfraOkButton
config = Key Enter CurrentWindow

and so forth…

When you are done, lunch irxevent like this

irxevent yourEventConfigFileName

Now test it: press some IR buttons and see if the keyboard events are fired.

From here, i just lunch XBMC and everything is working fine. (Note that XBMC does have support for lirc directly, you can use that aswell)

In English, My 2 cents, Tutoriale