「LIRC」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(序文を更新)
(→‎設定: 最新の英語版に差し替え)
19行目: 19行目:
 
{{Pkg|lirc}} パッケージを[[インストール]]してください。
 
{{Pkg|lirc}} パッケージを[[インストール]]してください。
   
==設定==
+
== 設定 ==
   
  +
=== Receiver and transmitter configuration ===
{{Note|このセクションでは簡単な説明だけを行います。完全なドキュメントは [http://lirc.sourceforge.net/lirc.org/html/index.html 開発元のホームページ] を参照してください。}}
 
   
  +
{{Note|This section is a quick summary. Complete documentation is available [https://lirc.sourceforge.net/lirc.org/html/index.html upstream].}}
{{ic|/etc/lirc/lircd.conf.d/foo.conf}} はスキャンコードをキーに変換する全ユーザー共通の設定ファイルです。ディレクトリには複数の conf ファイルを保存することができ、それぞれのファイルが各々のリモコン・レシーバに対応します。これらのファイルはユーザーが作成するファイルであり、{{Pkg|lirc}} パッケージに初めから用意されているわけではありません。
 
   
  +
The ''driver'' and/or the ''device'' for the LIRC service may need to be specified in order to run properly. Look for messages like these in the [[journalctl]] output if the service abruptly stops while running LIRC-dependent programs such as ''irrecord'':
LIRC でリモコンを管理するにはスキャンコードからキーマップに変換する定義が必要です。定義情報を入手する方法は2つ存在します。
 
   
  +
Driver `devinput' not found or not loadable (wrong or missing -U/--plugindir?).
==== 上流の設定ファイル ====
 
  +
readlink() failed for "auto": No such file or directory
   
  +
Set these in the configuration file and then restart the service.
使用するリモコン・レシーバを確認して、既に設定ファイルが存在しないか確認してください。{{ic|irdb-get}} を使うことで [http://lirc-remotes.sourceforge.net/remotes-table.html リモコンデータベース] を検索するか URL をブラウザで開いて手動で検索してください。
 
   
  +
{{hc|/etc/lirc/lirc_options.conf|2=
例えば {{ic|irdb-get}} を使って Streamzap 製のリモコンの設定ファイルを検索・入手するには:
 
  +
[lircd]
  +
driver = ''driver-name''
  +
device = /dev/''path-to-dev''
  +
}}
   
  +
==== Serial port ====
$ irdb-get find stream
 
atiusb/atiusb.lircd.conf
 
digital_stream/DTX9900.lircd.conf
 
snapstream/Firefly-Mini.lircd.conf
 
streamzap/PC_Remote.lircd.conf
 
streamzap/streamzap.lircd.conf
 
x10/atiusb.lircd.conf
 
 
$ irdb-get download streamzap/streamzap.lircd.conf
 
Downloaded sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/streamzap/streamzap.lircd.conf as streamzap.lircd.conf
 
   
  +
{{Tip|For DIY schematic refer to serial port [https://www.lirc.org/receivers.html receivers] and [https://www.lirc.org/transmitters.html transmitters] documentation. Note that serial port device much more reliable than ''audio_alsa'' or ''audio''.}}
必要なファイルを {{ic|/etc/lirc/lircd.conf.d/}} にコピーすることでデーモンによってリモコンのサポートが初期化されます:
 
  +
  +
Modern kernel has ''serial_ir'' module, which supersedes older ''lirc_serial'' driver. It supports even DIY receivers and transmitters, connected to the motherboard's serial port. Install {{AUR|setserial}} and run:
  +
  +
# setserial /dev/ttyS0 uart none
  +
# modprobe serial_ir
  +
  +
After loading ''serial_ir'' module, device {{ic|/dev/lirc0}} will be [https://github.com/torvalds/linux/blob/master/drivers/media/rc/serial_ir.c created] by kernel. If not, check the [[journal]] for any relevant errors. An LIRC configuration example for serial device:
  +
  +
{{hc|/etc/lirc/lirc_options.conf|2=
  +
[lircd]
  +
driver = default
  +
device = auto
  +
  +
[modinit]
  +
code = /usr/bin/setserial /dev/ttyS0 uart none
  +
code1 = /usr/sbin/modprobe serial_ir
  +
}}
  +
  +
==== Sound card ====
  +
  +
{{Note|Using sound card as infrared device has plenty pitfalls and does not gives advantage over other hardware setup.}}
  +
  +
Sound card with connected external DIY circuits can be used to [https://www.lirc.org/ir-audio.html receive] and [https://web.archive.org/web/20150511192459/http://www.lirc.org:80/html/audio.html transmit] IR codes.
  +
  +
''audio_alsa'' [https://www.lirc.org/html/audio-alsa.html driver] included in {{pkg|lirc}}, but supports only reception.
  +
  +
Unmute microphone input with {{ic|alsamixer}} and set enough gain. You can check waveform and gain with {{pkg|audacity}}. There should be distinguishable square pulses: not flatlined, nor overloaded. Also good demodulated pulses easily perceptible by ear. Note that LIRC and {{ic|irrecord}} reads ''positive pulses in right audio channel''. Negative pulses will not work.
  +
  +
{{hc|/etc/lirc/lirc_options.conf|2=
  +
driver = audio_alsa
  +
device = default
  +
}}
  +
  +
''audio'' [https://web.archive.org/web/20150511192459/http://www.lirc.org:80/html/audio.html driver] included in {{AUR|lirc-git}} and supports both reception and transmission. Note, that default latency around 0.02 can cause "Warning: Output underflow" and corrupted transmission - receiver will not respond to it. Try a higher value like 0.05.
  +
  +
Increase sound card output loudness, otherwise LED signal will be weak and range is low. LED flash can be detected with smartphone camera, as it sensitive to infrared wavelengths.
  +
  +
{{hc|/etc/lirc/lirc_options.conf|2=
  +
driver = audio
  +
device = ALSA:default@48000:0.05
  +
}}
  +
  +
=== Remote configuration ===
  +
  +
Directory {{ic|/etc/lirc/lircd.conf.d/}} contains system-wide configuration files for remotes. Each ''*.conf'' file corresponds to one device and describes its protocol, scancodes and keycodes. It allows LIRC receive and send signals for specific hardware. These files are not included in {{Pkg|lirc}} package and should be found somewhere or created by user.
  +
  +
==== Searching for remote configuration ====
  +
  +
Plenty of configuration files can be found in the [http://lirc-remotes.sourceforge.net/remotes-table.html LIRC remotes database]. Follow the url or use {{man|1|irdb-get}} to search the database.
  +
  +
An example using {{ic|irdb-get}} to find a configuration file for a "Streamzap" remote:
  +
  +
{{hc|$ irdb-get find stream|
  +
atiusb/atiusb.lircd.conf
  +
digital_stream/DTX9900.lircd.conf
  +
snapstream/Firefly-Mini.lircd.conf
  +
streamzap/PC_Remote.lircd.conf
  +
streamzap/streamzap.lircd.conf
  +
x10/atiusb.lircd.conf
  +
}}
  +
  +
{{hc|$ irdb-get download streamzap/streamzap.lircd.conf|
  +
Downloaded sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/streamzap/streamzap.lircd.conf as streamzap.lircd.conf
  +
}}
  +
  +
Once identified, copy the needed ''.conf'' to {{ic|/etc/lirc/lircd.conf.d/}} to allow the daemon to initialize support for it.
   
 
# cp streamzap.lircd.conf /etc/lirc/lircd.conf.d/
 
# cp streamzap.lircd.conf /etc/lirc/lircd.conf.d/
   
  +
==== Creating remote configuration ====
==== ユーザーが作成した設定ファイル ====
 
  +
サポートされていないハードウェアを使用する場合、誰かが作った設定ファイルを (google) 検索するか自分で作成する必要があります。設定ファイルは {{ic|/usr/bin/irrecord}} を使うことでガイドに従ってとても簡単に作成することができます。使用するリモコンが認識されている場合、以下のように起動してください:
 
  +
Remote control configurations can be created using {{man|1|irrecord}}, which guides users trough the process. If using a detected remote, invoke it like so:
   
 
# irrecord --device=/dev/lirc0 MyRemote
 
# irrecord --device=/dev/lirc0 MyRemote
   
  +
The program will instruct user to begin hitting keys on the remote in an attempt to learn it, ultimately mapping out every button and its corresponding scancode. When finished, save the resulting file to {{ic|/etc/lirc/lircd.conf.d/foo.conf}} and proceed. Consider sharing configuration file with others.
プログラムを実行するとリモコンのボタンを押して学習させるように指示されます。最終的には全てのボタンとスキャンコードがマッピングされます。全ての操作に10分もかからないはずです。マッピングが完了したら {{ic|/etc/lirc/lircd.conf.d/foo.conf}} にファイルが保存されます。
 
  +
  +
=== Application-specific actions ===
  +
  +
{{Tip|Many application-specific lircrc files are available on the internet.}}
  +
Bind keycodes to application-specific actions by placing their respective configuration files in {{ic|~/.config/lircrc/}} which should be created manually if desired, see {{man|5|lircrc}}. This only works for LIRC-aware applications, like [[MPlayer]], [[VLC]], [[MythTV]] and {{Pkg|totem}} ([[Kodi]] also supports LIRC but does so in a non-standard way, see [[Kodi#Using a remote control]]).
  +
  +
Define these application-specific configurations in separate files and include them in ''lircrc'', like:
  +
  +
include "~/.config/lircrc/mplayer"
  +
include "~/.config/lircrc/mythtv"
  +
include "~/.config/lircrc/vlc"
  +
  +
=== Running as a regular user ===
  +
  +
By default, ''lircd'' runs as root. For increased stability and security, upstream recommends running it as a regular user. See Appendix 14 at [https://www.lirc.org/html/configuration-guide.html this] link.
   
  +
==== User the AUR package for lirc-user-service ====
{{Note|プログラムに記述されているメールアドレスに作成された設定ファイルを送ることで、あなたが作った設定ファイルを他の人も使えるようになります。}}
 
   
  +
{{AUR|lirc-user-service}} is offered which does everything automatically.
=== 任意のファイル ===
 
LIRC を使用するアプリケーションの中には一部、以下のファイルを使うものがあります。例えば {{Pkg|mplayer}} や {{AUR|mythtv}} は以下のファイルを使ってキーマップやアクションを定義します。全てのアプリケーションが必要とするわけではありません。例として {{Pkg|kodi}} は固有の xml ファイルを使ってマッピングを行います。詳しくは各アプリケーションのドキュメントを参照してください。
 
* {{ic|~/.lircrc}} - プログラムごとの lirc マップ ({{ic|~/.lirc/foo}} や {{ic|~/.lirc/bar}} など) を指定する ''include'' ステートメントを記述するファイル。
 
* {{ic|~/.lirc/foo}} - ユーザー個別にキーを操作に翻訳する設定。各リモコンとアプリケーション foo の固有設定。
 
   
 
== リモコンのテスト ==
 
== リモコンのテスト ==

2024年2月25日 (日) 22:17時点における版

official website から:

LIRC (Linux 赤外線リモコン) は、一般的に使用される多くの (すべてではない) リモコンの赤外線信号をデコードして送信するパッケージです。
ノート: 4.18 以降、カーネルは BPF を使用して一部の IR リモコンの信号をデコードできるため、LIRC が重複する場合があります。[1]

この記事ではシリアル・USB 赤外線デバイスを使って LIRC "Linux Infrared Remote Control" を設定・使用する方法を説明しています。

LIRC はサポートしているリモコンのキーが押されたときにプログラムにあわせて特定のコマンドに変換することができるデーモンです。ここで、「プログラムにあわせて」とは同じキーでも実行しているプログラムによって異なる動作をさせることができることを意味します。LIRC から取得されたリモコンの情報は以下のようにプログラムに流れます:

  1. ユーザーがリモコンのボタンを押すことで IR または RF 信号が送信されます。
  2. Linux パソコンに接続されたレシーバーによって信号が受信されます。
  3. カーネル (のモジュール) によってリモコンから送信されたパルス信号が /dev/lirc0, /dev/input/eventX, /dev/ttyUSBX, /dev/ttyS0 などのデバイスに変換されます。
  4. /usr/bin/lircd/etc/lirc/lircd.conf.d/foo.conf の情報を使ってパルス信号をボタンの押下情報に変換します。
  5. LIRC を使用するプログラムは ~/.lircrc に書かれている情報に従って /usr/bin/lircd のボタン押下情報をユーザーが定義した操作に解釈します。

インストール

lirc パッケージをインストールしてください。

設定

Receiver and transmitter configuration

ノート: This section is a quick summary. Complete documentation is available upstream.

The driver and/or the device for the LIRC service may need to be specified in order to run properly. Look for messages like these in the journalctl output if the service abruptly stops while running LIRC-dependent programs such as irrecord:

Driver `devinput' not found or not loadable (wrong or missing -U/--plugindir?).
readlink() failed for "auto": No such file or directory

Set these in the configuration file and then restart the service.

/etc/lirc/lirc_options.conf
[lircd]
driver = driver-name
device = /dev/path-to-dev

Serial port

ヒント: For DIY schematic refer to serial port receivers and transmitters documentation. Note that serial port device much more reliable than audio_alsa or audio.

Modern kernel has serial_ir module, which supersedes older lirc_serial driver. It supports even DIY receivers and transmitters, connected to the motherboard's serial port. Install setserialAUR and run:

# setserial /dev/ttyS0 uart none
# modprobe serial_ir

After loading serial_ir module, device /dev/lirc0 will be created by kernel. If not, check the journal for any relevant errors. An LIRC configuration example for serial device:

/etc/lirc/lirc_options.conf
[lircd]
driver          = default
device          = auto

[modinit]
code = /usr/bin/setserial /dev/ttyS0 uart none
code1 = /usr/sbin/modprobe serial_ir

Sound card

ノート: Using sound card as infrared device has plenty pitfalls and does not gives advantage over other hardware setup.

Sound card with connected external DIY circuits can be used to receive and transmit IR codes.

audio_alsa driver included in lirc, but supports only reception.

Unmute microphone input with alsamixer and set enough gain. You can check waveform and gain with audacity. There should be distinguishable square pulses: not flatlined, nor overloaded. Also good demodulated pulses easily perceptible by ear. Note that LIRC and irrecord reads positive pulses in right audio channel. Negative pulses will not work.

/etc/lirc/lirc_options.conf
driver          = audio_alsa
device          = default

audio driver included in lirc-gitAUR and supports both reception and transmission. Note, that default latency around 0.02 can cause "Warning: Output underflow" and corrupted transmission - receiver will not respond to it. Try a higher value like 0.05.

Increase sound card output loudness, otherwise LED signal will be weak and range is low. LED flash can be detected with smartphone camera, as it sensitive to infrared wavelengths.

/etc/lirc/lirc_options.conf
driver          = audio
device          = ALSA:default@48000:0.05

Remote configuration

Directory /etc/lirc/lircd.conf.d/ contains system-wide configuration files for remotes. Each *.conf file corresponds to one device and describes its protocol, scancodes and keycodes. It allows LIRC receive and send signals for specific hardware. These files are not included in lirc package and should be found somewhere or created by user.

Searching for remote configuration

Plenty of configuration files can be found in the LIRC remotes database. Follow the url or use irdb-get(1) to search the database.

An example using irdb-get to find a configuration file for a "Streamzap" remote:

$ irdb-get find stream
atiusb/atiusb.lircd.conf
digital_stream/DTX9900.lircd.conf
snapstream/Firefly-Mini.lircd.conf
streamzap/PC_Remote.lircd.conf
streamzap/streamzap.lircd.conf
x10/atiusb.lircd.conf
$ irdb-get download streamzap/streamzap.lircd.conf
Downloaded sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/streamzap/streamzap.lircd.conf as streamzap.lircd.conf

Once identified, copy the needed .conf to /etc/lirc/lircd.conf.d/ to allow the daemon to initialize support for it.

# cp streamzap.lircd.conf /etc/lirc/lircd.conf.d/

Creating remote configuration

Remote control configurations can be created using irrecord(1), which guides users trough the process. If using a detected remote, invoke it like so:

# irrecord --device=/dev/lirc0 MyRemote

The program will instruct user to begin hitting keys on the remote in an attempt to learn it, ultimately mapping out every button and its corresponding scancode. When finished, save the resulting file to /etc/lirc/lircd.conf.d/foo.conf and proceed. Consider sharing configuration file with others.

Application-specific actions

ヒント: Many application-specific lircrc files are available on the internet.

Bind keycodes to application-specific actions by placing their respective configuration files in ~/.config/lircrc/ which should be created manually if desired, see lircrc(5). This only works for LIRC-aware applications, like MPlayer, VLC, MythTV and totem (Kodi also supports LIRC but does so in a non-standard way, see Kodi#Using a remote control).

Define these application-specific configurations in separate files and include them in lircrc, like:

include "~/.config/lircrc/mplayer"
include "~/.config/lircrc/mythtv"
include "~/.config/lircrc/vlc"

Running as a regular user

By default, lircd runs as root. For increased stability and security, upstream recommends running it as a regular user. See Appendix 14 at this link.

User the AUR package for lirc-user-service

lirc-user-serviceAUR is offered which does everything automatically.

リモコンのテスト

lircd.service起動してブート/シャットダウン時に実行されるように有効化してください (強く推奨)。

/usr/bin/irw を使ってリモコンをテストしてください、リモコンのボタンを押した時に LIRC が受信したものを全て標準出力に流します。

例:

$ irw
000000037ff07bfe 00 One mceusb
000000037ff07bfd 00 Two mceusb
000000037ff07bfd 01 Two mceusb
000000037ff07bf2 00 Home mceusb
000000037ff07bf2 01 Home mceusb

このコマンドが動作しない場合 (irw が何も出力をしない): /etc/lirc/lircd.conf.d/ 内の config ファイルに間違いがないかよく確認してください。

プログラムごとの設定

LIRC では同じキーでもプログラムごとに別々のコマンドになるように設定することができます。つまり、特定のキーを押した時に mplayer と vlc で挙動を変えられます。

まずは LIRC のコマンドを使用するプログラムを決めてください。一般的なプログラムの例: mplayer, mythtvAUR, totem, vlc, kodi

ノート: Kodi は非標準的な方法で LIRC を実装しています。他のプログラムが使用する LIRC の標準ファイルではなく、特別な xml ファイルである ~/.xbmc/userdata/Lircmap.xml を編集する必要があります。Kodi を使用するユーザーは Kodi#リモートコントロールの使用の記事を読んでください。

プログラム固有のマッピングを指定するファイルを作成してください:

$ mkdir ~/.lirc
$ touch ~/.lircrc

~/.lirc に各プログラムの名前が付いた設定ファイルを作成してください。例:

$ ls ~/.lirc
mplayer
mythtv
vlc
ヒント: Google で検索すれば様々なリモコン・プログラム固有のファイルが山ほど出てきます。この記事では各プログラムのキーマップについては扱いません。

~/.lircrc を編集して LIRC でコントロールするプログラムの数だけ ~/.lirc/foo を指定する include ステートメントを記述してください。例:

~/.lircrc
include "~/.lirc/mplayer"
include "~/.lirc/mythtv"
include "~/.lirc/vlc"

トラブルシューティング

リモコンがキーボードとして機能する

Xorg を使用している場合

Streamzap USB PC Remote など、リモコンによっては Xorg によって Human Interface Device (HID) と認識されるものがあり、物理キーボードからの入力のようにキーの一部または全てがキーストロークとして認識されます。この挙動は LIRC でデバイスを管理しようとしたときに問題になります。無効にするには、以下のファイルを作成して X を再起動してください:

/etc/X11/xorg.conf.d/90-streamzap.conf
Section "InputClass"
  Identifier "Ignore Streamzap IR"
  MatchProduct "Streamzap"
  MatchIsKeyboard "true"
  Option "Ignore" "true"
EndSection

次のコマンドで得られる出力の Name に合わせて MatchProduct は適切に変更するようにしてください:

$ cat /proc/bus/input/devices | grep -e IR

例えば N: Name="cx88 IR (WinFast DTV2000 H rev." の場合 WinFast にします。

ARM デバイスで Xorg を使用していない場合

/etc/modprobed.d/streamzap.conf を作成して問題を起こすモジュールをブラックリストに追加してください。例えば Streamzap のリモコンの場合:

install ir_sharp_decoder /bin/false
install ir_xmp_decoder /bin/false
install ir_rc5_decoder /bin/false
install ir_nec_decoder /bin/false
install ir_sony_decoder /bin/false
install ir_mce_kbd_decoder /bin/false
install ir_jvc_decoder /bin/false
install ir_rc6_decoder /bin/false
install ir_sanyo_decoder /bin/false

デフォルト設定を変更する

irw で何も出力されない場合、/etc/lirc/lirc_options.conf のデフォルト設定が原因である可能性があります (あるいはアップデートによって上書きされた可能性もあります)。

まず、/dev/lirc0 が存在するかどうか確認してください:

$ mode2 --driver default --device /dev/lirc0

リモコンのボタンを押してみて何か出力されないか確認してください。出力がある場合、/etc/lirc/lirc_options.conf を編集して driverdevice を適当な値に変更してください。

何も出力されない場合、適切なドライバーとデバイスの組み合わせを探します。最初に lirc がデフォルトでどの組み合わせを認識しているのか確認します。v4l-utils パッケージに含まれている ir-keytable を実行して出力を確認してください。以下のように出力されます:

Found /sys/class/rc/rc0/ (/dev/input/event5) with:
      Driver ite-cir, table rc-rc6-mce
      Supported protocols: unknown other lirc rc-5 jvc sony nec sanyo mce-kbd rc-6 sharp xmp
      Enabled protocols: lirc
      Extra capabilities: <access denied>

上記の場合、lirc は /dev/input/event5 を赤外線デバイスとして自動的に認識して、devinput ドライバーが使われています。以下のコマンドを実行することで組み合わせが正しいか確認します:

$ mode2 --driver devinput --device /dev/input/event5

リモコンのボタンを押してみてください。何も出力されない場合、別のドライバーとデバイスの組み合わせを試してみてください。機能する組み合わせを発見したら、/etc/lirc/lirc_options.confdriverdevice を変更してください。

サンプル

MCE RC6 互換レシーバの設定例:

/etc/lirc/lirc_options.conf
[lircd]
nodaemon        = False
driver          = default
device          = /dev/lirc0
output          = /var/run/lirc/lircd
pidfile         = /var/run/lirc/lircd.pid
plugindir       = /usr/lib/lirc/plugins
permission      = 666
allow-simulate  = No
repeat-max      = 600

[lircmd]
uinput          = False
nodaemon        = False

参照