Bluetooth mouse
Vladimir Grebenschikov
vova at fbsd.ru
Sun Dec 19 13:33:23 PST 2004
В пт, 17/12/2004 в 14:20 -0800, Maksim Yevmenkin пишет:
> Arne Schwabe wrote:
> > Maksim Yevmenkin <maksim.yevmenkin at savvis.net> writes:
> >
> >>bthidcontrol(8) is a utility that can query bluetooth hid devices and
> >>create configuration for bthidd(8).
> >>
> >>% nroff -man bthidcontrol.8 | less -- for more information
> >>
> >>bthidd(8) is a bluetooth hid daemon (incomplete but mouse should work).
> >>it will read configuration created by bthidcontrol(8) and talk to
> >>bluetooth hid devices.
> >
> > I just tried it with my Logitech MX900 mouse, it works! :)
>
> good.
I was not such lucky with mx900.
My experience:
bthidcontrol works ok:
# bthidcontrol -a mouse known
00:07:61:17:9b:27 mouse
# bthidcontrol -a mouse query
device {
bdaddr 00:07:61:17:9b:27;
control_psm 0x11;
interrupt_psm 0x19;
reconnect_initiate true;
battery_power true;
normally_connectable false;
hid_descriptor {
0x05 0x01 0x09 0x02 0xa1 0x01 0x85 0x02
0x09 0x01 0xa1 0x00 0x05 0x09 0x19 0x01
0x29 0x08 0x15 0x00 0x25 0x01 0x95 0x08
0x75 0x01 0x81 0x02 0x05 0x01 0x09 0x30
0x09 0x31 0x16 0x01 0xf8 0x26 0xff 0x07
0x75 0x0c 0x95 0x02 0x81 0x06 0x09 0x38
0x15 0x81 0x25 0x7f 0x75 0x08 0x95 0x01
0x81 0x06 0xc0 0xc0 0x06 0x00 0xff 0x09
0x01 0xa1 0x01 0x85 0x10 0x75 0x08 0x95
0x06 0x15 0x00 0x26 0xff 0x00 0x09 0x01
0x81 0x00 0x09 0x01 0x91 0x00 0xc0
};
}
# bthidcontrol -a mouse dump
Collection page=Generic_Desktop usage=Mouse
Collection page=Generic_Desktop usage=Pointer
Input id=2 size=1 count=1 page=Button usage=Button_1 Variable, logical range 0..1
Input id=2 size=1 count=1 page=Button usage=Button_2 Variable, logical range 0..1
Input id=2 size=1 count=1 page=Button usage=Button_3 Variable, logical range 0..1
Input id=2 size=1 count=1 page=Button usage=Button_4 Variable, logical range 0..1
Input id=2 size=1 count=1 page=Button usage=Button_5 Variable, logical range 0..1
Input id=2 size=1 count=1 page=Button usage=Button_6 Variable, logical range 0..1
Input id=2 size=1 count=1 page=Button usage=Button_7 Variable, logical range 0..1
Input id=2 size=1 count=1 page=Button usage=Button_8 Variable, logical range 0..1
Input id=2 size=12 count=1 page=Generic_Desktop usage=X Variable Relative, logical range -2047..2047
Input id=2 size=12 count=1 page=Generic_Desktop usage=Y Variable Relative, logical range -2047..2047
Input id=2 size=8 count=1 page=Generic_Desktop usage=Wheel Variable Relative, logical range -127..127
End collection
End collection
Input id=16 size=8 count=6 page=Microsoft usage=0x0001, logical range 0..255
Output id=16 size=8 count=6 page=Microsoft usage=0x0001, logical range 0..255
Collection page=Microsoft usage=0x0001
#
my configurations files are:
# cat /etc/bluetooth/bthidd.conf
device {
bdaddr 00:07:61:17:9b:27;
control_psm 0x11;
interrupt_psm 0x19;
reconnect_initiate true;
battery_power true;
normally_connectable false;
hid_descriptor {
0x05 0x01 0x09 0x02 0xa1 0x01 0x85 0x02
0x09 0x01 0xa1 0x00 0x05 0x09 0x19 0x01
0x29 0x08 0x15 0x00 0x25 0x01 0x95 0x08
0x75 0x01 0x81 0x02 0x05 0x01 0x09 0x30
0x09 0x31 0x16 0x01 0xf8 0x26 0xff 0x07
0x75 0x0c 0x95 0x02 0x81 0x06 0x09 0x38
0x15 0x81 0x25 0x7f 0x75 0x08 0x95 0x01
0x81 0x06 0xc0 0xc0 0x06 0x00 0xff 0x09
0x01 0xa1 0x01 0x85 0x10 0x75 0x08 0x95
0x06 0x15 0x00 0x26 0xff 0x00 0x09 0x01
0x81 0x00 0x09 0x01 0x91 0x00 0xc0
};
}
# cat /var/db/bthidd.hids
00:07:61:17:9b:27
#
When I start bthidd it waits for mouse connection forever, clicking on mouse connect button does not seems to have any effect,
moreover hcidump does not show any traffic.
But bthidd listens on /17 and /19 (why not /11 ?)
# btsockstat
Active raw HCI sockets
Socket PCB Flags Recv-Q Send-Q Local address
c2e44654 c273b500 000003 0 0 *
c1dba288 c2060880 000002 0 0 *
Active L2CAP sockets
PCB Recv-Q Send-Q Local address/PSM Foreign address CID State
c2fa8700 0 0 * /19 * 0 LISTEN
c2fa9700 0 0 * /17 * 0 LISTEN
c1957200 0 0 * /1 * 0 LISTEN
#
If I try to change reconnect_initiative to false bthidd try to connect to mouse but gets error:
# bthidd -d
bthidd[1785]: Opening outbound session for 00:07:61:17:9b:27 (new_device=0, reconnect_initiate=0)
bthidd[1785]: Could not connect to 00:07:61:17:9b:27. Socket is not connected (57)
while hcidump shows:
# hcidump
HCIDump - HCI packet analyzer ver 1.5
device: any snap_len: 65535 filter: 0xffffffff
< HCI Command: Create Connection(0x01|0x0005) plen 13
> HCI Event: Command Status(0x0f) plen 4
> HCI Event: Connect Complete(0x03) plen 11
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
< ACL data: handle 0x0029 flags 0x02 dlen 12
L2CAP(s): Connect req: psm 17 scid 0x004c
> HCI Event: Number of Completed Packets(0x13) plen 5
> HCI Event: Command Complete(0x0e) plen 6
> HCI Event: Page Scan Repetition Mode Change(0x20) plen 7
> ACL data: handle 0x0029 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x004d scid 0x004c result 1 status 2
> ACL data: handle 0x0029 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x0000 scid 0x004c result 2 status 0
> HCI Event: QoS Setup Complete(0x0d) plen 21
> HCI Event: Disconn Complete(0x05) plen 4
On mouse I have picture where attaching procedure shown as
1. Click connect on mouse
2. Click connect on USB receiver.
Looks like mouse gets passive state and waits for receiver connection after connect button.
Mouse works Ok under winXP with onboard bt.
(Is there way with hcidump "listen" traffic between XP and mouse to get clue ?)
If mouse already connected with USB receiver it do not answer even on l2ping.
My bluetooth controller:
ubt0: ALPS UGX, rev 1.10/7.81, addr 2
ubt0: ALPS UGX, rev 1.10/7.81, addr 2
ubt0: Interface 0 endpoints: interrupt=0x81, bulk-in=0x82, bulk-out=0x2
ubt0: Interface 1 (alt.config 5) endpoints: isoc-in=0x83, isoc-out=0x3; wMaxPacketSize=49; nframes=6, buffer size=294
# ngctl ls
There are 7 total nodes:
Name: ngctl1850 Type: socket ID: 00000020 Num hooks: 0
Name: ubt0l2cap Type: l2cap ID: 0000001a Num hooks: 3
Name: ubt0hci Type: hci ID: 00000016 Num hooks: 3
Name: btsock_l2c Type: btsock_l2c ID: 00000005 Num hooks: 1
Name: btsock_l2c_raw Type: btsock_l2c_raw ID: 00000004 Num hooks: 1
Name: btsock_hci_raw Type: btsock_hci_raw ID: 00000003 Num hooks: 1
Name: ubt0 Type: ubt ID: 00000002 Num hooks: 1
Any ideas is very appreciated.
> > But for _some_ reason, my third and second buttons are swapped. Well I
>
> the code just parses input hid reports according to the device's hid
> descriptor. it hid descriptor says its second button it will be second
> button :)
>
> > hacked it in the hid.c source code %)
>
> well, you are more then welcome to hack it further. i hope that enough
> bluetooth hid users will send me their hacks so i finally will be able
> to finish this :)
>
> thanks,
> max
--
Vladimir B. Grebenchikov
vova at fbsd.ru
More information about the freebsd-bluetooth
mailing list