はじめに
yumetodo.hateblo.jp
yumetodo.hateblo.jp
yumetodo.hateblo.jp
yumetodo.hateblo.jp
2018年、家のあまりにも操作性の良くない有線マウスをリストラするべく購入したBluetooth接続のマウス。
ところがデュアルブート環境である我が家では安定的に接続することができずにいた。
Ubuntuのバージョンは16.04から18.04を経て20.04にまでなった。
転機
2020年8月23日、GolangとVim界隈で知らない人はいない@mattn_jp氏のふとしたツイートがきっかけとなった。
紹介の合った記事がこちら。
orumin.blogspot.com
試す
このころは別件で忙しく、またcovid19研究加速のためにrosetta homeを回してるのであんま再起動したくないとか理由をつけて先延ばしにしていたが、重い腰を上げてついに試してみることにした。
まずchntpwを導入する。レジストリを閲覧するのに必要だ。
$sudo apt install chntpw
BluetoothマウスをGUIなどからペアリングする
PC再起動してWindowsを起動する
BluetoothマウスをGUIなどからペアリングする
管理者権限powershellを立ち上げてハイバネーションを切る
powercfg.exe /hibernate off
PC再起動してUbuntuを立ち上げる
nautilusなどからWindowのCドライブをマウントする
Bluetoothインターフェイス(ようはPCについたチップ)のIDを調べる
$bluetoothctl
Agent registered
[CHG] Controller A4:C3:F0:88:90:45 Pairable: yes
[ELECOM BlueLED Mouse]
A4:C3:F0:88:90:45
だった。
次のようにしてレジストリを閲覧する
$chntpw -e /media/yumetodo/4C7E6CE87E6CCC70/Windows/System32/config/SYSTEM
chntpw version 1.00 140201, (c) Petter N Hagen
Hive </media/yumetodo/4C7E6CE87E6CCC70/Windows/System32/config/SYSTEM> name (from header): <SYSTEM>
ROOT KEY at offset: 0x001020 * Subkey indexing type is: 686c <lh>
File size 24379392 [1740000] bytes, containing 5276 pages (+ 1 headerpage)
Used for data: 372635/23536872 blocks/bytes, unused: 87/38808 blocks/bytes.
Simple registry editor. ? for help.
>
> ls
Node has 17 subkeys and 0 values
key name
<ActivationBroker>
<ControlSet001>
<DriverDatabase>
<HardwareConfig>
<Input>
<Keyboard Layout>
<Maps>
<MountedDevices>
<ResourceManager>
<ResourcePolicyStore>
<RNG>
<Select>
<Setup>
<Software>
<State>
<WaaS>
<WPA>
> cd ControlSet001
\ControlSet001> cd Service\BTHPORT
\ControlSet001\Services\BTHPORT> cd Parameters\Keys
(...)\Services\BTHPORT\Parameters\Keys> ls
Node has 2 subkeys and 0 values
key name
<001bdc0f6618>
<a4c3f0889045>
(...)\Services\BTHPORT\Parameters\Keys> cd a4c3f0889045
(...)\BTHPORT\Parameters\Keys\a4c3f0889045> ls
Node has 0 subkeys and 1 values
size type value name [value if type DWORD]
16 3 REG_BINARY <c8478227da53>
(...)\BTHPORT\Parameters\Keys\a4c3f0889045> hex c8478227da5.
cat_vk: No such value <c8478227da5.>
(...)\BTHPORT\Parameters\Keys\a4c3f0889045> hex c8478227da53
Value <c8478227da53> of type REG_BINARY (3), data length 16 [0x10]
:00000 08 57 94 6B D5 43 8B 13 30 0E 90 A8 1B 43 ED C7 .W.k.C..0....C..
ControlSet001
かControlSet002
の中をみる。大抵はControlSet001
らしい。そこから\Services\BTHPORT\Parameters\Keys
と辿るとbluetoothインターフェイスのIDが列挙されている。目的のIDの中にはマウスのIDの値があるので、hex
でバイナリデータを閲覧する。今回は0857946BD5438B13300E90A81B43EDC7
であった。
あとはUbuntu側のbluetoothの設定を書き換える。
$sudo nano "/var/lib/bluetooth/A4:C3:F0:88:90:45/C8:47:82:27:DA:53"/info
[General]
Name=ELECOM BlueLED Mouse
Class=0x000580
SupportedTechnologies=BR/EDR;
Trusted=true
Blocked=false
Services=00001000-0000-1000-8000-00805f9b34fb;00001124-0000-1000-8000-00805f9b34fb;00001200-0000-1000-8000-00805f9b34fb;
[LinkKey]
Key=0857946BD5438B13300E90A81B43EDC7
Type=4
PINLength=0
[DeviceID]
Source=2
Vendor=1390
Product=229
Version=297
LinkKey
の中のKey
をさっきのhexで調べた値に書き換える。
終わったらbluetoothを再起動する
$sudo systemctl restart bluetooth
管理者権限powershellを立ち上げてハイバネーションを有効に。切りっぱなしはスリープ周りの挙動への影響が無視できないのでね。
powercfg.exe /hibernate on
まとめ
マウスがうごく!すばらしい!