「全てのマウスボタンを動作させる」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
 
 
(4人の利用者による、間の27版が非表示)
1行目: 1行目:
 
[[Category:マウス]]
 
[[Category:マウス]]
 
[[Category:X サーバー]]
 
[[Category:X サーバー]]
[[en:All Mouse Buttons Working]]
+
[[en:Mouse buttons]]
[[ru:All Mouse Buttons Working]]
+
[[ru:Mouse buttons]]
[[zh-tw:All Mouse Buttons Working]]
+
[[zh-hant:All Mouse Buttons Working]]
  +
{{Related articles start}}
この記事では7つ以上のマウスボタンが付いているマウスを使っているユーザーに全てのボタンを使用する方法を説明します。そうしたマウスは Logitech ([[Logitech_Marble_Mouse|Logitech Marble® Mouse]]) や Microsoft などが製作しています。
 
  +
{{Related|マウスのアクセラレーション}}
  +
{{Related|マウスのポーリングレート}}
  +
{{Related articles end}}
  +
この記事では 3 つ以上のマウスボタンが付いているマウスを設定する方法について説明します。
   
  +
== Xでマウス入力をテストする前提条件 ==
== 要件 ==
 
   
  +
このページでは、[[Wayland]]ではなく、[[Xorg]] ([[Xorg|X Window System]]) を使っていることを前提にしています。
Xorg では {{ic|evdev}} ドライバーを使います。EVentDEVice は USB 入力デバイス用の先進的なドライバーで、Xorg 標準の {{ic|mouse}} ドライバーよりも強力です。また、{{ic|mouse}} ドライバーよりも"ダイレクト"に制御することができ、遅延が抑えられます。
 
   
  +
まず、X があなたのマウスから何を見るかを確認したいと思うでしょう。X のイベントは [[xev]] ユーティリティで表示することができます。実行することでウィンドウがポップアップします。
{{Note|{{Ic|evdev}} はカーネルモジュールであり Xorg インプットドライバーでもあります。全ての Arch カーネルには {{Ic|evdev}} モジュールが付属しています。}}
 
   
  +
$ xev -event button | grep button
Xorg 11R7.0 以降では {{ic|/etc/X11/xorg.conf}} に変更を加えるだけで後の設定は必要ありません。
 
   
  +
そのウィンドウの xevents (移動、サイズ変更、クリックなど) は、''xev'' を起動したコンソールに報告されます。"ボタン" を含む行をフィルタリングしているため、マウスのクリックとリリースのイベントが、関連するボタン番号とともに表示されます。ほとんどのマウスの場合、これは左ボタンの場合は '1'、中央のボタンは '2'、右ボタンの場合は '3' になります。他のボタンは異なります (たとえば、Logicool MX Master 3 の場合、スクロールホイールは 4 と 5、サムホイールは 6 と 7、親指の先のボタンは 9、親指の内側のボタンは 8)
== マウスの名前を確認 ==
 
  +
  +
出力例:
  +
  +
state 0x0, button 1, same_screen YES
  +
state 0x100, button 1, same_screen YES
  +
state 0x0, button 9, same_screen YES
  +
state 0x0, button 9, same_screen YES
  +
  +
これは、マウスの左クリックとリリースに続いて親指の先でクリックとリリースに相当します。
  +
  +
''xev'' を使用すると、マウスボタンの番号を確認し、X にマウスクリックが通知されていることを確認できます。
  +
  +
== マウスとキーボードの機能の再バインド ==
  +
  +
このセクションでは、さまざまなツールを使用してマウスとキーボードの機能を再配置する方法について詳しく説明します。
  +
  +
=== マウスボタンをキーボード機能にバインドする ===
  +
  +
==== xte ====
  +
  +
{{Pkg|xautomation}} の ''xte'' は、キーボードのボタンをマウスにバインドする場合に便利です。
  +
  +
これは、{{ic|Shift_R}} をマウス ボタン 3 ("右クリック") にバインドする {{ic|~/.xbindkeysrc}} の例です:
  +
  +
{{hc|~/.xbindkeysrc|
  +
"xte 'mouseclick 3'"
  +
Shift_R
  +
}}
  +
  +
=== キーボードをマウスボタンにバインド ===
  +
  +
==== xvkbd と xbindkeys ====
  +
  +
マウスボタンをキーボードにバインドしたいとします。問題はキーの押下をエミュレートする方法がわからないということです。そこで {{AUR|xvkbd}} が役に立ちます。{{Pkg|xbindkeys}} と一緒に使うことができます:
  +
  +
$ xbindkeys --defaults >> ~/.xbindkeysrc
  +
$ xbindkeys
  +
  +
xbindkeys を再起動するには以下を実行:
  +
  +
$ pkill -f xbindkeys
  +
$ xbindkeys
  +
  +
{{Ic|~/.xbindkeysrc}} の設定例:
  +
  +
"xvkbd -text "\[F8]""
  +
m:0x0 + b:8
  +
"xvkbd -text "\[Shift]\[Left]""
  +
m:0x0 + b:9
  +
"xvkbd -text "\[Shift]\[Right]""
  +
m:0x0 + b:10
  +
"xvkbd -text 2"
  +
m:0x0 + b:11
  +
"xvkbd -text 3"
  +
m:0x0 + b:12
  +
  +
マウスボタンの番号を確認したいときは xev を使ってください。xvkbd -text では必ず大文字を入力して、括弧開き ([) を \ でエスケープしてください。
  +
  +
以下は xbindkeys で X のセレクションの貼り付け (中クリックのペースト) を有効にする例です。xsel と xvkbd のインストールが必要で、マウスのボタン 13 が押されたときにコマンドを実行します ({{ic|~/.xbindkeysrc}}):
  +
  +
"xvkbd -no-jump-pointer -text "\D1$(xsel)" 2>/dev/null"
  +
b:13
  +
  +
以下は Meta+M のキーバインドの例です:
  +
"xvkbd -text "\{+Super_L}m\{-Super_L}""
  +
b:10
  +
  +
==== evrouter ====
  +
  +
プログラム (特にゲーム) によっては別の方法で入力を読み込むため、もう一つのプログラムが必要になります: {{AUR|evrouter}}。
  +
  +
{{ic|evrouter}} コマンドで入力デバイスを読み込むには、{{ic|input}} グループのユーザー (あるいは root) でコマンドを実行しなければなりません。ユーザーをグループに追加するには:
  +
  +
# gpasswd -a ''user'' input
  +
  +
{{ic|--dump}} オプションを使うことで変更するボタンの名前を表示することができます:
  +
  +
{{Tip|USB デバイスであれば udev は通常 {{ic|/dev/input/by-id/}} にシンボリックリンクを作成するので、それを使って特定のデバイスを指定できます。}}
  +
  +
{{hc|$ evrouter --dump /dev/input/event*|device 0: /dev/input/event0: AT Translated Set 2 keyboard
  +
device 1: /dev/input/event1: Microsoft Microsoft Trackball Explorer®
  +
device 2: /dev/input/event2: Sleep Button
  +
device 3: /dev/input/event3: Power Button
  +
device 4: /dev/input/event4: Power Button
  +
device 5: /dev/input/event5: PC Speaker
  +
Display name: :0.0
  +
}}
  +
  +
それから変更したいボタンを押してください:
  +
  +
Window "(null)": # Window title
  +
# Window "(null)": # Resource name
  +
# Window "(null)": # Class name
  +
"Microsoft Trackball Explorer®" "/dev/input/event1" none key/275 "fill this in!"
  +
  +
Window "(null)": # Window title
  +
# Window "(null)": # Resource name
  +
# Window "(null)": # Class name
  +
"Microsoft Trackball Explorer®" "/dev/input/event1" none key/276 "fill this in!"
  +
  +
文末が "fill this in!" になっている行を設定ファイル (デフォルトでは {{ic|~/.evrouterrc}}) にコピーできます。例えば、evrouter に組み込まれている X11 のキーイベントエミュレータを使用して:
  +
  +
{{hc|~/.evrouterrc|"Microsoft Trackball Explorer®" "/dev/input/event*" any key/275 "XKey/1"
  +
"Microsoft Trackball Explorer®" "/dev/input/event*" any key/276 "XKey/2"}}
  +
  +
起動時に udev が別のデバイス番号を付与した場合を想定して 'event1' は 'event*' に変更してあります。また、'none' を 'any' に変更することで、ボタンが押されたときに修飾キーが押されていても、ルールが適用されるようにしています。フィールドの詳しい説味は {{man|1|evrouter|url=}} を見てください。
  +
  +
{{Tip|ルールは特定のウィンドウだけに適用させることもできます。詳しくは {{man|1|evrouter|url=}} を参照。}}
  +
  +
設定ファイルの作成後、デーモンとして実行:
  +
  +
$ evrouter /dev/input/event*
  +
  +
デーモンを停止するには:
  +
  +
$ evrouter -q
  +
$ rm -f /tmp/.evrouter*
  +
  +
{{Note|{{ic|/tmp/.evrouter:0.0}} ファイルが存在すると {{ic|evrouter}} は起動に失敗します。手動で削除してください。}}
  +
  +
== ユーザーツール ==
  +
  +
このセクションでは、マウス設定、特にボタンの設定に役立つハードウェア固有のツールの概要を説明します。一般的なリマップツールについては、[[入力リマップユーティリティ]] を参照してください。
  +
  +
* [https://github.com/libratbag/piper Piper] ({{Pkg|piper}}) は、ゲーミングマウスを設定するためのグラフィカルユーザーインターフェイスであり、Wayland と連携して動作します。マウスを操作するには、そのマウスが [https://github.com/libratbag/libratbag/tree/master/data/devices サポートされるデバイスのリスト] に含まれている必要があります。
  +
* Logitech MX マウスの {{AUR|lomoco}} は、適切な解像度の設定、スマートスクロールの有効化または無効化 (起動時のサポートも) などに役立ちます。{{ic|/etc/udev/lomoco_mouse.conf}} を開き、[[udev]] によってマウスがロードされたときに自動的に適用されるオプションを設定します。{{Note|lomoco パッケージが古い可能性があります。新しい Logitech マウス用のハックがあります: [http://piie.net/temp/g5_hiddev.c]}}
  +
* {{AUR|logiops}} は、Logicool マウスを設定するためのツール (Logicool Options for Linux) です。ボタンをアクションに再マップしたり、ジェスチャー、スマート シフトなどをサポートしたりできます。
  +
  +
== evdev Xorg.conf のセットアップ ==
  +
  +
このセクションでは、{{ic|evdev}} を使用して 3 つ以上のボタンを備えたマウスをセットアップする方法について説明します。これを実現する方法は他にもありますが、ここで説明するメモやツールの一部は、他のニーズを持つ人にとって役立つかもしれません。一部のパーツは、他のドライバーを使用して追加のマウス ボタンを機能させるのに役立つ場合があります。
  +
  +
Xorg の evdev ドライバーを使用します。EVentDEVice は、標準の Xorg {{ic|mouse}} ドライバーよりもはるかに優れた能力を提供する USB 入力デバイス用の高度なドライバーです。また、{{ic|mouse}} ドライバーよりも ''直接的'' であるため、待ち時間が短くなり、変換の問題も少なくなります。
  +
  +
* {{ic|evdev}} はカーネルモジュールと Xorg 入力ドライバーの両方であることに注意してください。すべての Arch カーネルには、{{ic|evdev}} モジュールが付属しています。
  +
  +
Xorg 11R7.0 以降では、{{ic|/etc/X11/xorg.conf}} に次の変更を加えるだけで済みます。
  +
  +
=== マウスの名前を確認 ===
   
 
{{Note|正確な情報を得るために、Xorg やマウスのドライバーをロードする前にコマンドを実行する必要がある場合もあります。}}
 
{{Note|正確な情報を得るために、Xorg やマウスのドライバーをロードする前にコマンドを実行する必要がある場合もあります。}}
36行目: 179行目:
 
デバイスの名前をコピーしたら、{{ic|/etc/X11/xorg.conf}} を開いて下さい。
 
デバイスの名前をコピーしたら、{{ic|/etc/X11/xorg.conf}} を開いて下さい。
   
== Xorg の設定 ==
+
=== Xorg の設定 ===
   
 
X がマウスを使う方法を設定するため {{ic|xorg.conf}} にエントリを記述します。エントリは以下のようになります:
 
X がマウスを使う方法を設定するため {{ic|xorg.conf}} にエントリを記述します。エントリは以下のようになります:
74行目: 217行目:
 
$ ls /dev/input/by-id/
 
$ ls /dev/input/by-id/
   
== 設定後 ==
+
=== evdev Xorg.conf 設定後 ===
   
=== Google Chrome ===
+
==== Google Chrome ====
   
 
動作します。横スクロールは何も設定しなくても動作します。スクロールホイールを左右に押して下さい。親指ボタンで次/前のページに移動します。
 
動作します。横スクロールは何も設定しなくても動作します。スクロールホイールを左右に押して下さい。親指ボタンで次/前のページに移動します。
   
=== Opera ===
+
==== Opera ====
   
 
動作します。ボタンのマッピングは {{Ic|Preferences > Advanced > Shortcuts > Mouse set-up}} で簡単に変えられます。例えば、''button 8'' を ''back'' にバインドするには:
 
動作します。ボタンのマッピングは {{Ic|Preferences > Advanced > Shortcuts > Mouse set-up}} で簡単に変えられます。例えば、''button 8'' を ''back'' にバインドするには:
88行目: 231行目:
 
# アクションカラムに、次を入力: ''Back''
 
# アクションカラムに、次を入力: ''Back''
   
=== Firefox ===
+
==== Firefox ====
   
==== 横スクロール ====
+
===== 横スクロール =====
   
  +
左と右のスクロールの代わりに、戻ると進むを有効にするには、{{ic|about:config}} で以下の設定を変更します:
=====Firefox 20 以上=====
 
(Tested in version 32)
 
To get back and forward enabled, instead of scroll left/right, change the following settings in {{ic|about:config}}:
 
   
 
mousewheel.default.action.override_x 2
 
mousewheel.default.action.override_x 2
 
mousewheel.default.delta_multiplier_x -100
 
mousewheel.default.delta_multiplier_x -100
   
=====古いバージョ=====
+
==== 親指ボタ - 進むと戻る ====
   
  +
{{Note |以下は、xev がすべてのマウスボタンを正しく検出する (アプリごとに機能をマッピングできる) か、それともデフォルトの動作を変更するかによって、冗長になる可能性があります。}}
By default, left right scroll on a FX/MX mouse translates into back/forward, respectively. If you do not like this, open {{ic|about:config}} and change a few values:
 
   
  +
キーストロークを適当なマウスボタンにマッピングして {{AUR|xvkbd}} と {{Pkg|xbindkeys}} をインストールする必要があります。
mousewheel.horizscroll.withnokey.action 0
 
mousewheel.horizscroll.withnokey.numlines -3
 
   
  +
戻る/進むを使用する最近のアプリケーションでは、デフォルトで XF86Back が戻るに、XF86Forward が進むにマッピングされています。ほとんどの MX マウスでは親指ボタンは 8 や 9 と認識されます。使用しているボタンで番号が異なっている場合、xev を使ってボタンの番号を確認して例で使われている番号を置き換えて下さい (b:8 & b:9)。
OR (tested on Logitech G5)
 
   
  +
MX マウスを使っている場合、以下の内容で {{ic|~/.xbindkeysrc}} ファイルを作成します:
mousewheel.horizscroll.withnokey.action 2
 
mousewheel.horizscroll.withnokey.numlines 2
 
 
NOTE: If you use a positive value for numlines, your left/right will switch, ie: pressing left scrolls the window to the right.
 
 
=== 親指ボタン - 進むと戻る ===
 
 
{{Note | The following maybe redundant depending on whether xev detects all your mouse buttons correctly (functions can be mapped on a per-app basis) or you want to change the default behaviour.}}
 
 
To do this we need to map keystrokes to the desired mouse buttons and install {{Pkg|xvkbd}} and {{Pkg|xbindkeys}}.
 
 
In most modern applications which use back/forward features, XF86Back is mapped to back and XF86Forward is mapped to forward by default. On most MX mice the thumb buttons resolve to 8 & 9. If your mouse is different, check button numbers using xev and replace the numbers used in the example (b:8 & b:9).
 
 
So if you have an MX mouse you would create the file ~/.xbindkeysrc, containing:
 
   
 
# Mouse Buttons
 
# Mouse Buttons
129行目: 256行目:
 
m:0x0 + b:9
 
m:0x0 + b:9
   
  +
次にテストです。以下のコマンドを実行してください。問題ないようでしたら xbindkeys を {{ic|.xinitrc}} など (X が起動するたびに読み込まれるファイル) に追加してください。また、Epiphany や Konqueror では特別な設定をしたり [[Imwheel]] を使用しなくとも機能します。
Now to test... Run the following command and if it works as expected remember to add xbindkeys to {{ic|.xinitrc}} or somewhere where it will be executed each time X starts. Also, this should work with Epiphany and Konqueror without any additional configuration or use of [[Imwheel]].
 
 
xbindkeys
 
xbindkeys
   
 
詳しい情報は [[en2:Logitech MX1000|Logitech MX1000]] にあります。
 
詳しい情報は [[en2:Logitech MX1000|Logitech MX1000]] にあります。
   
=== xmodmap の調整 ===
+
==== xmodmap の調整 ====
   
  +
{{Note |evdev では以下のどれも必要ありませんが、evdev 以外のユーザーのためにここにあります。マウスで問題が発生しない限り、このセクション全体を無視してください。}}
{{Note | None of the below is necessary with evdev, but it's here for non-evdev users. Unless something does not work on your mouse, ignore this whole section!}}
 
   
  +
{{ic|.xinitrc}} を使って X をロードしている場合、以下を {{ic|.xinitrc}} に追加してください (ボタンの数字は必要に応じて変更してください):
If you use .xinitrc to load X, then add this to {{ic|.xinitrc}} (change for the number of buttons you have):
 
xmodmap -e "pointer = 1 2 3 6 7 8 9 10 11 12 4 5" &
+
xmodmap -e "pointer = 1 2 3 6 7 8 9 10 11 12 4 5" &
   
  +
ボタン 4 と 5 は一番最後に置いて下さい。そうしないとスクロールホイールが動作しません。
Note that buttons 4 and 5 '''must go on the end''' or else your scroll wheel will not work.
 
   
  +
{{ic|.xinitrc}} ではなく GDM/XDM/KDM を使っている場合、{{ic|~/.Xmodmap}} ファイルを作成して以下を追加します (ボタンの数字は必要に応じて変更してください):
If you use GDM/XDM/KDM instead of .xinitrc, then create the file {{ic|~/.Xmodmap}} and add this to it (change for the number of buttons you have):
 
pointer = 1 2 3 6 7 8 9 10 11 12 4 5
+
pointer = 1 2 3 6 7 8 9 10 11 12 4 5
   
* GDM/XDM/KDM read the {{ic|~/.Xmodmap}} file if it's present, whereas {{Ic|startx}} does not. Another solution would be to add this to your ~/.xinitrc: {{Ic|xmodmap -e $(cat ~/.Xmodmap)}}. This would allow you to use *DM and {{Ic|startx}} while only having to edit {{ic|~/.Xmodmap}} when you need to make changes.
+
* GDM/XDM/KDM {{ic|~/.Xmodmap}} ファイルが存在すると読み込みますが、{{Ic|startx}} は読み込みません。{{ic|~/.xinitrc}} に次のコマンドを追加して読み込ませることもできます: {{Ic|xmodmap ~/.Xmodmap}}。何か変更が必要になったときに *DM {{Ic|startx}} のどちらを使っている場合でも {{ic|~/.Xmodmap}} を編集すれば良くなります。
   
  +
望み通りの動作をさせるために数字を多少弄る必要があるかもしれません。マウスによってはボタン 6 と 7 がスクロールホイールだったりします。その場合は 6 と 7 を最後の数字にしてください。上手く行くまで弄り続けて下さい。
You may have to play with these numbers a bit to get your desired behavior. Some mice use buttons 6 and 7 for the scroll wheel, in which case those buttons would have to be the last numbers. Keep playing with it until it works!
 
   
  +
Xorg に含まれている 'xev' というプログラムを使ってボタンを確認することもできます。xev を実行すると、デスクトップに小さなボックスが表示されるので、カーソルを合わせてボタンをクリックすることで、ボタンのマッピングがわかります。
You can also check to see which buttons are being read with a program called 'xev', which is part of XOrg. When xev is run, it will show a box on your desktop that you can put the cursor into and click buttons to find out what buttons have been mapped.
 
   
== 方法 ==
+
==== xinput 調整 ====
   
  +
デバッグ時は {{ic|xinput}} を使うことでユーザー空間で即座にボタンマップを変更できます。Logitech M505/B605 マウスの場合の実行例:
The following methods use standard X.org mouse input driver (xf86-input-mouse) instead of using the evdev driver. It works on mice up to 7 buttons. Edit {{ic|/etc/X11/xorg.conf}} InputDevice section for your mouse to reflect the changes shown below. Then restart X and you are done.
 
   
  +
$ xinput set-button-map "$(xinput | awk -F'[=]' '/Logitech M505\/B605/ {print $2}' | awk '{print $1}')" 1 2 3 4 5 8 9
=== IMPS/2 ===
 
 
This has been tested on an IntelliMouse Explorer 3.0. Your mileage may vary, as this does not seem to work for all said mice.
 
 
Driver "mouse"
 
Option "Protocol" "IMPS/2"
 
Option "Device" "/dev/input/mice"
 
Option "ZAxisMapping" "4 5 6 7"
 
 
=== ExplorerPS/2 ===
 
 
This has been tested on a Logitech MX400 and MX518 and should work on any mx series mouse with up to 7 buttons.
 
 
Driver "mouse"
 
Option "Protocol" "ExplorerPS/2"
 
Option "Device" "/dev/input/mice"
 
Option "Buttons" "7"
 
Option "ZAxisMapping" "4 5"
 
Option "ButtonMapping" "1 2 3 6 7"
 
 
Settings from above also works for Microsoft InteliMouse Explorer 3.0 that connects through USB.
 
 
=== Auto ===
 
 
This has been tested on a Logitech MX400 and should work on most mice with up to 7 buttons.
 
 
Driver "mouse"
 
Option "Protocol" "auto"
 
Option "Device" "/dev/input/mice"
 
Option "Buttons" "7"
 
Option "ZAxisMapping" "4 5"
 
Option "ButtonMapping" "1 2 3 6 7"
 
 
This has been tested to work with Logitech MX1000.
 
 
Driver "mouse"
 
Option "Protocol" "auto"
 
Option "Device" "/dev/input/mice"
 
Option "Emulate3Buttons" "no"
 
Option "Buttons" "12"
 
Option "ZAxisMapping" "4 5 7 6 8 9"
 
 
=== easystroke ===
 
 
[http://sourceforge.net/projects/easystroke/ easystroke] は X11 用のジェスチャー認識アプリケーションです。
 
 
easystroke is a mouse gesture application, but it can be used to manage mouse buttons as well. It's main advantage o-ver btnx is that it's more versatile. On the other hand, it's user-based, so any user has to configure it to reflect his own needs.
 
 
In order to set up easystroke to manage your extra mouse buttons, you will need to do this (example features Back/Forward mouse buttons) :
 
run:
 
easystroke -g
 
Go to Preferences tab > Additional buttons > Add, and add any special button.
 
{{Note|In case of easystroke does not automatically detect mouse buttons, you can specify it manually. Button identifiers (numbers) can be viewed by xev.}}
 
 
Go to ''Action tab > Add action'', give the new action a name, as Type choose "Key", as Details set "Alt+Left" for Back button, "Alt+Right" for Forward button, as Stroke click the proper mouse button (confirm if a warning is displayed), and voilà! Your mouse button is configured.
 
 
== キーボードをマウスボタンにバインド ==
 
 
=== xvkbd と xbindkeys ===
 
 
Let us say we want to bind some mouse buttons to keyboard ones. The problem we will encounter is that we do not know how to emulate a key press. Here comes in handy {{Pkg|xvkbd}}. We can use it along with {{Pkg|xbindkeys}}.
 
 
$ xbindkeys --defaults >> ~/.xbindkeysrc
 
$ xbindkeys
 
 
To restart xbindkeys type:
 
 
$ pkill -f xbindkeys
 
$ xbindkeys
 
 
Here is example {{Ic|~/.xbindkeysrc}} config:
 
 
"xvkbd -text "\[F8]""
 
m:0x0 + b:8
 
"xvkbd -text "\[Shift]\[Left]""
 
m:0x0 + b:9
 
"xvkbd -text "\[Shift]\[Right]""
 
m:0x0 + b:10
 
"xvkbd -text 2"
 
m:0x0 + b:11
 
"xvkbd -text 3"
 
m:0x0 + b:12
 
 
If you want to check your mouse buttons number use xev. Do not forget to type capital letters in xvkbd -text usage and to escape opening bracket with \ or you get simply [Shift] written.
 
 
Here is an example for xbindkeys to enable x selection paste(third click pasting), you need both xsel and xvkbd installed, What it does it executes that command whenever button 13 of the mouse is pressed (in ~/.xbindkeysrc) :
 
 
"xvkbd -no-jump-pointer -text "\D1$(xsel)" 2>/dev/null"
 
b:13
 
 
=== Why standard methods are not enough? ===
 
 
This will work great for X servers, but it seems not to work in some specific situations, like in Enemy Territory game. So I will describe a bit more advanced configuration, which work with my logitech G5 buttons - I can use all my 5 additional buttons along with 3 standard and a scroll, which gives overall 10 events to use in Enemy Territory. So here we go:
 
 
{{Note | '''Update:''' evrouter can now simulate X11 key events so it is now possible to skip [[#kbde|kbde]] and only use [[#evrouter|evrouter]] to bind keyboard buttons to your mouse. }}
 
 
=== kbde ===
 
 
To emulate keystroke which will be later detected in Enemy Territory we need something more advanced than xvkbd. Here comes in handy kbde, but it does not exist in the AUR yet – we have got to compile it by ourselves. We need two programs: kbde and kbde-driver. Kbde website is located on sourceforge [http://kbde.sourceforge.net/], check it for download, you need only kbde-driver. Apparently, it does not work for me without some hacking. Use your editor and add
 
 
#include <linux/version.h>
 
 
somewhere near other includes in the driver/kbde.c file. (OK, I'm not sure whether it is a proper way to compile it, but it works).
 
Assuming that you have already done that try:
 
 
tar -zxvf kbde-driver-1*
 
cd kbde-driver-1*
 
make
 
# if you do not have sudo just use su and type this as root
 
sudo make install mknod
 
modprobe kbde
 
 
and now you should have kbde working. If you want to use it as a non-root (yes, you want) change permissions, the quickest and dirtiest way is (note that I added my startup scripts at the end of this text):
 
 
chgrp users /dev/kbde
 
chmod 220 /dev/kbde
 
 
If not try reading installation instructions on the site. Now we can use it to emulate keystrokes visible even in login shells:
 
 
kbde --press 5 --release 5 -b
 
 
this will press 5 for about three times. If you want to type a string using this, rather than this use --asci=STRING, as press sometimes generates 3 strokes before it is released.
 
 
=== evrouter ===
 
 
Now we need something which will work when Enemy Territory is loaded. Apparently, xbindkeys does not work here, so we need another program: {{AUR|evrouter}} [http://www.bedroomlan.org/~alexios/coding_evrouter.html].
 
 
OK, so now we must have evdev and we can NOT use it in X, so here is how my example {{ic|/etc/X11/xorg.conf}} mouse section looks like:
 
 
Section "InputDevice"
 
 
Identifier "Logitech G5"
 
 
Driver "mouse"
 
Option "Protocol" "Auto"
 
Option "Device" "/dev/input/mouse1" # probably you will need here mouse0
 
Option "Name" "Logitech USB Gaming Mouse"
 
Option "Buttons" "8" # set this to your number of buttons
 
Option "ZAxisMapping" "4 5"
 
 
EndSection
 
 
and now we have to restart the X server.
 
You will run this as user, and event devices are owned by root, so you got to change the permissions at this point. Let us say we do it just like that, but I advise you to do this more carefully (note that I added my start-up scripts at the end of this text):
 
 
chgrp users /dev/input/event*
 
chmod 660 /dev/input/event*
 
 
Now we can use the {{ic|--dump}} option to check what we will have to bind and to which device:
 
 
evrouter --dump /dev/input/event*
 
# here click buttons you would like to bind
 
 
It will give you output similar to config. Here is my example config {{ic|~/.evrouterrc}} with kbde usage:
 
 
"Logitech USB Gaming Mouse" "/dev/input/event.*" any key/278 "SHELL/kbde --press 2 --release 2 -b"
 
"Logitech USB Gaming Mouse" "/dev/input/event.*" any key/279 "SHELL/kbde --press 3 --release 3 -b"
 
"Logitech USB Gaming Mouse" "/dev/input/event.*" any key/274 "SHELL/kbde --press 4 --release 4 -b"
 
"Logitech USB Gaming Mouse" "/dev/input/event.*" any key/277 "SHELL/kbde --press 5 --release 5 -b"
 
"Logitech USB Gaming Mouse" "/dev/input/event.*" any key/276 "SHELL/kbde --press 6 --release 6 -b"
 
 
Same config using evrouters built in X11 key event emulator instead of kbde:
 
 
"Logitech USB Gaming Mouse" "/dev/input/event.*" any key/278 "XKey/2"
 
"Logitech USB Gaming Mouse" "/dev/input/event.*" any key/278 "XKey/3"
 
"Logitech USB Gaming Mouse" "/dev/input/event.*" any key/278 "XKey/4"
 
"Logitech USB Gaming Mouse" "/dev/input/event.*" any key/278 "XKey/5"
 
"Logitech USB Gaming Mouse" "/dev/input/event.*" any key/278 "XKey/6"
 
 
This works great, even in Enemy Territory. The "none" modifier means that I have to only press the button, other options are {{ic|Ctrl+Alt}} and so on. Here I use "any" because "none" means that after pressing {{ic|Shift}}, {{ic|Ctrl}}, or {{ic|Alt}}, our buttons would not work. Also note that it accepts regular expressions for mouse name and event path. Then, after setting up a config, run service with:
 
 
evrouter /dev/input/event* >> /dev/null
 
 
or change the {{Ic|event*}} to a device corresponding to your mouse -- but be aware that the numbers are changing sometimes. It will work in background, while outputting some annoying messages, so we stream it to {{ic|/dev/null}}. If something went wrong, run it without streaming and check what it outputs. If you want to end it, you have to delete {{ic|/tmp/evrouter.*}} manually. Here is a script to kill evrouter:
 
 
#!/bin/bash
 
evrouter -q
 
rm -f /tmp/.evrouter*
 
 
and here is one to start it:
 
 
#!/bin/bash
 
mydevicename="Logitech USB Gaming Mouse"
 
 
device=$(evrouter -D /dev/input/event* | grep "$mydevicename") | cut -d ":" -f 2
 
evrouter $device > /dev/null
 
 
You have to edit the {{Ic|mydevicename}} variable to its proper value (the one which is shown by {{Ic|evrouter -D}}), or just change it to listen on all events by changing device var to {{Ic|/dev/input/event*}}. OK, I have saved them in {{ic|/usr/bin/}}. Now, everything should be ready for use!
 
 
=== Logitech G5 マウスの + と - のバインド ===
 
 
If you want to bind the buttons {{ic|+}} and {{ic|-}} in G5/7 mouse, which normally changes DPI, you have to use {{Ic|g5hack}} [http://piie.net/temp/g5_hiddev.c] released by a lomoco author.
 
 
<nowiki>wget http://piie.net/temp/g5_hiddev.c</nowiki>
 
gcc -o g5hack g5_hiddev.c
 
./g5hack /dev/usb/hiddev0 3
 
 
This will change your DPI to 2000, light the 1st LED and disables DPI on-the-fly changing, so you can use it with evrouter. If you would use it frequently I suggest you to copy it to the {{ic|/usr/bin}} directory:
 
 
# cp g5hack /usr/bin/
 
 
If you want to bind your {{ic|+}} and {{ic|-}} buttons you must copy the line at the bottom (one with the comment '"-" button does not function anymore' above) to the mode you will be using, like, for example, under the "case 3:" you can put it on the line with the comment 'turn on third led' above (deleting the old one before of course).
 
 
For the newest G5 mouse which is reported as "product 0xc049" original hack does not work. You have to simply change the {{ic|#define MOUSE_G5 0xc041}} to {{ic|#define MOUSE_G5 0xc049}} and recompile.
 
 
=== スタートアップスクリプト ===
 
 
Currently, I am using a startup script with a few dirty methods, so if somebody can propose better, please edit. I have created an input group and made my user a member of it.
 
 
{{ic|/etc/rc.local}}:
 
 
#!/bin/bash
 
# creating /dev/kbde nod and changing permissions
 
# also do not forget to add kbde in modules line in /etc/rc.conf
 
# to be honest, I'm not sure why we have to create /dev/kbde after each startup, but it seems that only this way it works
 
# maybe first check if it's needed for you, too
 
mknod --mode=220 /dev/kbde c 11 0
 
chgrp input /dev/kbde
 
# changing permissions for event* -- evrouter needs that
 
chmod 660 /dev/input/event*
 
chgrp input /dev/input/event*
 
# g5hack ran for a few times to make sure that it will work...
 
# note that I have add it to /usr/bin, you should probably put your full path here
 
# you probably should skip this lines, especially if you do not have a Logitech g5/g3/g7
 
g5hack /dev/usb/hiddev0 3
 
g5hack /dev/usb/hiddev0 3
 
g5hack /dev/usb/hiddev0 3
 
 
{{ic|~/.kde/Autostart/init}}:
 
 
#!/bin/bash
 
# there I use my script to start evrouter, which I have presented above
 
evrouter-start
 
# here I map my buttons so I can use G5 thumb button as push to talk in TS
 
# note that I have to use it as middle button also on KDE
 
# you probably do not need it
 
xmodmap -e "pointer = 1 9 3 4 5 6 7 2 8 10 11 12"
 
 
And voila, we have got it working immediately after KDE login.
 
 
== ユーザーツール ==
 
 
{{AUR|imwheel}} provides configurable mouse wheel and button mapping. It can be configured globally or for individual processes.
 
 
Sample {{ic|~/.imwheelrc}} to enable back/forward thumb buttons for all applications and increased scroll speed in Chromium:
 
"^chromium$"
 
None, Up, Button4, 3
 
None, Down, Button5, 3<br/>
 
".*"
 
None, Thumb1, Alt_L|Left
 
None, Thumb2, Alt_L|Right
 
 
{{Pkg|lomoco}} for Logitech MX mice will help you set the proper resolution, enable or disable smart scroll (with boot time support too!), etc. lomoco is available from the {{Ic|[community]}} repository and can be installed with the following command:
 
 
Be sure to look at {{ic|/etc/udev/lomoco_mouse.conf}} and set up the the options you want to be automatically applied when the mouse gets loaded by [[udev]].
 
{{Note|The lomoco package may be out of date. There is a hack for newer Logitech mice: [http://piie.net/temp/g5_hiddev.c]}}
 
   
 
==デバイスごとの設定ファイル==
 
==デバイスごとの設定ファイル==
   
 
=== Logitech G600===
 
=== Logitech G600===
  +
xorg-server 1.18.0-3 では G600 のサイドボタンはキーボードデバイスとして認識されず、おかしな挙動が発生することがあります (マウスボタンをクリックするとマウスカーソルが画面の端に飛ばされる)。強制的にキーボードボタンとして認識させるために、以下のセクションを {{ic|/etc/X11/xorg.conf}} に追加してください:
It is known that in xorg-server 1.18.0-3 side buttons of G600 are not recognized as a separate keyboard device, but another mouse which causes strange (moving mouse cursor to an edge of screen when one of main mouse buttons are clicked) behavior.
 
To force xorg to recognize them as a keyboard buttons, add following section to your {{ic|/etc/X11/xorg.conf}}:
 
   
 
Section "InputClass"
 
Section "InputClass"
428行目: 299行目:
 
EndSection
 
EndSection
   
=== Mad Catz Mouse===
+
=== Mad Catz ===
   
[[en2:Mad Catz Mouse|Mad Catz Mouse]] を見てさい。
+
[[Mad Catz]] を見てください。
   
 
=== Logitech M560/M545/M546 ===
 
=== Logitech M560/M545/M546 ===
  +
これらのマウスは Windows 8 用に設計されており、通常通りの挙動を示しません: マウスとキーボードのペアとして認識され、ボタンによっては通常のマウスボタンのイベントが発火せず、キーボードとマウスボタンのコンビネーションと認識されます。そのため Linux で"快適"なマウスとして使うのは厳しくなっています。
These mouse is designed for Windows 8, and has a non conventional behavior: the mouse appears as a pair of mouse and keyboard and some buttons don't emit the standard mouse button event, but instead a combination of keyboard and mouse button. This prevent a "confortable" use of this mouse under Linux.
 
   
 
ドライバーを使うことで通常のマウスのように使うことができます:
 
ドライバーを使うことで通常のマウスのように使うことができます:
439行目: 310行目:
 
[https://github.com/kreijack/logitech-m560 M560 のカーネルモジュール] (カーネル v4.2 でマージされています), [https://github.com/CzBiX/logitech-m560/tree/m545 M545/M546 のカーネルモジュール]
 
[https://github.com/kreijack/logitech-m560 M560 のカーネルモジュール] (カーネル v4.2 でマージされています), [https://github.com/CzBiX/logitech-m560/tree/m545 M545/M546 のカーネルモジュール]
   
xbindkeys でボタンをマッピングすることを推奨します。
+
また、xbindkeys でボタンをマッピングすることを推奨します。
  +
  +
=== Logitech G5 マウスの + と - のバインド ===
  +
  +
G5/7 マウスに付いているボタン {{ic|+}} と {{ic|-}} をバインドしたい場合 (通常は DPI を変更します)、lomoco の作者によって作成された {{Ic|g5hack}} [http://piie.net/temp/g5_hiddev.c] を使う必要があります。
  +
  +
$ <nowiki>wget http://piie.net/temp/g5_hiddev.c</nowiki>
  +
$ gcc -o g5hack g5_hiddev.c
  +
$ ./g5hack /dev/usb/hiddev0 3
  +
  +
上記のコマンドで DPI が2000に変更され、1番目の LED が点灯して DPI の動的な変更が無効化され evrouter で使えるようになります。コマンドを頻繁に実行する場合は {{ic|/usr/bin}} ディレクトリにコピーすると良いでしょう:
  +
  +
# cp g5hack /usr/bin/
  +
  +
{{ic|+}} や {{ic|-}} ボタンをバインドしたい場合、ファイル内の末尾付近の行 ('"-" button does not function anymore' というコメントが上にある行) を使用したいモードのところにコピーしてください。
  +
  +
{{ic|product 0xc049}} と認識される最新の G5 マウスではオリジナルのソースは使えません。{{ic|#define MOUSE_G5 0xc041}} を {{ic|#define MOUSE_G5 0xc049}} に変更してコンパイルしてください。
  +
  +
systemd ユニットを使うことで起動時に g5hack ツールを実行できます。詳しくは [[Systemd#ユニットファイル]]を見てください。
  +
  +
== Arch がゲスト仮想マシンの場合 ==
  +
  +
2 つまたは 3 つを超えるマウス ボタンをサポートしたい場合、その機能はハイパーバイザーソフトウェアによって異なります。
   
  +
=== VMware ワークステーション ===
== 参照 ==
 
   
  +
Arch ベースのゲスト VM の場合、その ''.vmx'' 設定ファイルに以下の行を追加します:
* http://www.gentoo-wiki.info/HOWTO_Advanced_Mouse
 
  +
mouse.vusb.enable = "TRUE"
* http://lotphelp.com/lotp/lotp-guide-logitech-mx-mouse-ubuntu
 
  +
mouse.vusb.useBasicMouse = "FALSE"

2024年2月4日 (日) 23:14時点における最新版

関連記事

この記事では 3 つ以上のマウスボタンが付いているマウスを設定する方法について説明します。

Xでマウス入力をテストする前提条件

このページでは、Waylandではなく、Xorg (X Window System) を使っていることを前提にしています。

まず、X があなたのマウスから何を見るかを確認したいと思うでしょう。X のイベントは xev ユーティリティで表示することができます。実行することでウィンドウがポップアップします。

$ xev -event button | grep button

そのウィンドウの xevents (移動、サイズ変更、クリックなど) は、xev を起動したコンソールに報告されます。"ボタン" を含む行をフィルタリングしているため、マウスのクリックとリリースのイベントが、関連するボタン番号とともに表示されます。ほとんどのマウスの場合、これは左ボタンの場合は '1'、中央のボタンは '2'、右ボタンの場合は '3' になります。他のボタンは異なります (たとえば、Logicool MX Master 3 の場合、スクロールホイールは 4 と 5、サムホイールは 6 と 7、親指の先のボタンは 9、親指の内側のボタンは 8)

出力例:

state 0x0, button 1, same_screen YES
state 0x100, button 1, same_screen YES
state 0x0, button 9, same_screen YES
state 0x0, button 9, same_screen YES

これは、マウスの左クリックとリリースに続いて親指の先でクリックとリリースに相当します。

xev を使用すると、マウスボタンの番号を確認し、X にマウスクリックが通知されていることを確認できます。

マウスとキーボードの機能の再バインド

このセクションでは、さまざまなツールを使用してマウスとキーボードの機能を再配置する方法について詳しく説明します。

マウスボタンをキーボード機能にバインドする

xte

xautomationxte は、キーボードのボタンをマウスにバインドする場合に便利です。

これは、Shift_R をマウス ボタン 3 ("右クリック") にバインドする ~/.xbindkeysrc の例です:

~/.xbindkeysrc
"xte 'mouseclick 3'"
  Shift_R

キーボードをマウスボタンにバインド

xvkbd と xbindkeys

マウスボタンをキーボードにバインドしたいとします。問題はキーの押下をエミュレートする方法がわからないということです。そこで xvkbdAUR が役に立ちます。xbindkeys と一緒に使うことができます:

$ xbindkeys --defaults >> ~/.xbindkeysrc
$ xbindkeys

xbindkeys を再起動するには以下を実行:

$ pkill -f xbindkeys
$ xbindkeys 

~/.xbindkeysrc の設定例:

"xvkbd  -text "\[F8]""
       m:0x0 + b:8
"xvkbd  -text "\[Shift]\[Left]""
       m:0x0 + b:9
"xvkbd  -text "\[Shift]\[Right]""
       m:0x0 + b:10
"xvkbd  -text 2"
       m:0x0 + b:11
"xvkbd  -text 3"
       m:0x0 + b:12

マウスボタンの番号を確認したいときは xev を使ってください。xvkbd -text では必ず大文字を入力して、括弧開き ([) を \ でエスケープしてください。

以下は xbindkeys で X のセレクションの貼り付け (中クリックのペースト) を有効にする例です。xsel と xvkbd のインストールが必要で、マウスのボタン 13 が押されたときにコマンドを実行します (~/.xbindkeysrc):

"xvkbd -no-jump-pointer -text "\D1$(xsel)" 2>/dev/null"
b:13

以下は Meta+M のキーバインドの例です:

"xvkbd  -text "\{+Super_L}m\{-Super_L}""
b:10

evrouter

プログラム (特にゲーム) によっては別の方法で入力を読み込むため、もう一つのプログラムが必要になります: evrouterAUR

evrouter コマンドで入力デバイスを読み込むには、input グループのユーザー (あるいは root) でコマンドを実行しなければなりません。ユーザーをグループに追加するには:

# gpasswd -a user input

--dump オプションを使うことで変更するボタンの名前を表示することができます:

ヒント: USB デバイスであれば udev は通常 /dev/input/by-id/ にシンボリックリンクを作成するので、それを使って特定のデバイスを指定できます。
$ evrouter --dump /dev/input/event*
device  0: /dev/input/event0: AT Translated Set 2 keyboard
device  1: /dev/input/event1: Microsoft Microsoft Trackball Explorer®
device  2: /dev/input/event2: Sleep Button
device  3: /dev/input/event3: Power Button
device  4: /dev/input/event4: Power Button
device  5: /dev/input/event5: PC Speaker
Display name: :0.0

それから変更したいボタンを押してください:

Window "(null)": # Window title
# Window "(null)": # Resource name
# Window "(null)": # Class name
"Microsoft Trackball Explorer®" "/dev/input/event1" none key/275 "fill this in!"

Window "(null)": # Window title
# Window "(null)": # Resource name
# Window "(null)": # Class name
"Microsoft Trackball Explorer®" "/dev/input/event1" none key/276 "fill this in!"

文末が "fill this in!" になっている行を設定ファイル (デフォルトでは ~/.evrouterrc) にコピーできます。例えば、evrouter に組み込まれている X11 のキーイベントエミュレータを使用して:

~/.evrouterrc
"Microsoft Trackball Explorer®" "/dev/input/event*" any key/275 "XKey/1"
"Microsoft Trackball Explorer®" "/dev/input/event*" any key/276 "XKey/2"

起動時に udev が別のデバイス番号を付与した場合を想定して 'event1' は 'event*' に変更してあります。また、'none' を 'any' に変更することで、ボタンが押されたときに修飾キーが押されていても、ルールが適用されるようにしています。フィールドの詳しい説味は evrouter(1) を見てください。

ヒント: ルールは特定のウィンドウだけに適用させることもできます。詳しくは evrouter(1) を参照。

設定ファイルの作成後、デーモンとして実行:

$ evrouter /dev/input/event*

デーモンを停止するには:

$ evrouter -q
$ rm -f /tmp/.evrouter*
ノート: /tmp/.evrouter:0.0 ファイルが存在すると evrouter は起動に失敗します。手動で削除してください。

ユーザーツール

このセクションでは、マウス設定、特にボタンの設定に役立つハードウェア固有のツールの概要を説明します。一般的なリマップツールについては、入力リマップユーティリティ を参照してください。

  • Piper (piper) は、ゲーミングマウスを設定するためのグラフィカルユーザーインターフェイスであり、Wayland と連携して動作します。マウスを操作するには、そのマウスが サポートされるデバイスのリスト に含まれている必要があります。
  • Logitech MX マウスの lomocoAUR は、適切な解像度の設定、スマートスクロールの有効化または無効化 (起動時のサポートも) などに役立ちます。/etc/udev/lomoco_mouse.conf を開き、udev によってマウスがロードされたときに自動的に適用されるオプションを設定します。
    ノート: lomoco パッケージが古い可能性があります。新しい Logitech マウス用のハックがあります: [1]
  • logiopsAUR は、Logicool マウスを設定するためのツール (Logicool Options for Linux) です。ボタンをアクションに再マップしたり、ジェスチャー、スマート シフトなどをサポートしたりできます。

evdev Xorg.conf のセットアップ

このセクションでは、evdev を使用して 3 つ以上のボタンを備えたマウスをセットアップする方法について説明します。これを実現する方法は他にもありますが、ここで説明するメモやツールの一部は、他のニーズを持つ人にとって役立つかもしれません。一部のパーツは、他のドライバーを使用して追加のマウス ボタンを機能させるのに役立つ場合があります。

Xorg の evdev ドライバーを使用します。EVentDEVice は、標準の Xorg mouse ドライバーよりもはるかに優れた能力を提供する USB 入力デバイス用の高度なドライバーです。また、mouse ドライバーよりも 直接的 であるため、待ち時間が短くなり、変換の問題も少なくなります。

  • evdev はカーネルモジュールと Xorg 入力ドライバーの両方であることに注意してください。すべての Arch カーネルには、evdev モジュールが付属しています。

Xorg 11R7.0 以降では、/etc/X11/xorg.conf に次の変更を加えるだけで済みます。

マウスの名前を確認

ノート: 正確な情報を得るために、Xorg やマウスのドライバーをロードする前にコマンドを実行する必要がある場合もあります。

まず最初にマウスの名前を確認します。次のコマンドを実行してください:

$ egrep "Name|Handlers" /proc/bus/input/devices | egrep -B1 'Handlers.*mouse'

以下のような出力がされます:

N: Name="Logitech USB Gaming Mouse"
H: Handlers=mouse0 event0 ts0 

もしくはマウスが複数ある場合:

N: Name="Kensington Kensington Expert Mouse Wireless"
H: Handlers=event0 mouse0 
--
N: Name="Logitech USB Receiver"
H: Handlers=kbd event2 mouse1

Handlers=mouse0 というのがマウスであり、デバイスの名前は Logitech USB Gaming Mouse です。名前はマウスによって異なります。

デバイスの名前をコピーしたら、/etc/X11/xorg.conf を開いて下さい。

Xorg の設定

X がマウスを使う方法を設定するため xorg.conf にエントリを記述します。エントリは以下のようになります:

Section "InputDevice"
  Identifier      "Evdev Mouse"
  Driver          "evdev"
  Option          "Name" "Logitech USB Gaming Mouse"
  Option          "evBits"  "+1-2"
  Option          "keyBits" "~272-287"
  Option          "relBits" "~0-2 ~6 ~8"
  Option          "Pass"    "3"
  Option          "CorePointer"
EndSection

Name オプションは先にコピーした名前に置き換えて下さい。マウスを複数使う場合や Xorg をロードしたときにエラーが発生する場合は CorePointer オプションは外して下さい。他のオプションはどれも evdev の基本的なマウス設定で、ほとんどのマウスで機能します。

次に、マウスを使うように X を設定します。xorg.confServerLayout を見て下さい。

ServerLayout セクションを修正してデバイスとして "Evdev Mouse" を使うようにしてください。設定したら、以下のようになります:

Section "ServerLayout"
  Identifier     "Default Layout"
  Screen 0       "Monitor0" 0 0
  InputDevice    "Keyboard0" "CoreKeyboard"
  InputDevice    "Evdev Mouse" "CorePointer"
EndSection

レイアウトで変更する必要があるのは (マウスを示す) InputDevice 行だけです。

Logitech G5 マウスを使っていてマウスが動作しない場合、InputDevice セクションに以下を記述してみてください ([#] は egrep 'Name|Handlers' /proc/bus/input/devices で確認できる数字に置き換えて下さい)。必要ない場合は、記述しないでください。

Option "Device" "/dev/input/event[#]"

上記の方法で、再起動後にマウスが動作しなくなる場合、/dev/input/by-id にシンボリックリンクを作成してみてください。例:

Option      "Device" "/dev/input/by-id/usb-Logitech_USB_Receiver-event-mouse"

適当な ID は、次を実行することで確認できます:

$ ls /dev/input/by-id/

evdev Xorg.conf 設定後

Google Chrome

動作します。横スクロールは何も設定しなくても動作します。スクロールホイールを左右に押して下さい。親指ボタンで次/前のページに移動します。

Opera

動作します。ボタンのマッピングは Preferences > Advanced > Shortcuts > Mouse set-up で簡単に変えられます。例えば、button 8back にバインドするには:

  1. マウスの設定から Application ドロップダウンを開く
  2. インプットカラムに、次を入力: Button 8
  3. アクションカラムに、次を入力: Back

Firefox

横スクロール

左と右のスクロールの代わりに、戻ると進むを有効にするには、about:config で以下の設定を変更します:

mousewheel.default.action.override_x         2
mousewheel.default.delta_multiplier_x       -100

親指ボタン - 進むと戻る

ノート: 以下は、xev がすべてのマウスボタンを正しく検出する (アプリごとに機能をマッピングできる) か、それともデフォルトの動作を変更するかによって、冗長になる可能性があります。

キーストロークを適当なマウスボタンにマッピングして xvkbdAURxbindkeys をインストールする必要があります。

戻る/進むを使用する最近のアプリケーションでは、デフォルトで XF86Back が戻るに、XF86Forward が進むにマッピングされています。ほとんどの MX マウスでは親指ボタンは 8 や 9 と認識されます。使用しているボタンで番号が異なっている場合、xev を使ってボタンの番号を確認して例で使われている番号を置き換えて下さい (b:8 & b:9)。

MX マウスを使っている場合、以下の内容で ~/.xbindkeysrc ファイルを作成します:

# Mouse Buttons
"xvkbd -xsendevent -text "\[XF86Back]""
m:0x0 + b:8 
"xvkbd -xsendevent -text "\[XF86Forward]""
m:0x0 + b:9

次にテストです。以下のコマンドを実行してください。問題ないようでしたら xbindkeys を .xinitrc など (X が起動するたびに読み込まれるファイル) に追加してください。また、Epiphany や Konqueror では特別な設定をしたり Imwheel を使用しなくとも機能します。

xbindkeys

詳しい情報は Logitech MX1000 にあります。

xmodmap の調整

ノート: evdev では以下のどれも必要ありませんが、evdev 以外のユーザーのためにここにあります。マウスで問題が発生しない限り、このセクション全体を無視してください。

.xinitrc を使って X をロードしている場合、以下を .xinitrc に追加してください (ボタンの数字は必要に応じて変更してください):

xmodmap -e "pointer = 1 2 3 6 7 8 9 10 11 12 4 5" &

ボタン 4 と 5 は一番最後に置いて下さい。そうしないとスクロールホイールが動作しません。

.xinitrc ではなく GDM/XDM/KDM を使っている場合、~/.Xmodmap ファイルを作成して以下を追加します (ボタンの数字は必要に応じて変更してください):

pointer = 1 2 3 6 7 8 9 10 11 12 4 5
  • GDM/XDM/KDM は ~/.Xmodmap ファイルが存在すると読み込みますが、startx は読み込みません。~/.xinitrc に次のコマンドを追加して読み込ませることもできます: xmodmap ~/.Xmodmap。何か変更が必要になったときに *DM と startx のどちらを使っている場合でも ~/.Xmodmap を編集すれば良くなります。

望み通りの動作をさせるために数字を多少弄る必要があるかもしれません。マウスによってはボタン 6 と 7 がスクロールホイールだったりします。その場合は 6 と 7 を最後の数字にしてください。上手く行くまで弄り続けて下さい。

Xorg に含まれている 'xev' というプログラムを使ってボタンを確認することもできます。xev を実行すると、デスクトップに小さなボックスが表示されるので、カーソルを合わせてボタンをクリックすることで、ボタンのマッピングがわかります。

xinput の調整

デバッグ時は xinput を使うことでユーザー空間で即座にボタンマップを変更できます。Logitech M505/B605 マウスの場合の実行例:

$ xinput set-button-map "$(xinput | awk -F'[=]' '/Logitech M505\/B605/ {print $2}' | awk '{print $1}')" 1 2 3 4 5 8 9

デバイスごとの設定ファイル

Logitech G600

xorg-server 1.18.0-3 では G600 のサイドボタンはキーボードデバイスとして認識されず、おかしな挙動が発生することがあります (マウスボタンをクリックするとマウスカーソルが画面の端に飛ばされる)。強制的にキーボードボタンとして認識させるために、以下のセクションを /etc/X11/xorg.conf に追加してください:

Section "InputClass"
    Identifier "G600 misconfiguration fix"
    MatchProduct "G600"
    # Match just the keyboard section of the G600
    MatchIsKeyboard "true"
    # evdev assumes it's a mouse when it sees the absolute axis. Stop that from happening. 
    Option "IgnoreAbsoluteAxes" "on"  
EndSection

Mad Catz

Mad Catz を見てください。

Logitech M560/M545/M546

これらのマウスは Windows 8 用に設計されており、通常通りの挙動を示しません: マウスとキーボードのペアとして認識され、ボタンによっては通常のマウスボタンのイベントが発火せず、キーボードとマウスボタンのコンビネーションと認識されます。そのため Linux で"快適"なマウスとして使うのは厳しくなっています。

ドライバーを使うことで通常のマウスのように使うことができます:

M560 のカーネルモジュール (カーネル v4.2 でマージされています), M545/M546 のカーネルモジュール

また、xbindkeys でボタンをマッピングすることを推奨します。

Logitech G5 マウスの + と - のバインド

G5/7 マウスに付いているボタン +- をバインドしたい場合 (通常は DPI を変更します)、lomoco の作者によって作成された g5hack [2] を使う必要があります。

$ wget http://piie.net/temp/g5_hiddev.c
$ gcc -o g5hack g5_hiddev.c
$ ./g5hack /dev/usb/hiddev0 3

上記のコマンドで DPI が2000に変更され、1番目の LED が点灯して DPI の動的な変更が無効化され evrouter で使えるようになります。コマンドを頻繁に実行する場合は /usr/bin ディレクトリにコピーすると良いでしょう:

# cp g5hack /usr/bin/

+- ボタンをバインドしたい場合、ファイル内の末尾付近の行 ('"-" button does not function anymore' というコメントが上にある行) を使用したいモードのところにコピーしてください。

product 0xc049 と認識される最新の G5 マウスではオリジナルのソースは使えません。#define MOUSE_G5 0xc041#define MOUSE_G5 0xc049 に変更してコンパイルしてください。

systemd ユニットを使うことで起動時に g5hack ツールを実行できます。詳しくは Systemd#ユニットファイルを見てください。

Arch がゲスト仮想マシンの場合

2 つまたは 3 つを超えるマウス ボタンをサポートしたい場合、その機能はハイパーバイザーソフトウェアによって異なります。

VMware ワークステーション

Arch ベースのゲスト VM の場合、その .vmx 設定ファイルに以下の行を追加します:

mouse.vusb.enable = "TRUE"
mouse.vusb.useBasicMouse = "FALSE"