Using LIRC with WinTV Nova-T USB stick in Mint 13

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
kleinbottle
Level 1
Level 1
Posts: 23
Joined: Thu Aug 25, 2011 4:26 pm

Using LIRC with WinTV Nova-T USB stick in Mint 13

Post by kleinbottle »

This tutorial details how I got WinTV Nova-T USB stick (model 294) to work in Maya (Mint 13) with LIRC (the dvb function works automatically via kaffeine):

Hardware: Lenovo Thinkpad T61p laptop
OS: Linux Mint 13 "Maya" Cinnamon Edition
Kernel:3.2.0.23 Generic

1.Install v4l-utils package:this provides the ir-keytable utility

2.Hotplug your USB IR receiver and run the following command from the terminal to see if it is recognised by the kernel input layer:

sudo ir-keytable

Mine showed the following output:

Found /sys/class/rc/rc0/ (/dev/input/event9) with:
Driver dib0700, table rc-dib0700-rc5
Supported protocols: NEC RC-5 RC-6
Enabled protocols: RC-5
Repeat delay = 500 ms, repeat period = 125 ms


This will show what driver (ie:dib0700) and keymap (ie:rc-dib0700-rc5:corresponding to the dib0700_rc5 keymap file in the /lib/udev/rc_keymaps folder ) is being loaded and also that the IR receiver is mapped to /dev/input/event9

Ofcourse your's may be different

3.Then test if scancodes and keycodes are being retrieved by running(substitute the # with whatever rc number you see above in "Found /sys/class/rc/rc0/".In this case it was rc0):

sudo ir-keytable -s rc# -t


If you see scancodes but no keycodes then the keymap is wrong.Thats what happened with me.To remedy that i modified /lib/udev/rc_keymaps/dib0700_rc5 by copying the correct scancodes-keycodes from this site: http://ubuntuforums.org/showthread.php?t=1867643 AND also renamed KEY_OK to KEY_ENTER as KEY_OK didn't do anything when i pressed OK on the remote but the KEY_ENTER behaves like pressing the return key on your keyboard which is what i wanted.If you're interested you can find KEYCODES and their numerical and human definitions in /usr/include/linux/input.h OR alternatively copy the following into your /lib/udev/rc_keymaps/dib0700_rc5 (first backup your old file):

# table dib0700_rc5, type: RC5
0x1c25 KEY_SELECT
0x1c3d KEY_POWER
0x1c3b KEY_HOME
0x1c1c KEY_TV
0x1c14 KEY_UP
0x1c15 KEY_DOWN
0x1c16 KEY_LEFT
0x1c17 KEY_RIGHT
0x1c25 KEY_ENTER
0x1c1f KEY_EXIT
0x1c0d KEY_MENU
0x1c10 KEY_VOLUMEUP
0x1c11 KEY_VOLUMEDOWN
0x1c12 KEY_PREVIOUS
0x1c0f KEY_MUTE
0x1c20 KEY_CHANNELUP
0x1c21 KEY_CHANNELDOWN
0x1c37 KEY_RECORD
0x1c36 KEY_STOP
0x1c32 KEY_REWIND
0x1c35 KEY_PLAY
0x1c34 KEY_FASTFORWARD
0x1c24 KEY_PREVIOUSSONG
0x1c30 KEY_PAUSE
0x1c1e KEY_NEXTSONG
0x1c01 KEY_1
0x1c02 KEY_2
0x1c03 KEY_3
0x1c04 KEY_4
0x1c05 KEY_5
0x1c06 KEY_6
0x1c07 KEY_7
0x1c08 KEY_8
0x1c09 KEY_9
0x1c0a KEY_TEXT
0x1c00 KEY_0
0x1c0e KEY_SUBTITLE


4.Run ls -l /dev/input/by-path.Mine showed the following:

total 0
lrwxrwxrwx 1 root root 9 Jul 4 21:51 pci-0000:00:1d.0-usb-0:1:1.0-event-mouse -> ../event4
lrwxrwxrwx 1 root root 9 Jul 4 21:51 pci-0000:00:1d.0-usb-0:1:1.0-mouse -> ../mouse0
lrwxrwxrwx 1 root root 9 Jul 4 21:56 pci-0000:00:1d.7-usb-0:2-event-ir -> ../event9
lrwxrwxrwx 1 root root 9 Jul 4 21:51 platform-i8042-serio-0-event-kbd -> ../event3
lrwxrwxrwx 1 root root 9 Jul 4 21:51 platform-i8042-serio-1-event-mouse -> ../event7
lrwxrwxrwx 1 root root 9 Jul 4 21:51 platform-i8042-serio-1-mouse -> ../mouse1
lrwxrwxrwx 1 root root 9 Jul 4 21:51 platform-i8042-serio-2-event-mouse -> ../event8
lrwxrwxrwx 1 root root 9 Jul 4 21:51 platform-i8042-serio-2-mouse -> ../mouse2
lrwxrwxrwx 1 root root 9 Jul 4 21:51 platform-thinkpad_acpi-event -> ../event6

This shows that the IR receiver maps to /dev/input/by-path/pci-0000:00:1d.7-usb-0:2-event-ir which is a link to /dev/input/event9

5.Install lirc (version 0.9.0) package (which also installs irw and irexec),lirc-x package (installs irxevent),and optionally the xautomation package which contains the xte binary which i used in my .lircrc file inorder to scroll up and down and go back in Nautilus filemanager (where back is Alt_Left key combo).Reason i used xte is because i found that irxevent didn't work.

When installing lirc it will open up a configuration window.Select Linux Input Layer (/dev/input/event#) as the remote device,click forward and then select the appropriate /dev/input/by-path for the receiver.This configures the /etc/lirc/hardware.conf and lircd.conf files and starts the lircd daemon (which can be stopped/started anytime afterwards by the command:sudo service lirc start|stop|restart)

Note that you can configure lirc anytime,even after install, by running the command "dpkg-reconfigure lirc"

6.Create your .lircrc file (placed in your home directory) as you deem fit.My samples are as follows:

Code: Select all

#For VLC media player
begin
	prog = vlc
	button = KEY_EXIT
	config = key-quit
end

begin
	prog = vlc
	button = KEY_PLAY
	config = key-play-pause
end

begin
	prog = vlc
	button = KEY_PAUSE
	config = key-play-pause
end

begin
	prog = vlc
	button = KEY_STOP
	config = key-stop
end



begin
	prog = vlc
	button = KEY_NEXT
	config = key-jump+medium
	repeat = 2
end

begin
	prog = vlc
	button = KEY_PREVIOUS
	config = key-jump-medium
	repeat = 2
end

#seek forward
begin
	prog = vlc
	button = KEY_FASTFORWARD
	config = key-jump+short
	repeat = 2
end

#seek backward
begin
	prog = vlc
	button = KEY_REWIND
	config = key-jump-short
	repeat = 2
end

begin
	prog = vlc
	button = KEY_VOLUMEUP
	config = key-vol-up
	repeat = 1
end


begin
	prog = vlc
	button = KEY_VOLUMEDOWN
	config = key-vol-down
	repeat = 1
end



begin
	prog = vlc
	button = KEY_MUTE
	config = key-vol-mute
end

#show time position
begin
	prog = vlc
	button = KEY_INFO
	config = key-position
end


#Toggle fullscreen
begin
	prog = vlc
	button = KEY_GREEN
	config = key-toggle-fullscreen
end

#For KAFFEINE media player:

### Kaffeine (using mce usb remote with its usb IR receiver)
#To find out qdbus commands for Kaffeine run "qdbus org.kde.kaffeine".This will output something like:
#/
#/KBookmarkManager
#/KBookmarkManager/kfilePlaces
#/KDebug
#/KIO
#/KIO/Scheduler
#/MainApplication
#/Player
#/Television
#/TrackList
#/kaffeine
#/kaffeine/MainWindow_1

#then run whatever more specific qdbus commands you want from above interfaces by "qdbus org.kde.kaffeine /<name of #interface>
#E.g: qdbus org.kde.kaffeine /Television OR "qdbus org.kde.kaffeine /Player"

#Use Home button on remote to open kaffeine:
begin
        prog = irexec
        button = KEY_MEDIA
        config = kaffeine
end

begin
        prog = irexec
        button = KEY_EXIT
        config = qdbus org.kde.kaffeine /MainApplication quit
end

begin
        prog = irexec
        button = KEY_PLAY
        config = qdbus org.kde.kaffeine /Player Play
end

begin
        prog = irexec
        button = KEY_PAUSE
        config = qdbus org.kde.kaffeine /Player Pause
end

begin
        prog = irexec
        button = KEY_STOP
        config = qdbus org.kde.kaffeine /Player Stop
end

begin
        prog = irexec
        button = KEY_NEXT
        config = qdbus org.kde.kaffeine /Player LongSkipForward
end

begin
        prog = irexec
        button = KEY_PREVIOUS
        config = qdbus org.kde.kaffeine /Player LongSkipBackward
end

begin
        prog = irexec
        button = KEY_FASTFORWARD
        config = qdbus org.kde.kaffeine /Player ShortSkipForward
end

begin
        prog = irexec
        button = KEY_REWIND
        config = qdbus org.kde.kaffeine /Player ShortSkipBackward
end


begin
        prog = irexec
        button = KEY_VOLUMEUP
        config = qdbus org.kde.kaffeine /Player IncreaseVolume
end



begin
        prog = irexec
        button = KEY_VOLUMEDOWN
        config = qdbus org.kde.kaffeine /Player DecreaseVolume
end


#Toggles onscreen display:
begin
        prog = irexec
        button = KEY_INFO
        config = qdbus org.kde.kaffeine /Television ToggleOsd
end

#Toggles fullscreen
begin
        prog = irexec
        button = KEY_GREEN
        config = qdbus org.kde.kaffeine /Player ToggleFullScreen
end


begin
        prog = irexec
        button = KEY_MUTE
        config = qdbus org.kde.kaffeine /Player ToggleMuted
end



#numeric and channel_change keypresses using xte:
#Taken from:http://hftom.free.fr/phpBB2/viewtopic.php?p=2177&sid=8a6d5d09a0a848aa2e27991670532c7a

 begin
   prog = irexec
   button = KEY_NUMERIC_1
   config = xte 'key 1'
 end

 begin
   prog = irexec
   button = KEY_NUMERIC_2
   config = xte 'key 2'
 end

 begin
   prog = irexec
   button = KEY_NUMERIC_3
   config = xte 'key 3'
 end

 begin
   prog = irexec
   button = KEY_NUMERIC_4
   config = xte 'key 4'
 end

 begin
   prog = irexec
   button = KEY_NUMERIC_5
   config = xte 'key 5'
 end

 begin
   prog = irexec
   button = KEY_NUMERIC_6
   config = xte 'key 6'
 end

 begin
   prog = irexec
   button = KEY_NUMERIC_7
   config = xte 'key 7'
 end

 begin
   prog = irexec
   button = KEY_NUMERIC_8
   config = xte 'key 8'
 end

 begin
   prog = irexec
   button = KEY_NUMERIC_9
   config = xte 'key 9'
 end

 begin
   prog = irexec
   button = KEY_NUMERIC_0
   config = xte 'key 0'
 end 

begin
     prog = irexec
     button = KEY_CHANNELUP
     config = xte 'key Page_Up'
end

begin
     prog = irexec
     button = KEY_CHANNELDOWN
     config = xte 'key Page_Down'
end 





#For xte:
#xte is found in the package xautomation.Useful as an alternative to irxevent when the latter doesn't work.Make sure you run "irexec -d" first


begin
    prog = irexec
    button = KEY_UP
    config = xte 'key Up'
end

begin
    prog = irexec
    button = KEY_DOWN
    config = xte 'key Down'
end

begin
    prog = irexec
    button = KEY_LEFT
    config = xte 'key Left'
end

begin
    prog = irexec
    button = KEY_RIGHT
    config = xte 'key Right'
end

#the following is not necessary if the kernel inputlayer is sending through the KEY_ENTER keycode from the IR #remote.Otherwise you'll get a double press effect of the ENTER key:one press from the kernel and another from xte

begin
    prog = irexec
    button = KEY_ENTER
    config = xte 'key Return'
end


#this keypress in nautilus is equivalent to its alt+Left key combo which causes you to go Back in the filemanager

begin
    prog = irexec
    button = KEY_EXIT
    config = xte "keydown Alt_L" "key Left" "keyup Alt_L"
end


7.Test remote keypresses and see if it works (use irw or another lirc enabled client such as vlc)

NEXT STEP IS OPTIONAL:

In the above setup the scancodes from the IR receiver are mapped to keycodes using the keymap table (ie:in my case using the dib0700_rc5 keymap file in the /lib/udev/rc_keymaps folder).The keycodes are then relayed onto the lircd which hooks into this kernal input layer using the lirc devinput driver.The keycodes are also relayed in parallel onto X via the evdev driver.

evdev is an Xorg input driver for Linux's generic event devices. It therefore supports all input devices that the kernel knows about including most mice and keyboards.The evdev driver configures your input devices, as needed, using HAL (now deprecated;udev preferred) or udev. This allows for the X server to automatically detect the keyboard and mouse you're using for your input devices, and removes the need to specify your devices in xorg.conf. Also, it allows for hot-plugging keyboards, mice and the various devices you might find yourself having to unplug the devices from a running machine and later plugging the devices back into the same running machine.

If you want to prevent keycodes being relayed to X and thereby to prevent X treating your remote as a keyboard and to have them just be received by lircd then you need to configure X to ignore your IR remote receiver.Read this site http://ubuntuforums.org/showthread.php?p=10800958

Firstly you need to create a /etc/xorg.conf file because according to this site http://fedoraproject.org/wiki/Input_dev ... figuration :

"Users are encouraged to put custom configuration into /etc/xorg.conf and leave the /etc/X11/xorg.conf.d directory for configuration snippets provided by the distribution".

Then add the following lines into the /etc/xorg.conf file:

Section "InputClass"
Identifier "evdev keyboard catchall"
Driver "evdev"
MatchProduct "IR-receiver inside an USB DVB receiver"
Option "Ignore" "on"
EndSection

Ofcourse your values for Identifier and MatchProduct may be different to those above

The values for Identifier and MatchProduct are found by running the command :
cat /var/log/Xorg.0.log.

In the ouput i got i saw a section like below:

[ 313.729] (II) config/udev: Adding input device IR-receiver inside an USB DVB receiver (/dev/input/event9)
[ 313.729] (**) IR-receiver inside an USB DVB receiver: Applying InputClass "evdev keyboard catchall"

The MatchProduct value is the bit after config/udev: Adding input device,i.e: "IR-receiver inside an USB DVB receiver" and the Identifier value is the bit after Applying InputClass i.e: "evdev keyboard catchall"

Now if you reboot and test your remote you will find that X no longer treats it as a keyboard and keycodes are only received via lircd
Post Reply

Return to “Tutorials”