VMware ゲストにDS4を接続してみた (Bluetooth編)

VMware にインストールした Ubuntu1.04 にDS4 (Sony DualShock4) を接続してみました。今回はBluetoothで接続した際のメモです。

下記のようなブログもあります。

1.動作環境
2.確認

接続されているUSBデバイスを確認する

$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
$

上記のように Bluetooth インターフェスが接続されていなければ
「Player(P)」メニュー →「管理 (M)」→ 「仮想マシン設定 (S)」をクリック

f:id:ky2018041:20201004213334p:plain
仮想マシン設定

ポップアップした仮想マシン設定ダイアログの「USBコントローラ」をクリックして、「Bluetoothバイス仮想マシンと共有 (B)」のチェックを外し、[OK]をクリック。

f:id:ky2018041:20201004213624p:plain
仮想マシン設定ダイアログ

再度接続されているUSBデバイスを確認する。2行目がBluetoothインタフェースの模様。

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 004: ID 04c5:14b9 Fujitsu, Ltd 
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
$

接続されている Bluetoothバイスを確認すると、

$ hciconfig 
$ 

何も接続されていないので、UbuntuBluetoothバイスを接続する。
[Player(P)]メニューの[取外し可能デバイス(R)] → [Fujitsu Bluetooth Radio] → [接続 (ホストから切断) (C)]

f:id:ky2018041:20201005203458p:plain
ホストから切断し仮想マシンに接続

仮想マシンへの接続を確認するダイアログがポップアップするので、[OK] をクリック。

f:id:ky2018041:20201005203838p:plain
仮想マシンへの接続確認ダイアログ

接続されている Bluetoothバイスを確認。

$ hciconfig 
hci0:	Type: Primary  Bus: USB
	BD Address: 80:78:71:1B:59:C3  ACL MTU: 1021:6  SCO MTU: 255:12
	UP RUNNING PSCAN 
	RX bytes:779 acl:0 sco:0 events:59 errors:0
	TX bytes:3241 acl:0 sco:0 commands:59 errors:0

$ 
3.ペアリング

Bluetoothインタフェースが接続されたので、DS4 をペアリングする。

$ sudo ds4drv
[sudo] ...... のパスワード: 
[info][controller 1] Created devices /dev/input/js0 (joystick) /dev/input/event5 (evdev) 
[info][bluetooth] Scanning for devices

DS4 の[SHARE] ボタンと 二つのジョイスティックの間にある [PS] ボタンを、LEDが点滅するまで同時押し。ペアリングが完了すると、ターミナル・ウィンドウに下記のようなメッセージが出力される。

[info][bluetooth] Found device A4:AE:12:9A:8D:AC
[info][controller 1] Connected to Bluetooth Controller (A4:AE:12:9A:8D:AC)
[info][bluetooth] Scanning for devices
[info][controller 1] Battery: Fully charged

別のターミナル・ウィンドウを立ち上げて([Ctrl] + [Alt] + [T])、/dev/input ディレクトリをチェックしてみる。

$ ls /dev/input
by-id    event0  event2  event4  js0   mouse0  mouse2
by-path  event1  event3  event5  mice  mouse1
$ 

js0がジョイスティク、あとマウスとイベントが追加されている。

4.動作確認

jstest-get を起動してDS4 の動作を確認する 。

$ jstest-gtk 

下記のウィンドウがポップアップするので、ジョイスティックのアイコンが表示されているメニューアイテムをダブルクリックする。

f:id:ky2018041:20201005205909p:plain
Joystick Preferences ダイアログ

下記のようなウィンドウがポップアップするので、DS4のボタンやジョイスティックを操作して、表示が変化すれば確認終了。

f:id:ky2018041:20201005210343p:plain
ゲームコントローラ動作確認ウィンドウ