Difference between revisions of "Bluetooth mouse"

From ArchWiki
Jump to: navigation, search
(Finding out your mouse's bdaddr)
m (Bluez5 instructions: fixed style)
 
(43 intermediate revisions by 16 users not shown)
Line 1: Line 1:
 
[[Category:Mice]]
 
[[Category:Mice]]
 
[[Category:Bluetooth]]
 
[[Category:Bluetooth]]
[[cs:Bluetooth Mouse]]
+
[[cs:Bluetooth mouse]]
[[ru:Bluetooth Mouse]]
+
[[ja:Bluetooth マウス]]
This article describes how to set up a [[Bluetooth]] mouse manually with no desktop assistance for Bluetooth. For example, a minimalist XFCE installation.  
+
[[ru:Bluetooth mouse]]
 +
{{Related articles start}}
 +
{{Related|Bluetooth}}
 +
{{Related|Bluez4}}
 +
{{Related|Mouse polling rate}}
 +
{{Related articles end}}
 +
 
 +
This article describes how to set up a [[Bluetooth]] mouse through the command line without relying upon a graphical application.
  
 
== Installation ==
 
== Installation ==
  
You need the {{Pkg|bluez}} package from the extra repository.
+
Install the {{Pkg|bluez}} package which contains the current Linux bluetooth stack (Bluez5). You may also want to install {{Pkg|bluez-utils}} which provides the ''bluetoothctl'' utility. See [[Bluetooth]] for more information.
  
== Start Bluetooth service ==
+
== Bluez5 instructions ==
  
The pertinent options in /etc/conf.d/bluetooth are
+
{{Tip|Ensure that the bluetooth daemon is started before continuing.}}
HIDD_ENABLE=true
+
  
after that, start bluetooth services with
+
The ''bluetoothctl'' utility provides a simple interface for configuring bluetooth devices. The text below is an example of how you can connect a bluetooth mouse using ''bluetoothctl'':
# systemctl enable bluetooth.service
+
# systemctl start bluetooth.service
+
  
=== kernel modules ===
+
# bluetoothctl
No additional actions are necessary if the bluetooth service is started using systemd. If it does not work try following.
+
[bluetooth]# list
 +
Controller <controller mac> BlueZ 5.5 [default]
 +
[bluetooth]# select <controller mac>
 +
[bluetooth]# power on
 +
[bluetooth]# scan on
 +
[bluetooth]# agent on
 +
[bluetooth]# devices
 +
Device <mouse mac> Name: Bluetooth Mouse
 +
[bluetooth]# pair <mouse mac>
 +
[bluetooth]# trust <mouse mac>
 +
[bluetooth]# connect <mouse mac>
  
The command
+
In order for the device to start on boot you may have to create a [[udev]] rule. Please see [[Bluetooth#Bluetoothctl]] for more information.
# modprobe -v btusb bluetooth hidp l2cap
+
loads the kernel modules you need, if they weren't loaded automatically.
+
  
=== Test ===
+
{{Tip|In case you were using USB Bluetooth dongle and moved it to another USB port, you may need to remove the mouse's MAC address in ''bluetoothctl'' with ''remove <mouse mac>'' command and repeat the entire procedure again.}}
The following command should show your bluetooth adapter:
+
  
{{hc|# hciconfig|
+
== Troubleshooting ==
hci0:  Type: BR/EDR  Bus: USB
+
      BD Address: 00:22:43:E1:82:E0  ACL MTU: 1021:8  SCO MTU: 64:1
+
      UP RUNNING PSCAN
+
      RX bytes:1062273 acl:62061 sco:0 events:778 errors:0
+
      TX bytes:1825 acl:11 sco:0 commands:39 errors:0
+
}}
+
  
== Configure Bluetooth Mouse ==
+
=== Mouse lag ===
The method described here is based in three steps, in this order:
+
  
# Make the PC learn about the bluetooth mouse.
+
If you experience mouse lag you can try to increase the polling rate. See [[Mouse polling rate]] for more information.
# Grant the mouse permissions to connect.
+
# Make the mouse learn about the PC.
+
  
=== Search your mouse ===
+
=== Problems with the USB dongle ===
First make your mouse discoverable. For example some mouse need to press a button. Then issue the following command as root:
+
  
{{hc|# hcitool scan|
+
If you have trouble with your USB dongle, you may also want to try:
Scanning ...
+
        00:07:61:F5:5C:3D      Logitech Bluetooth Mouse M555b
+
}}
+
  
Your mouse bluetooth address will be similar to {{ic|12:34:56:78:9A:BC}}. You may also find it in the documentation or on the mouse itself.
+
# modprobe -v rfcomm
  
== Connecting the mouse ==
+
At this point, you should get an hci0 device with:
hidd --search
+
hcitool inq
+
are good for device scanning (I needed to use sudo for 'hidd --search' to automatically connect mouse, searching worked even without sudo).
+
hidd --connect <bdaddr>
+
to actually connect.
+
hidd --show
+
will show your currently connected devices. The mouse should show up in this list. If it doesn't, press the reset button to make it discoverable.
+
  
Note: If you have the ipw3945 module loaded (wifi on HP computer) the bluetooth wont work.
+
# hcitool dev
  
== Connecting the mouse at startup ==
+
Sometimes the device is not active right away. Try starting the interface with:
Edit /etc/conf.d/bluetooth:
+
# Arguments to hidd
+
HIDD_OPTIONS="--connect <enter here your bluetooth mouse address>"
+
  
and test the new settings:
+
  # hciconfig hci0 up
  /etc/rc.d/bluetooth stop
+
hidd --killall (drop mouse connection)
+
/etc/rc.d/bluetooth start
+
  
Note: The above instructions to start the mouse at startup do not work with the now outdated 3.11 bluetooth packages. New versions such as the current (3.32) packages are not affected. If you are using an older version, then to start the mouse at startup, add:
 
hidd --connect <enter here your bluetooth mouse address (No capitals!!!)>
 
to your /etc/rc.local file.
 
 
Note #2: You can connect any bluetooth mouse and/or keyboard without any further configuration and without knowing the device address. You can do it by adding the --master and/or --server option in HIDD_OPTIONS depending on your device.
 
 
== Troubleshooting tips ==
 
 
If you have trouble with your USB dongle, you may also want to try
 
# modprobe -v rfcomm
 
 
At this point, you should get an hci0 device with
 
# hcitool dev
 
 
Sometimes the device is not active right away - try starting the interface with
 
# hciconfig hci0 up
 
 
and searching for devices as shown above.
 
and searching for devices as shown above.

Latest revision as of 08:34, 27 January 2016

This article describes how to set up a Bluetooth mouse through the command line without relying upon a graphical application.

Installation

Install the bluez package which contains the current Linux bluetooth stack (Bluez5). You may also want to install bluez-utils which provides the bluetoothctl utility. See Bluetooth for more information.

Bluez5 instructions

Tip: Ensure that the bluetooth daemon is started before continuing.

The bluetoothctl utility provides a simple interface for configuring bluetooth devices. The text below is an example of how you can connect a bluetooth mouse using bluetoothctl:

# bluetoothctl
[bluetooth]# list
Controller <controller mac> BlueZ 5.5 [default]
[bluetooth]# select <controller mac>
[bluetooth]# power on
[bluetooth]# scan on
[bluetooth]# agent on
[bluetooth]# devices
Device <mouse mac> Name: Bluetooth Mouse
[bluetooth]# pair <mouse mac>
[bluetooth]# trust <mouse mac>
[bluetooth]# connect <mouse mac>

In order for the device to start on boot you may have to create a udev rule. Please see Bluetooth#Bluetoothctl for more information.

Tip: In case you were using USB Bluetooth dongle and moved it to another USB port, you may need to remove the mouse's MAC address in bluetoothctl with remove <mouse mac> command and repeat the entire procedure again.

Troubleshooting

Mouse lag

If you experience mouse lag you can try to increase the polling rate. See Mouse polling rate for more information.

Problems with the USB dongle

If you have trouble with your USB dongle, you may also want to try:

# modprobe -v rfcomm

At this point, you should get an hci0 device with:

# hcitool dev

Sometimes the device is not active right away. Try starting the interface with:

# hciconfig hci0 up

and searching for devices as shown above.