Настраиваем пульт в Calculate Media Center

Так как денег мне жалко на безпроводную мышку и клавиатуру, да и моя любимая мама не будет их использовать потому что ей неудобно (самый веский аргумент), да и не кошерно это, заказал я себе ПДУ usb-шный. Обошелся он мне всего 700 рублей, ну или 17 еврейских рублей.

Для работы большенства современных ПДУ достаточно в make.conf добавить такую строчку и смело собирать lirc.

LIRC_DEVICES="devinput"

xbmc ~ # emerge -av app-misc/lirc

Теперь приступим к настройке этого зверя.

Нам нужно узнать event нашего IR приемника, дабы потом указать его в конфиге. У меня это выглядит так:

xbmc ~ # cat /proc/bus/input/devices
I: Bus=0003 Vendor=1784 Product=0011 Version=0100
N: Name="Media Center Ed. eHome Infrared Remote Transceiver (1784:0011)"
P: Phys=usb-0000:00:1d.0-1.1
S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/rc/rc0/input3
U: Uniq=
H: Handlers=kbd event3 
B: PROP=0
B: EV=100013
B: KEY=fff 0 200108fc326 237605100000000 0 700158000 419200100001 9e968000000000 10000000
B: MSC=10

Создаем конфиг в котором у нас будут такие строки (почему его нет сразу остается для меня загадкой 0_о):

xbmc ~ # nano /etc/lirc/hardware.conf
#Chosen Remote Control
#REMOTE="Linux input layer (/dev/input/eventX)"
 # Arguments which will be used when launching lircd
LIRCD_ARGS=""
#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD=false
#Try to load appropriate kernel modules
LOAD_MODULES=true
 # Run "lircd --driver=help" for a list of supported drivers.
DRIVER="dev/input"
 # If DEVICE is set to /dev/lirc and devfs is in use /dev/lirc/0 will be automatically used instead
DEVICE="/dev/input/eventX" (меняем X на тот event который у нас, у меня это event3)
MODULES="" 
 # Default configuration files for your hardware if any
LIRCD_CONF="/etc/lirc/lircd.conf"
LIRCMD_CONF=""

Вот теперь можно стартовать lirc =)

xbmc ~ # /etc/init.d/lircd start
* Starting lircd ...                                                                        [ ok ]

Вот и славненько, теперь осталось только научить lirc понимать что мы нажимаем, и немного донастроить xbmc под наши нужды.
Для начала конечно стоит посмотреть на официальном сайте lirc (http://lirc.sourceforge.net/remotes/) есть ли там готовый lircd.conf для нашего пульта. Для тех кто в танке конфигурационный файл от одного ПДУ не подойдет к ПДУ другой модели этого же производителя. Так что если готового конфига нет, нужно сделать его ручками. Ну ладно, от слов к действиям.

irrecord --list-namespace

Покажет как можно называть кнопки пульта это я к тому что назвать кнопки xz, enter, neponjatnaja_knopka нельзя. Советую ознакомиться и сделать небольшую заготовку! Если будете долго медитировать на список во время обучения lirc то обучение отключится и придется вводить снова. Вот такой вот незатейливый геморрой, незнаю о чем думал автор lirc но там не так уж и мало названий для кнопок. Радует то, что все в принципе интуитивно понятно, и имея базовые знания буржуйского можно разобраться :slight_smile:

xbmc ~ # irrecord -f --driver=devinput -d /dev/input/event3 /etc/lirc/lircd.conf

У вас другой event, так что не забывайте поменять его на свой =))

irrecord - application for recording IR-codes for usage with lirc
Copyright (C) 1998,1999 Christoph Bartelmus(lirc@bartelmus.de)
irrecord: initializing '/dev/input/event3'
This program will record the signals from your remote control
and create a config file for lircd.
Usually it's not necessary to create a new config file for devinput
devices. A generic config file can be found at:
http://www.lirc.org/remotes/devinput/
You should try this config file before creating your own config file.
A proper config file for lircd is maybe the most vital part of this
package, so you should invest some time to create a working config
file. Although I put a good deal of effort in this program it is often
not possible to automatically recognize all features of a remote
control. Often short-comings of the receiver hardware make it nearly
impossible. If you have problems to create a config file READ THE
DOCUMENTATION of this package, especially section "Adding new remote
controls" for how to get help.
If there already is a remote control of the same brand available at
http://www.lirc.org/remotes/ you might also want to try using such a
remote as a template. The config files already contain all
parameters of the protocol used by remotes of a certain brand and
knowing these parameters makes the job of this program much
easier. There are also template files for the most common protocols
available in the remotes/generic/ directory of the source
distribution of this package. You can use a template files by
providing the path of the file as command line parameter.
Please send the finished config files to <lirc@bartelmus.de> so that I
can make them available to others. Don't forget to put all information
that you can get about the remote control in the header of the file.
Press RETURN to continue.
Hold down an arbitrary button.

Теперь можно беспорядочно нажимать кнопки на пульте, можно нажимать одну кнопку, кому как нравится, пока не появится

Found gap length: 32990
Now enter the names for the buttons.
Please enter the name for the next button (press <ENTER> to finish recording)

Для незнающих буржуйский он просит ввести название для следующей кнопки, ну а потом попросит нажать ее на пульте. Вот так вот настройка кнопок выглядела у меня:

Please enter the name for the next button (press <ENTER> to finish recording)
BTN_0
Now hold down button "BTN_0".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_VOLUMEUP
Now hold down button "KEY_VOLUMEUP".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_VOLUMEDOWN
Now hold down button "KEY_VOLUMEDOWN".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_PLAY
Now hold down button "KEY_PLAY".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_PLAYPAUSE
Now hold down button "KEY_PLAYPAUSE".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_NEXT
Now hold down button "KEY_NEXT".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_LEFT
Now hold down button "KEY_LEFT".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_RIGHT
Now hold down button "KEY_RIGHT".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_UP
Now hold down button "KEY_UP".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_DOWN
Now hold down button "KEY_DOWN".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_ENTER
Now hold down button "KEY_ENTER".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_BACK
Now hold down button "KEY_BACK".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_FASTFORWARD
Now hold down button "KEY_FASTFORWARD".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_REWIND
Now hold down button "KEY_REWIND".

Не показываю полностью что получилось, так как много, да и не нужно, тут просто что бы видеть как это должно выглядеть. Когда кнопочки на пульте закончились просто жмякаем enter.

irrecord: closing '/dev/input/event3'
irrecord: initializing '/dev/input/event3'
irrecord: closing '/dev/input/event3'
Successfully written config file.

Ну вот, настройка lirc закончена, теперь рестартанем его что бы конфигурация для кнопок ПДУ подхватилась lirc’ом.Теперь наш пультик настроен и готов к бою, теперь нужно немного подкорректировать конфигурационный файл xbmc, можно удалить из него все что ненужно, а можно оставить как есть и не заморачиваться.

xbmc ~ # nano /usr/share/xbmc/system/Lircmap.xml
<lircmap>
        <remote device="linux-input-layer">
        <altname>cx23885_remote</altname>
        <altname>devinput</altname>
                <left>KEY_LEFT</left>
                <right>KEY_RIGHT</right>
                <up>KEY_UP</up>
                <down>KEY_DOWN</down>
                <select>KEY_ENTER</select>
                <start>KEY_SELECT</start>
                <back>KEY_EXIT</back>
                <record>KEY_RECORD</record>
                <play>KEY_PLAY</play>
                <pause>KEY_PAUSE</pause>
                <stop>KEY_STOP</stop>
                <forward>KEY_FASTFORWARD</forward>
                <reverse>KEY_REWIND</reverse>
                <volumeplus>KEY_VOLUMEUP</volumeplus>
                <volumeminus>KEY_VOLUMEDOWN</volumeminus>
                <channelplus>KEY_CHANNELUP</channelplus>
                <channelminus>KEY_CHANNELDOWN</channelminus>
                <skipplus>KEY_NEXTSONG</skipplus>
                <skipminus>KEY_PREVIOUSSONG</skipminus>
                <title>KEY_TEXT</title>
                <subtitle>KEY_SUBTITLE</subtitle>
                <mute>KEY_MUTE</mute>
                <power>KEY_POWER</power>
                <myvideo>KEY_VIDEO</myvideo>
                <mymusic>KEY_AUDIO</mymusic>
                <mypictures>KEY_MHP</mypictures>
                <mytv>KEY_TV</mytv>
                <one>KEY_1</one>
                <two>KEY_2</two>
                <three>KEY_3</three>
                <four>KEY_4</four>
                <five>KEY_5</five>
                <six>KEY_6</six>
                <seven>KEY_7</seven>
                <eight>KEY_8</eight>
                <nine>KEY_9</nine>
                <zero>KEY_0</zero>
                <red>KEY_RED</red>
                <green>KEY_GREEN</green>
                <yellow>KEY_YELLOW</yellow>
                <blue>KEY_BLUE</blue>
        </remote>
</lircmap>

Кое какие строчки отсюда я убрал для чистоты, так как у меня их нет, кое что немножко поправил. По дефолту так то все работает, но дефолт это не интересно, если можно настривать, то нужно настраивать :slight_smile: Конфигурационный файл интуитивно понятен.
Ну вот в обшем то и вся настройка CMC для работы с ПДУ.

ПыСы: У кого есть пультики, и кто будет настраивать, было бы неплохо выкладывать готовые lircd.conf и Lircmap.xml указав модель пульта. Кому то поможет настроить без проблем, да и думаю со временем в CMC ваш пультик будет работать из коробки.

молодец! вот это интересно! спасибо за инфо!

Замечательная статья, то что нужно и когда нужно. :slight_smile: Благодарю.

З,Ы,Без слова “кошерно” скоро здороваться не будут. >_@

Хорошая статья, но мучают пару вопросов
# Что будет если подключить 2-а и больше пультов разных моделей, а одной. А если использовать один приемник инсколько пультов, к примеру от ТВ, не верю что не пробовал :wink:
# Если пульт и приемник жестко связанны и на нихне влияют другие устройства, может стоит наделать udev-правил для этих устройств, хотя-бы для своего. И выложить сюда, а там глядишь и на отдельный системный пакет соберется.
# Исходя из предыдущего вопроса - Скорее всего если по событиям udev будет перезагружаться служба при втыкании/вытыкании устройств, не будет ли это “колбасить” службу и не будут ли генериться левые евенты?

Михаил Гагауз писал(а):
“Хорошая статья, но мучают пару вопросов
Что будет если подключить 2-а и больше пультов разных моделей, а одной. А если использовать один приемник инсколько пультов, к примеру от ТВ, не верю что не пробовал ;-)”
Попробовал настроить с пультом от двд плеера проблем нет. Немного поковыряться и думаю можно юзать сразу 2 пульта ) Но у меня резонный вопрос нафига? :slight_smile:

Попробовал настроить с пультом от двд плеера проблем нет.

Это как - можно поподробнее