Télécommande ATI Remote Wonder 2 sous Debian avec Lirc
J’ai fait l’acquisition il y a quelque temps d’une télécommande ATI Remote Wonder II pour mon pc media center.
Ayant un peu « galéré » pour faire fonctionner cette télécommande sous debian testing, je vais détailler l’installation dans ce billet.
Commençons par installer ce dont nous avons besoin:
sudo apt-get install linux-headers-$(uname -r) lirc lirc-x lirc-modules-source
Laissez la réponse par défaut pour les deux questions qui vous sont posées lors de l’installation.
Cette télécommande ne fonctionne pas avec le module ati_remote2 mais avec le module lirc_atiusb.
Ajoutez ati_remote2
au fichier /etc/modprobe.d/blacklist afin d’empêcher le chargement du module au démarrage et ajoutez lirc_atiusb
dans le fichier /etc/modules afin de charger le bon module.
Pour pouvoir émuler la souris avec la télécommande il faut ajouter les lignes suivantes à votre fichier /etc/X11/xorg.conf:
Section « InputDevice »
Identifier « LIRC-Mouse »
Driver « mouse »
Option « Device » « /dev/lircm »
Option « Protocol » « IntelliMouse »
Option « SendCoreEvents »
Option « Buttons » « 2 »
Option « ZAxisMapping » « 4 5 »
EndSection
Ensuite, toujours dans /etc/X11/xorg.conf, ajoutez InputDevice "LIRC-Mouse"
dans la section ServerLayout
Pour finir éditez le fichier /etc/lirc/lircmd.conf, supprimez toutes les lignes et remplacez les par:
# Protocole utilisé :
PROTOCOL IntelliMouse
# ACCELERATOR start max multiplier
ACCELERATOR 1 30 1
# Bouton | ACCELERATOR 2 30 5utiliser pour activer la souris :
TOGGLE_ACTIVATE * hand
# Maping des directions :
MOVE_N * mouse_up
MOVE_NE * mouse_up_right
MOVE_E * mouse_right
MOVE_SE * mouse_down_right
MOVE_S * mouse_down
MOVE_SW * mouse_down_left
MOVE_W * mouse_left
MOVE_NW * mouse_up_left
# Maping de la molette :
MOVE_IN * up
MOVE_OUT * down
# Maping des clicks :
BUTTON1_CLICK * left_click
BUTTON3_CLICK * right_click
Afin d’obtenir la bonne correspondance entre la touche pressée sur la télécommande et le signal reçu par Lirc il faut éditer le fichier /etc/lirc/lircd.conf et remplacer son contenu par:
begin remote
name ATI_Remote_Wonder_II
bits 24
eps 30
aeps 100
one 0 0
zero 0 0
gap 203970
toggle_bit 0
begin codes
stop 0x000231
pause 0x000230
fforward 0x000228
rec 0x000237
rewind 0x000229
play 0x00022C
d 0x00027B
c 0x00027A
e 0x00027C
f 0x00027D
right 0x00025B
left 0x00025A
up 0x000258
down 0x000259
ok 0x00025C
info 0x0002F9
timer 0x000296
menu 0x000254
check 0x000282
0 0x000200
1 0x000201
2 0x000202
3 0x000203
4 0x000204
5 0x000205
6 0x000206
7 0x000207
8 0x000208
9 0x000209
volup 0x000210
voldown 0x000211
mute 0x00020D
chup 0x000220
chdown 0x000221
mouse_up 0x0001FF
mouse_down 0x0002FF
mouse_left 0x0020FF
mouse_right 0x0010FF
mouse_up_right 0x0011FF
mouse_down_right 0x0012FF
mouse_up_left 0x0021FF
mouse_down_left 0x0022FF
right_click 0x0002AA
left_click 0x0002A9
hand 0x0002D0
shrink_resize 0x0002D5
? 0x0002BE
dvd 0x000238
tv 0x000239
a 0x000278
b 0x000279
power 0x00020C
ATI 0x00028E
end codes
end remote
Assurez vous aussi que le fichier /etc/lirc/hardware.conf contienne bien la ligne: DEVICE="/dev/lirc0"
Afin de vérifier si tout fonctionne, ouvrez un terminal et lancez irw
, puis appuyez sur quelques touches au hasard de la télécommande et assurez vous que le bon nom de touche soit renvoyé dans le terminal.
Vous voila donc (si tout va bien) avec une télécommande fonctionnelle.
Le seul petit « hic » c’est que pour l’instant les différents daemons utilisés par Lirc sont lancés avec les droits root, ce qui fait que toutes les applications lancées avec la télécommande le seront avec les droits root …
Pour palier à ce problème nous allons remplacer le fichier /etc/init.d/lirc
créé lors de l’installation par celui ci:
#! /bin/sh
### BEGIN INIT INFO
# Provides: lirc
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts LIRC daemon.
# Description: LIRC is used to control different
# infrared receivers and transceivers.
### END INIT INFOUSER=k
load_modules ()
{
MODULES_MISSING=falsefor mod in $*
do
modprobe $mod 2> /dev/null || MODULES_MISSING=true
doneif [ « $MODULES_MISSING » = true ]; then
echo « ##################################################### »
echo « ## I couldn’t load the required kernel modules ## »
echo « ## You should install lirc-modules-source to build ## »
echo « ## kernel support for your hardware. ## »
echo « ##################################################### »
echo « ## If this message is not appropriate you may set ## »
echo « ## LOAD_MODULES=false in /etc/lirc/hardware.conf ## »
echo « ##################################################### »
START_LIRCMD=false
START_LIRCD=false
fiunset -v MODULES_MISSING
# avoid a hard dependency or a flag day between udev versions
if [ -x /sbin/udevadm ]; then
# udev >= 0.117
udevadm settle || echo « timeout waiting for devices to be ready »
elif [ -x /sbin/udevsettle ]; then
# udev < 0.117
udevsettle || echo « timeout waiting for devices to be ready »
fi
}
build_args ()
{
ARGS= »$* »## Try to find an lirc device.
## udev uses /dev/lirc0
## static dev uses /dev/lirc
if [ -z « $DEVICE » ]; then
for dev in /dev/lirc0 /dev/lirc; do
if [ -c $dev ]; then
DEVICE= »$dev »
break
fi
done
fiif [ -n « $DEVICE » ] && [ « $DEVICE » != « none » ]; then
ARGS= »–device=$DEVICE $ARGS »
fi
if [ -n « $DRIVER » ] && [ « $DRIVER » != « none » ]; then
ARGS= »–driver=$DRIVER $ARGS »
fi
echo $ARGSunset -v ARGS
}test -f /usr/sbin/lircd || exit 0
test -f /usr/sbin/lircmd || exit 0
#test -f /etc/lirc/lircd.conf || exit 0
#test -f /etc/lirc/lircmd.conf || exit 0START_LIRCMD=true
START_LIRCD=true
START_IREXEC=true
START_IRXEVENT=true
if [ ! -f /etc/lirc/lircd.conf ] \
|| grep -q « ^#UNCONFIGURED » /etc/lirc/lircd.conf \
|| [ ! -f /etc/lirc/hardware.conf ] \
|| grep -qE « ^DRIVER=.UNCONFIGURED. » /etc/lirc/hardware.conf; then
if [ « $1 » = « start » ]; then
echo « ################################################## »
echo « ## LIRC IS NOT CONFIGURED ## »
echo « ## ## »
echo « ## read /usr/share/doc/lirc/html/configure.html ## »
echo « ################################################## »
echo « Additional hint: Either /etc/lirc/lircd.conf or »
echo » /etc/lirc/hardware.conf doesn’t exist or either »
echo » of the two has the string UNCONFIGURED in it at »
echo » some important place. Try: ‘dpkg-reconfigure lirc' »
fi
START_LIRCD=false
START_LIRCMD=false
START_IREXEC=true
fi
if [ ! -f /etc/lirc/lircmd.conf ] \
|| grep -q « ^#UNCONFIGURED » /etc/lirc/lircmd.conf; then
START_LIRCMD=false
fiif [ ! -f /home/k/.lircrc ] \
|| grep -q « ^#UNCONFIGURED » /home/k/.lircrc; then
START_IREXEC=false
fiif [ -f /etc/lirc/hardware.conf ]; then
. /etc/lirc/hardware.conf
ficase « $1 » in
start)
if [ « $LOAD_MODULES » = « true » ] && [ « $START_LIRCD » = « true » ]; then
load_modules $MODULES
fi
echo -n « Starting lirc daemon: »
if [ « $START_LIRCD » = « true » ]; then
echo -n » lircd »
LIRCD_ARGS=`build_args $LIRCD_ARGS`
start-stop-daemon –start –quiet –exec /usr/sbin/lircd — $LIRCD_ARGS \
< /dev/null
fi
if [ « $START_LIRCMD » = « true » ]; then
echo -n » lircmd »
start-stop-daemon –start –quiet –exec /usr/sbin/lircmd \
< /dev/null
fi
if [ « $START_IREXEC » = « true » ]; then
echo -n » irexec »
start-stop-daemon –start -c $USER –quiet –exec /usr/bin/irexec — -d /home/k/.lircrc \
< /dev/null
fi
if [ « $START_IRXEVENT » = « true » ]; then
echo -n » irxevent »
start-stop-daemon –start -c $USER –quiet –exec /usr/bin/irxevent — -d \
< /dev/null
fi
echo « . »
;;
stop)
echo -n « Stopping lirc daemon: »
echo -n » irexec »
start-stop-daemon –stop –quiet –exec /usr/bin/irexec
echo -n » lircmd »
start-stop-daemon –stop –quiet –exec /usr/sbin/lircmd
echo -n » lircd »
start-stop-daemon –stop –quiet –exec /usr/sbin/lircd
echo -n » irxevent »
start-stop-daemon –stop –quiet –exec /usr/bin/irxevent
echo « . »
;;
reload|force-reload)
if [ « $START_IREXEC » = « true » ]; then
start-stop-daemon –stop –quiet –signal 1 –exec /usr/bin/irexec
fi
if [ « $START_LIRCD » = « true » ]; then
start-stop-daemon –stop –quiet –signal 1 –exec /usr/sbin/lircd
fi
if [ « $START_LIRCMD » = « true » ]; then
start-stop-daemon –stop –quiet –signal 1 –exec /usr/sbin/lircmd
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo « Usage: /etc/init.d/lircd {start|stop|reload|restart|force-reload} »
exit 1
esacexit 0
N’oubliez pas de remplacer k par votre nom d’utilisateur à la ligne 12 …
Nous allons maintenant pouvoir passer à la configuration des actions de la télécommande.
Pour cela nous allons créer un fichier .lircrc
que vous placerez dans votre home.
C’est ce fichier qui va permettre d’associer une action à une touche de la télécommande.
Voici pour exemple mon fichier .lircrc
:
begin
prog = irexec
button = ?
config = eject
config = eject -t
repeat = 0
endbegin
prog = irexec
button = info
config = sudo /sbin/shutdown -h now
repeat = 0
endbegin
prog = irexec
button = timer
config = if [ $(ps -eo cmd | grep -c gshutdown$) -eq 0 ]; then (gshutdown &); fi
repeat = 1
endbegin
prog = irexec
button = tv
config = if [ $(ps -eo cmd | grep -c ^vlc) -eq 0 ]; then (vlc « http://mafreebox.freebox.fr/freeboxtv/playlist.m3u » –control lirc -I skins2 &); fi
mode = vlc
endbegin
prog = irexec
button = hand
config = if [ $(ps -eo cmd | grep -c /usr/bin/elisa$) -eq 0 ]; then (elisa &); fi
mode = elisa
endbegin
prog = irexec
button = dvd
config = if [ $(ps -eo cmd | grep -c ^./xbmc.bin$) -eq 0 ]; then (/home/k/scripts/xbmc.sh &); fi
end# Chiffres
begin
prog = irxevent
button = 1
config = Key SHIFT-1 CurrentWindow
endbegin
prog = irxevent
button = 2
config = Key SHIFT-2 CurrentWindow
endbegin
prog = irxevent
button = 3
config = Key SHIFT-3 CurrentWindow
endbegin
prog = irxevent
button = 4
config = Key SHIFT-4 CurrentWindow
endbegin
prog = irxevent
button = 5
config = Key SHIFT-5 CurrentWindow
endbegin
prog = irxevent
button = 6
config = Key SHIFT-6 CurrentWindow
endbegin
prog = irxevent
button = 7
config = Key SHIFT-7 CurrentWindow
endbegin
prog = irxevent
button = 8
config = Key SHIFT-8 CurrentWindow
endbegin
prog = irxevent
button = 9
config = Key SHIFT-9 CurrentWindow
endbegin
prog = irxevent
button = 0
config = Key SHIFT-0 CurrentWindow
endinclude ~/.lircrc.vlc
include ~/.lircrc.elisa
Les fichiers de configuration spécifiques à chaque logiciel sont appelés par la commande include
placée à la fin du fichier.
Voici pour exemple mon fichier .lircrc.vlc:
begin vlc
begin
prog = vlc
button = Play
config = key-play-pause
endbegin
prog = vlc
button = Pause
config = key-pause
endbegin
prog = vlc
button = Stop
config = key-stop
endbegin
prog = vlc
button = Power
config = key-quit
endbegin
prog = vlc
button = chup
config = key-next
endbegin
prog = vlc
button = chdown
config = key-prev
endbegin
prog = vlc
button = shrink_resize
config = key-fullscreen
end#Audio controls
begin
prog = vlc
button = voldown
config = key-vol-down
endbegin
prog = vlc
button = Volup
config = key-vol-up
endbegin
prog = vlc
button = Mute
config = key-vol-mute
end#For dvd navigation
begin
prog = vlc
button = Menu
config = key-disc-menu
endbegin
prog = vlc
button = 4
config = key-nav-left
endbegin
prog = vlc
button = 5
config = key-nav-down
endbegin
prog = vlc
button = 2
config = key-nav-up
endbegin
prog = vlc
button = 6
config = key-nav-right
endbegin
prog = vlc
button = Up
config = key-nav-activate
endbegin
prog = vlc
button = 9
config = key-subtitle-track
end
end vlc
Par défaut l’option de controle par Lirc est désactivé dans VLC, il vous faudra l’activer: vlc → Settings → Interface → Control Interfaces et cocher Infrared remote control interface
.
A vous de jouer et amusez vous bien =)
Commentaires récents