LoginSignup
4
3

More than 3 years have passed since last update.

WiiリモコンをUbuntuでゲームバッドして使う

Posted at

WiiリモコンをUbuntuでゲームバッドして使えないか?ふと思い立ち、実行してみました。
結果無事にUbuntuで利用できたので、その時の記録。

前提条件

・Wiiリモコンを認識させたいPCで、BlueToothが利用できること

動作確認環境

  • OS:Ubuntu 18.0.4 LTS
  • CPU:Athlon 200GE
  • メモリ:8G
  • BlueTooth(+Wifi):Intel Dual Band Wireless-AC 3168

必要なソフトをインストール

$ sudo apt-get install lswm wminput libcwiid1

インストール後、コントローラーが認識できるか確認

  • lswmコマンドを実行
$ lswm
"Put Wiimotes in discoverable mode now (press 1+2)..."

この時、Wiiリモコンの3つのボタンを同時に押下
1. バッテリーカバーを外した箇所にある、小さなボタン(Wi-Fiロゴが近くに刻印されている)
2. 1ボタン + 2ボタン

うまく認識されると、MACアドレスが表示される

$ lswm
"Put Wiimotes in discoverable mode now (press 1+2)..."
00:1F:03:AB:F1:XA

キーボードをWiiリモコンにマッピングする

  • 認識されることを確認したら、キーボードのボタンをWiiリモコンにマッピングする
  • そのために、設定ファイルを記述(下記設定ファイルはデフォルト値が入力されているので上書きする)
$ sudo vi /etc/cwiid/wminput/gamepad
/etc/cwiid/wminput/gamepad
# 設定例(利用するエミュレーターソフトのキーコントロールに対応させると良い)
# Wiiリモコンは右倒しで利用するため、右に90度回転させてボタンを配置する
Wiimote.Up = KEY_LEFT

Wiimote.Down = KEY_RIGHT

Wiimote.Left = KEY_DOWN

Wiimote.Right = KEY_UP

Wiimote.1 = KEY_Z

Wiimote.2 = KEY_A

Wiimote.A = KEY_LEFTALT

Wiimote.B = KEY_RIGHTCTRL

Wiimote.Plus = KEY_ENTER

Wiimote.Minus = KEY_SPACE

設定ファイルを読み込み、Wiiリモコンをつなぐ

  • 下記コマンドを実行
$ sudo wminput -c /etc/cwiid/wminput/gamepad
"Put Wiimotes in discoverable mode now (press 1+2)..."

上記画面が出たら、再びWiiリモコンの3つのボタンを同時に押下
1. バッテリーカバーを外した箇所にある、小さなボタン(Wi-Fiロゴが近くに刻印されている)
2. 1ボタン + 2ボタン

すると、Readyと表示される。

$ sudo wminput -c /etc/cwiid/wminput/gamepad
"Put Wiimotes in discoverable mode now (press 1+2)..."
Ready

この時点でWiiリモコンのボタンはキーボード入力にマッピングされているため、1ボタンを押すと
zが、2ボタンを押すとaが画面に表示される

$ sudo wminput -c /etc/cwiid/wminput/gamepad
"Put Wiimotes in discoverable mode now (press 1+2)..."
Ready
za

上記のように認識された後にエミュレーターを立ち上げ、Wiiリモコンで操作できるか確認。

補足:利用できるWiiのボタン

・Wiimote.Up ・Wiimote.Down ・Wiimote.Left ・Wiimote.Right ・Wiimote.A
・Wiimote.B ・Wiimote.1 ・Wiimote.2 ・Wiimote.Plus ・Wiimote.Minus
・Wiimote.Home ・Wiimote.Dpad.X ・Wiimote.Dpad.Y ・Nunchuk.C
・Nunchuk.Z ・Nunchuk.Stick.X ・Nunchuk.Stick.Y ・Classic.Up
・Classic.Down ・Classic.Left ・Classic.Right ・Classic.Minus
・Classic.Plus ・Classic.Home ・Classic.A ・Classic.B ・Classic.X
・Classic.Y ・Classic.ZL ・Classic.ZR ・Classic.L ・Classic.R
・Classic.Dpad.X ・Classic.Dpad.Y ・Classic.LStick.X ・Classic.LStick.Y
・Classic.RStick.X ・Classic.RStick.Y ・Classic.LAnalog ・Classic.RAnalog

マッピング可能なキー一覧

キー コード
Escape KEY_ESC
0 KEY_0
1 KEY_1
2 KEY_2
3 KEY_3
4 KEY_4
5 KEY_5
6 KEY_6
7 KEY_7
8 KEY_8
9 KEY_9
- (minus symbol) KEY_MINUS
= (equals symbol) KEY_EQUAL
BackSpace KEY_BACKSPACE
Tab KEY_TAB
Q KEY_Q
W KEY_W
E KEY_E
R KEY_R
T KEY_T
Y KEY_Y
U KEY_U
I KEY_I
O KEY_O
P KEY_P
[ KEY_LEFTBRACE
] KEY_RIGHTBRACE
Enter KEY_ENTER
CTRL (Left side of keyboard) KEY_LEFTCTRL
A KEY_A
S KEY_S
D KEY_D
F KEY_F
G KEY_G
H KEY_H
J KEY_J
K KEY_K
L KEY_L
; (Semi Colon) KEY_SEMICOLON
' (Apostrophe) KEY_APOSTROPHE)
#
Shift (Left side of keyboard) KEY_LEFTSHIFT
\ KEY_BACKSLASH
Z KEY_Z
X KEY_X
C KEY_C
V KEY_V
B KEY_B
N KEY_N
M KEY_M
, (comma) KEY_COMMA
. (full stop) KEY_DOT
/ (forward slash) KEY_SLASH
Shift (right side of keyboard KEY_RIGHTSHIFT
ALT (left side of keyboard
Space bar KEY_SPACE
Caps Lock KEY_CAPSLOCK
F1 KEY_F1
F2 KEY_F2
F3 KEY_F3
F4 KEY_F4
F5 KEY_F5
F6 KEY_F6
F7 KEY_F7
F8 KEY_F8
F9 KEY_F9
F10 KEY_F10
F11 KEY_F11
F12 KEY_F12
Num Kock KEY_NUMLOCK
Shift Lock KEY_SHIFTLOCK
0 (keypad) KEY_KP0
1 (keypad) KEY_KP1
2 (keypad) KEY_KP2
3 (keypad) KEY_KP3
4 (keypad) KEY_KP4
5 (keypad) KEY_KP5
6 (keypad) KEY_KP6
7 (keypad) KEY_KP7
8 (keypad) KEY_KP8
9 (keypad) KEY_KP9
. (keypad dot) KEY_KPDOT
+ (keypad plus symbol) KEY_KPPLUS
- (keypad minus symbol) KEY_KPMINUS
Left arrow KEY_LEFT
Right arrow KEY_RIGHT
Up arrow KEY_UP
Down arrow KEY_DOWN
Home KEY_HOME
Insert KEY_INSERT
Delete KEY_DELETE
Page Up KEY_PAGEUP
Page Down KEY_PAGEDOWN

参考

How To Use A Nintendo Wii Controller To Play Linux Games
Linux Mint 18 : Will リモコンをゲームパッドとして使えるようにする

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3