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 0×000231
pause 0×000230
fforward 0×000228
rec 0×000237
rewind 0×000229
play 0×00022C
d 0×00027B
c 0×00027A
e 0×00027C
f 0×00027D
right 0×00025B
left 0×00025A
up 0×000258
down 0×000259
ok 0×00025C
info 0×0002F9
timer 0×000296
menu 0×000254
check 0×000282
0 0×000200
1 0×000201
2 0×000202
3 0×000203
4 0×000204
5 0×000205
6 0×000206
7 0×000207
8 0×000208
9 0×000209
volup 0×000210
voldown 0×000211
mute 0×00020D
chup 0×000220
chdown 0×000221
mouse_up 0×0001FF
mouse_down 0×0002FF
mouse_left 0×0020FF
mouse_right 0×0010FF
mouse_up_right 0×0011FF
mouse_down_right 0×0012FF
mouse_up_left 0×0021FF
mouse_down_left 0×0022FF
right_click 0×0002AA
left_click 0×0002A9
hand 0×0002D0
shrink_resize 0×0002D5
? 0×0002BE
dvd 0×000238
tv 0×000239
a 0×000278
b 0×000279
power 0×00020C
ATI 0×00028E
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