diff options
author | yokota <yokota@FreeBSD.org> | 1998-11-20 11:22:17 +0000 |
---|---|---|
committer | yokota <yokota@FreeBSD.org> | 1998-11-20 11:22:17 +0000 |
commit | 1f03d6ad7163a25c01f2f7fd49833b3a23de3f0a (patch) | |
tree | e4e1048c05090fc2a0ced8f54a6772ca1e07b0f3 | |
parent | 785bd0be95899a9d27713c569fd11329852496ff (diff) | |
download | FreeBSD-src-1f03d6ad7163a25c01f2f7fd49833b3a23de3f0a.zip FreeBSD-src-1f03d6ad7163a25c01f2f7fd49833b3a23de3f0a.tar.gz |
- Added support for Genius Kidspad tablet.
# `moused' is getting too over-loaded now. If we want something
# more than simple mouse emulation for tablets or remote devices,
# we should start writing a separate daemon...
Submitted by: luigi
-rw-r--r-- | sys/i386/include/mouse.h | 4 | ||||
-rw-r--r-- | sys/sys/mouse.h | 4 | ||||
-rw-r--r-- | usr.sbin/moused/moused.8 | 4 | ||||
-rw-r--r-- | usr.sbin/moused/moused.c | 106 |
4 files changed, 113 insertions, 5 deletions
diff --git a/sys/i386/include/mouse.h b/sys/i386/include/mouse.h index 27ec8e1..b6ecef7 100644 --- a/sys/i386/include/mouse.h +++ b/sys/i386/include/mouse.h @@ -20,7 +20,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: mouse.h,v 1.9 1997/12/07 08:08:50 yokota Exp $ + * $Id: mouse.h,v 1.10 1998/06/14 20:05:22 ahasty Exp $ */ #ifndef _MACHINE_MOUSE_H_ @@ -113,6 +113,7 @@ typedef struct mousehw { #define MOUSE_MODEL_THINK 5 #define MOUSE_MODEL_EASYSCROLL 6 #define MOUSE_MODEL_MOUSEMANPLUS 7 +#define MOUSE_MODEL_KIDSPAD 8 typedef struct mousemode { int protocol; /* MOUSE_PROTO_XXX */ @@ -140,6 +141,7 @@ typedef struct mousemode { #define MOUSE_PROTO_THINK 11 /* Kensignton Thinking Mouse, 3/4 bytes */ #define MOUSE_PROTO_SYSMOUSE 12 /* /dev/sysmouse */ #define MOUSE_PROTO_X10MOUSEREM 13 /* X10 MouseRemote, 3 bytes */ +#define MOUSE_PROTO_KIDSPAD 14 /* Genius Kidspad */ #define MOUSE_RES_UNKNOWN (-1) #define MOUSE_RES_DEFAULT 0 diff --git a/sys/sys/mouse.h b/sys/sys/mouse.h index 27ec8e1..b6ecef7 100644 --- a/sys/sys/mouse.h +++ b/sys/sys/mouse.h @@ -20,7 +20,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: mouse.h,v 1.9 1997/12/07 08:08:50 yokota Exp $ + * $Id: mouse.h,v 1.10 1998/06/14 20:05:22 ahasty Exp $ */ #ifndef _MACHINE_MOUSE_H_ @@ -113,6 +113,7 @@ typedef struct mousehw { #define MOUSE_MODEL_THINK 5 #define MOUSE_MODEL_EASYSCROLL 6 #define MOUSE_MODEL_MOUSEMANPLUS 7 +#define MOUSE_MODEL_KIDSPAD 8 typedef struct mousemode { int protocol; /* MOUSE_PROTO_XXX */ @@ -140,6 +141,7 @@ typedef struct mousemode { #define MOUSE_PROTO_THINK 11 /* Kensignton Thinking Mouse, 3/4 bytes */ #define MOUSE_PROTO_SYSMOUSE 12 /* /dev/sysmouse */ #define MOUSE_PROTO_X10MOUSEREM 13 /* X10 MouseRemote, 3 bytes */ +#define MOUSE_PROTO_KIDSPAD 14 /* Genius Kidspad */ #define MOUSE_RES_UNKNOWN (-1) #define MOUSE_RES_DEFAULT 0 diff --git a/usr.sbin/moused/moused.8 b/usr.sbin/moused/moused.8 index 70d1876..64cd108 100644 --- a/usr.sbin/moused/moused.8 +++ b/usr.sbin/moused/moused.8 @@ -28,7 +28,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: moused.8,v 1.16 1998/09/17 09:51:15 dwhite Exp $ +.\" $Id: moused.8,v 1.17 1998/11/20 11:19:20 yokota Exp $ .\" .Dd December 3, 1997 .Dt MOUSED 8 @@ -260,6 +260,8 @@ Kensington ThinkingMouse protocol. Hitachi tablet protocol. .It Ar x10mouseremote X10 MouseRemote. +.It Ar kidspad +Genius Kidspad and Easypad protocol. .El .Pp For the bus and InPort mouse: diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c index bc8e16f..21caca1 100644 --- a/usr.sbin/moused/moused.c +++ b/usr.sbin/moused/moused.c @@ -46,7 +46,7 @@ #ifndef lint static const char rcsid[] = - "$Id: moused.c,v 1.21 1998/11/20 11:17:59 yokota Exp $"; + "$Id: moused.c,v 1.22 1998/11/20 11:19:20 yokota Exp $"; #endif /* not lint */ #include <err.h> @@ -187,6 +187,7 @@ static char *rnames[] = { "thinkingmouse", "sysmouse", "x10mouseremote", + "kidspad", #if notyet "mariqua", #endif @@ -202,6 +203,7 @@ static symtab_t rmodels[] = { { "IntelliMouse", MOUSE_MODEL_INTELLI }, { "EasyScroll", MOUSE_MODEL_EASYSCROLL }, { "MouseMan+", MOUSE_MODEL_MOUSEMANPLUS }, + { "Kidspad", MOUSE_MODEL_KIDSPAD }, { "generic", MOUSE_MODEL_GENERIC }, { NULL, MOUSE_MODEL_UNKNOWN }, }; @@ -218,6 +220,8 @@ static symtab_t pnpprod[] = { { "KYE0001", MOUSE_PROTO_MS, MOUSE_MODEL_GENERIC }, /* Genius NetMouse */ { "KYE0003", MOUSE_PROTO_INTELLI, MOUSE_MODEL_NET }, + /* Genius Kidspad, Easypad and other tablets */ + { "KYE0005", MOUSE_PROTO_KIDSPAD, MOUSE_MODEL_KIDSPAD }, /* Genius EZScroll */ { "KYEEZ00", MOUSE_PROTO_MS, MOUSE_MODEL_EASYSCROLL }, /* Logitech MouseMan (new 4 button model) */ @@ -326,6 +330,7 @@ static unsigned short rodentcflags[] = (CS7 | CREAD | CLOCAL | HUPCL ), /* Thinking Mouse */ (CS8 | CSTOPB | CREAD | CLOCAL | HUPCL ), /* sysmouse */ (CS7 | CREAD | CLOCAL | HUPCL ), /* X10 MouseRemote */ + (CS8 | PARENB | PARODD | CREAD | CLOCAL | HUPCL ), /* kidspad etc. */ #if notyet (CS8 | CSTOPB | CREAD | CLOCAL | HUPCL ), /* Mariqua */ #endif @@ -403,6 +408,8 @@ static char *gettokenname(symtab_t *tab, int val); static void mremote_serversetup(); static void mremote_clientchg(int add); +static int kidspad(u_char rxc, mousestatus_t *act); + void main(int argc, char *argv[]) { @@ -877,6 +884,7 @@ static unsigned char proto[][7] = { { 0x40, 0x40, 0x40, 0x00, 3, ~0x33, 0x00 }, /* ThinkingMouse */ { 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff }, /* sysmouse */ { 0x40, 0x40, 0x40, 0x00, 3, ~0x23, 0x00 }, /* X10 MouseRem */ + { 0x80, 0x80, 0x00, 0x00, 5, 0x00, 0xff }, /* KIDSPAD */ #if notyet { 0xf8, 0x80, 0x00, 0x00, 5, ~0x2f, 0x10 }, /* Mariqua */ #endif @@ -1258,6 +1266,8 @@ r_protocol(u_char rBuf, mousestatus_t *act) static unsigned char pBuf[8]; debug("received char 0x%x",(int)rBuf); + if (rodent.rtype == MOUSE_PROTO_KIDSPAD) + return kidspad(rBuf, act) ; /* * Hack for resyncing: We check here for a package that is: @@ -2211,7 +2221,8 @@ pnpproto(pnpid_t *id) int i, j; if (id->nclass > 0) - if (strncmp(id->class, "MOUSE", id->nclass) != 0) + if ( strncmp(id->class, "MOUSE", id->nclass) != 0 && + strncmp(id->class, "TABLET", id->nclass) != 0) /* this is not a mouse! */ return NULL; @@ -2267,6 +2278,97 @@ gettokenname(symtab_t *tab, int val) return NULL; } + +/* + * code to read from the Genius Kidspad tablet. + +The tablet responds to the COM PnP protocol 1.0 with EISA-ID KYE0005, +and to pre-pnp probes (RTS toggle) with 'T' (tablet ?) +9600, 8 bit, parity odd. + +The tablet puts out 5 bytes. b0 (mask 0xb8, value 0xb8) contains +the proximity, tip and button info: + (byte0 & 0x1) true = tip pressed + (byte0 & 0x2) true = button pressed + (byte0 & 0x40) false = pen in proximity of tablet. + +The next 4 bytes are used for coordinates xl, xh, yl, yh (7 bits valid). + +Only absolute coordinates are returned, so we use the following approach: +we store the last coordinates sent when the pen went out of the tablet, + + + * + */ + +typedef enum { + S_IDLE, S_PROXY, S_FIRST, S_DOWN, S_UP +} k_status ; + +static int +kidspad(u_char rxc, mousestatus_t *act) +{ + static buf[5]; + static int buflen = 0, b_prev = 0 , x_prev = -1, y_prev = -1 ; + static k_status status = S_IDLE ; + static struct timeval old, now ; + static int x_idle = -1, y_idle = -1 ; + + int deltat, x, y ; + + if (buflen > 0 && (rxc & 0x80) ) { + fprintf(stderr, "invalid code %d 0x%x\n", buflen, rxc); + buflen = 0 ; + } + if (buflen == 0 && (rxc & 0xb8) != 0xb8 ) { + fprintf(stderr, "invalid code 0 0x%x\n", rxc); + return 0 ; /* invalid code, no action */ + } + buf[buflen++] = rxc ; + if (buflen < 5) + return 0 ; + + buflen = 0 ; /* for next time... */ + + x = buf[1]+128*(buf[2] - 7) ; + if (x < 0) x = 0 ; + y = 28*128 - (buf[3] + 128* (buf[4] - 7)) ; + if (y < 0) y = 0 ; + + x /= 8 ; + y /= 8 ; + + act->flags = 0 ; + act->obutton = act->button ; + act->dx = act->dy = act->dz = 0 ; + gettimeofday(&now, NULL); + if ( buf[0] & 0x40 ) /* pen went out of reach */ + status = S_IDLE ; + else if (status == S_IDLE) { /* pen is newly near the tablet */ + act->flags |= MOUSE_POSCHANGED ; /* force update */ + status = S_PROXY ; + x_prev = x ; + y_prev = y ; + } + old = now ; + act->dx = x - x_prev ; + act->dy = y - y_prev ; + if (act->dx || act->dy) + act->flags |= MOUSE_POSCHANGED ; + x_prev = x ; + y_prev = y ; + if (b_prev != 0 && b_prev != buf[0]) { /* possibly record button change */ + act->button = 0 ; + if ( buf[0] & 0x01 ) /* tip pressed */ + act->button |= MOUSE_BUTTON1DOWN ; + if ( buf[0] & 0x02 ) /* button pressed */ + act->button |= MOUSE_BUTTON2DOWN ; + act->flags |= MOUSE_BUTTONSCHANGED ; + } + b_prev = buf[0] ; + return act->flags ; +} + static void mremote_serversetup() { |