tv

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: http://lirc.org/ir-audio.html

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

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:

begin
prog = irxevent
button = YOURBUTTONNAMEFROMLIRCCONFIG
config = Key Page_Up CurrentWindow
end

begin
prog = irxevent
button = InfraOkButton
config = Key Enter CurrentWindow
end

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)

How to build XBMC in Debian (etch)

After many long hours of forum sweeping and googleing I finally managed to build XBMC in Debian. It took me exactly 18 hours to do this starting from scratch. (final build after satisfying all perquisites took about 3 hours)

Yes, it is possible to build and run XBMC in Debian without too much hassle.

Why: I have a linux machine running a server environment for my files, and I thought it would be nice to use it as a media center since it is always on. Since it is al set up i did not want to install an ubuntu on it just for the media center, so I had to build XBMC for Debian (etch)  from the sources. Unfortunately Debian is not yet supported by XBMC community, but you can obtain the source code and build it anyway. Here is what i did. (I am in no way a linux wiz, so this is probably not the best way to build it, but it should work)

My configuration: AMD K7 1300 Mhz, 768Mb RAM, GeForce MX440 SE using Debiean (etch) with Kernel Image 2.6.18-6-k7

Step 1 – Get the source code

(assuming you are root and are in your home folder)

(if you don’t have subversion installed: apt-get install subversion )

Step 2 – Install the required packages

Add the backports to your /etc/apt/sources.list

Edit the /etc/apt/sources.list and add contrib and non-free
Install graphics driver so when you run glxinfo you should see Direct rendering enabled.

Now install these packages.

I did my build by excluding faac and pulse audio.

This command will most likely FAIL at the first time you try it, so just get rid of the packages which are not found, and use a tool like aptitude to search for different naming. (lib in front of the name, and/or -dev at the end) My environment is very messy, so I am not sure which ones I had from different sources. Try running ./configure –disable-faac from your XBMC sources directory, and it will complain about what you are missing from the environment.

Step 3 – Configure script

Change to your sources directory and run the ./configure script. (for me it is linuxport/XBMC/)
If ./configure finished successfully you should try to run make
If your lucky enough it might run, but I had several issues with it.

For me the first fix was to re-run configure with disabled PulseAudio and faac.

Step 4 – Editing and running the makefile

From this point my serious issues started, I will list a few which i had, if you are lucky and make finishes successfully, you may skip this section :)

The sqlite3_prepare_v2() issue
I got a missing function error here, so i changed the line of code in question(in the file the error was coming from).

Changed the function name sqlite3_prepare_v2 to sqlite3_prepare

I guess my sqlite libraries are old, you might try updating yours.

The CPulseAudioDirectSound issue

I got an error in the file “AudioRendererFactory.cpp” in line 64 related to CPulseAudioDirectSound not being found. This was strange because i explicitly disabled Pulseaudio. I just commented out both lines of code in this section. (lines 64 and 65)

The smbclient issue

This was a strange issue, i don’t know why xbmc-s internal smbclient library does not work. In any case, I’ve installed smbclient via: apt-get install smbclient smbclient-dev

And edited the Makefile like this:

Find something like: OBJSXBMC += \
continued by path to libsmbclient-i486-linux.a, should be around line 314 and 315, and enclose it in /* .. */ block. (comment it out)

Next look for the LIBS=… line (around line 85) which contains all libraries and append: -lsmbclient to it’s end.

The xrandr.c issues
All of these can be solved by upgrading your libxrandr packages. I did this by manually fetching the files and requirements from the debian packages list. Etch has xrandr 1.1.0 i think, and xbmc requires at least 1.2.3

http://packages.debian.org/lenny/libxrandr-dev

You can get the deb file here and try to install it by: dpkg -i PACKAGENAME.DEB (it will tell you what it’s missing, and follow the links on the debian page, you will find them there. Get those packages, and install them the same way, then retry installing xrandr package)

Step 5 – Make Install

Once make has completed successfully (will take a few hours on slower machines) you can install xbmc.

Step 6 – Run and enjoy

Once you installed run it by typing “xbmc” in your terminal.

————————————–

I will try to keep this list updated as comments roll in with problems and solutions.

Have fun using XBMC, and thank the guys and babes at xbmc.org for making such a cool software.