Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src add Magic Mouse driver and manpage btmagic(4)



details:   https://anonhg.NetBSD.org/src/rev/1cba3d264294
branches:  trunk
changeset: 755102:1cba3d264294
user:      plunky <plunky%NetBSD.org@localhost>
date:      Sat May 22 18:56:00 2010 +0000

description:
add Magic Mouse driver and manpage btmagic(4)

diffstat:

 distrib/sets/lists/man/mi         |     5 +-
 share/man/man4/Makefile           |     5 +-
 share/man/man4/btmagic.4          |   113 +++
 sys/dev/bluetooth/btmagic.c       |  1355 +++++++++++++++++++++++++++++++++++++
 sys/dev/bluetooth/files.bluetooth |     7 +-
 5 files changed, 1481 insertions(+), 4 deletions(-)

diffs (truncated from 1549 to 300 lines):

diff -r 0d8a9d390a53 -r 1cba3d264294 distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Sat May 22 18:51:19 2010 +0000
+++ b/distrib/sets/lists/man/mi Sat May 22 18:56:00 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1209 2010/05/16 15:33:29 jruoho Exp $
+# $NetBSD: mi,v 1.1210 2010/05/22 18:56:00 plunky Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -819,6 +819,7 @@
 ./usr/share/man/cat4/bthset.0                  man-obsolete            obsolete
 ./usr/share/man/cat4/bthub.0                   man-sys-catman          .cat
 ./usr/share/man/cat4/btkbd.0                   man-sys-catman          .cat
+./usr/share/man/cat4/btmagic.0                 man-sys-catman          .cat
 ./usr/share/man/cat4/btms.0                    man-sys-catman          .cat
 ./usr/share/man/cat4/btsco.0                   man-sys-catman          .cat
 ./usr/share/man/cat4/btuart.0                  man-sys-catman          .cat
@@ -3479,6 +3480,7 @@
 ./usr/share/man/html4/bthidev.html             man-sys-htmlman         html
 ./usr/share/man/html4/bthub.html               man-sys-htmlman         html
 ./usr/share/man/html4/btkbd.html               man-sys-htmlman         html
+./usr/share/man/html4/btmagic.html             man-sys-htmlman         html
 ./usr/share/man/html4/btms.html                        man-sys-htmlman         html
 ./usr/share/man/html4/btsco.html               man-sys-htmlman         html
 ./usr/share/man/html4/btuart.html              man-sys-htmlman         html
@@ -5915,6 +5917,7 @@
 ./usr/share/man/man4/bthset.4                  man-obsolete            obsolete
 ./usr/share/man/man4/bthub.4                   man-sys-man             .man
 ./usr/share/man/man4/btkbd.4                   man-sys-man             .man
+./usr/share/man/man4/btmagic.4                 man-sys-man             .man
 ./usr/share/man/man4/btms.4                    man-sys-man             .man
 ./usr/share/man/man4/btsco.4                   man-sys-man             .man
 ./usr/share/man/man4/btuart.4                  man-sys-man             .man
diff -r 0d8a9d390a53 -r 1cba3d264294 share/man/man4/Makefile
--- a/share/man/man4/Makefile   Sat May 22 18:51:19 2010 +0000
+++ b/share/man/man4/Makefile   Sat May 22 18:56:00 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.516 2010/04/10 17:55:25 jruoho Exp $
+#      $NetBSD: Makefile,v 1.517 2010/05/22 18:56:01 plunky Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/18/93
 
 MAN=   aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -13,7 +13,8 @@
        auixp.4 autri.4 auvia.4 awi.4 azalia.4 \
        battery_pmu.4 bba.4 bce.4 bcsp.4 be.4 bge.4 bnx.4 bha.4 \
        bio.4 bktr.4 bluetooth.4 bmtphy.4 bpf.4 \
-       brgphy.4 bridge.4 bthidev.4 bthub.4 btkbd.4 btms.4 btsco.4 btuart.4 \
+       brgphy.4 bridge.4 bthidev.4 bthub.4 btkbd.4 \
+       btmagic.4 btms.4 btsco.4 btuart.4 \
        bwi.4 \
        cac.4 cardbus.4 carp.4 cas.4 ccd.4 cd.4 \
        cec.4 cgd.4 cfb.4 ch.4 chipsfb.4 ciphy.4 ciss.4 clcs.4 clct.4 clnp.4 \
diff -r 0d8a9d390a53 -r 1cba3d264294 share/man/man4/btmagic.4
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man4/btmagic.4  Sat May 22 18:56:00 2010 +0000
@@ -0,0 +1,113 @@
+.\" $NetBSD: btmagic.4,v 1.1 2010/05/22 18:56:01 plunky Exp $
+.\"
+.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Iain Hibbert.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd May 22, 2010
+.Dt BTMAGIC 4
+.Os
+.Sh NAME
+.Nm btmagic
+.Nd Apple Magic Mouse
+.Sh SYNOPSIS
+.Cd "btmagic*  at bthub?"
+.Cd "wsmouse*  at btmagic?"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for the
+.Tn Bluetooth
+.Dq Magic Mouse
+from
+.Tn Apple, Inc .
+.Pp
+The Magic Mouse uses the standard
+.Tn USB
+Human Interface Device protocol to communicate, but does not provide a
+proper HID Descriptor, and requires specific initializations to enable
+the proprietary touch reports.
+.Pp
+The Magic Mouse provides basic mouse functionality with two buttons,
+and the
+.Nm
+driver additionally interprets the touch reports to emulate a middle
+mouse button when more than one firm touch is detected during a click
+event, plus horizontal and vertical scrolling for touch movements
+greater than a certain distance.
+The mouse has a base resolution of 1300dpi, which the driver scales
+by default to a less sensitive 650dpi, but this is adjustable with
+.Xr sysctl 8
+along with the pressure needed to discern a firm touch, the minimum
+distance necessary to trigger scrolling and the additional downscale
+factor applied to scroll movements.
+.Pp
+The Magic Mouse should be configured with the
+.Xr btdevctl 8
+program and
+.Nm
+interfaces to the system as usual through the
+.Xr wscons 4
+driver.
+The following properties are used during autoconfiguration:
+.Bl -tag -width ".It remote-bdaddr"
+.It vendor-id
+Must be 0x05ac.
+.It product-id
+Must be 0x030d.
+.It local-bdaddr
+Local device address.
+.It remote-bdaddr
+Remote device address.
+.It link-mode
+This optional string represents the link mode of the baseband link, and
+may be one of
+.Sq auth ,
+.Sq encrypt ,
+or
+.Sq secure .
+.El
+.Pp
+When the
+.Nm
+driver has configured, it will attempt to open a connection to the mouse
+and, if this fails or the connection is lost, will wait for the
+mouse to initiate connections.
+.Sh SEE ALSO
+.Xr bluetooth 4 ,
+.Xr bthub 4 ,
+.Xr wsmouse 4 ,
+.Xr btdevctl 8 ,
+.Xr sysctl 8
+.Sh HISTORY
+The
+.Nm
+driver was written by
+.An Iain Hibbert
+with reference to the
+.Tn Linux
+driver written by
+.An Michael Poole .
diff -r 0d8a9d390a53 -r 1cba3d264294 sys/dev/bluetooth/btmagic.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/bluetooth/btmagic.c       Sat May 22 18:56:00 2010 +0000
@@ -0,0 +1,1355 @@
+/*     $NetBSD: btmagic.c,v 1.1 2010/05/22 18:56:01 plunky Exp $       */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Iain Hibbert.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (lennart%augustsson.net@localhost) at
+ * Carlstedt Research & Technology.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*-
+ * Copyright (c) 2006 Itronix Inc.
+ * All rights reserved.
+ *
+ * Written by Iain Hibbert for Itronix Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of Itronix Inc. may not be used to endorse
+ *    or promote products derived from this software without specific
+ *    prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*****************************************************************************
+ *
+ *             Apple Bluetooth Magic Mouse driver
+ *
+ * The Apple Magic Mouse is a HID device but it doesn't provide a proper HID
+ * descriptor, and requires extra initializations to enable the proprietary
+ * touch reports. We match against the vendor-id and product-id and provide
+ * our own Bluetooth connection handling as the bthidev driver does not cater
+ * for such complications.
+ *
+ * This driver interprets the touch reports only as far as emulating a
+ * middle mouse button and providing horizontal and vertical scroll action.
+ * Full gesture support would be more complicated and is left as an exercise
+ * for the reader.
+ *
+ * Credit for decoding the proprietary touch reports goes to Michael Poole
+ * who wrote the Linux hid-magicmouse input driver.
+ *
+ *****************************************************************************/
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.1 2010/05/22 18:56:01 plunky Exp $");
+
+#include <sys/param.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/fcntl.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/proc.h>
+#include <sys/socketvar.h>
+#include <sys/systm.h>
+#include <sys/sysctl.h>
+
+#include <prop/proplib.h>
+
+#include <netbt/bluetooth.h>
+#include <netbt/l2cap.h>
+
+#include <dev/bluetooth/btdev.h>
+#include <dev/bluetooth/bthid.h>
+#include <dev/bluetooth/bthidev.h>
+
+#include <dev/usb/hid.h>
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdevs.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsmousevar.h>
+
+#undef DPRINTF
+#ifdef BTMAGIC_DEBUG
+#define        DPRINTF(sc, ...) do {                           \
+       printf("%s: ", device_xname((sc)->sc_dev));     \
+       printf(__VA_ARGS__);                            \
+       printf("\n");                                   \
+} while (/*CONSTCOND*/0)
+#else
+#define        DPRINTF(...)    (void)0
+#endif



Home | Main Index | Thread Index | Old Index