mouse.h revision 49964
12606Sdfr/*- 22606Sdfr * Copyright (c) 1992, 1993 Erik Forsberg. 331603Syokota * Copyright (c) 1996, 1997 Kazutaka YOKOTA 42606Sdfr * All rights reserved. 52606Sdfr * 62606Sdfr * Redistribution and use in source and binary forms, with or without 72606Sdfr * modification, are permitted provided that the following conditions 82606Sdfr * are met: 92606Sdfr * 1. Redistributions of source code must retain the above copyright 102606Sdfr * notice, this list of conditions and the following disclaimer. 112606Sdfr * 122606Sdfr * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED 132606Sdfr * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 142606Sdfr * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 152606Sdfr * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 162606Sdfr * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 172606Sdfr * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 182606Sdfr * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 192606Sdfr * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 202606Sdfr * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 212606Sdfr * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 222606Sdfr * 2349964Syokota * $Id: mouse.h,v 1.13 1999/07/12 15:16:12 yokota Exp $ 242606Sdfr */ 252606Sdfr 2619753Ssos#ifndef _MACHINE_MOUSE_H_ 2719753Ssos#define _MACHINE_MOUSE_H_ 2819753Ssos 2919753Ssos#include <sys/types.h> 3019753Ssos#include <sys/ioccom.h> 3119753Ssos 3231603Syokota/* ioctls */ 3331603Syokota#define MOUSE_GETSTATUS _IOR('M', 0, mousestatus_t) 3431603Syokota#define MOUSE_GETHWINFO _IOR('M', 1, mousehw_t) 3531603Syokota#define MOUSE_GETMODE _IOR('M', 2, mousemode_t) 3631603Syokota#define MOUSE_SETMODE _IOW('M', 3, mousemode_t) 3731603Syokota#define MOUSE_GETLEVEL _IOR('M', 4, int) 3831603Syokota#define MOUSE_SETLEVEL _IOW('M', 5, int) 3931603Syokota#define MOUSE_GETVARS _IOR('M', 6, mousevar_t) 4031603Syokota#define MOUSE_SETVARS _IOW('M', 7, mousevar_t) 4131603Syokota#define MOUSE_READSTATE _IOWR('M', 8, mousedata_t) 4231603Syokota#define MOUSE_READDATA _IOWR('M', 9, mousedata_t) 4319753Ssos 4431603Syokota#if notyet 4531603Syokota#define MOUSE_SETRESOLUTION _IOW('M', 10, int) 4631603Syokota#define MOUSE_SETSCALING _IOW('M', 11, int) 4731603Syokota#define MOUSE_SETRATE _IOW('M', 12, int) 4831603Syokota#define MOUSE_GETHWID _IOR('M', 13, int) 4931603Syokota#endif 5019753Ssos 5120073Ssos/* mouse status block */ 5220073Ssostypedef struct mousestatus { 5331603Syokota int flags; /* state change flags */ 5420073Ssos int button; /* button status */ 5520073Ssos int obutton; /* previous button status */ 5620073Ssos int dx; /* x movement */ 5720073Ssos int dy; /* y movement */ 5831603Syokota int dz; /* z movement */ 5920073Ssos} mousestatus_t; 6021327Snate 6120073Ssos/* button */ 6220073Ssos#define MOUSE_BUTTON1DOWN 0x0001 /* left */ 6320073Ssos#define MOUSE_BUTTON2DOWN 0x0002 /* middle */ 6420073Ssos#define MOUSE_BUTTON3DOWN 0x0004 /* right */ 6520073Ssos#define MOUSE_BUTTON4DOWN 0x0008 6620073Ssos#define MOUSE_BUTTON5DOWN 0x0010 6720073Ssos#define MOUSE_BUTTON6DOWN 0x0020 6820073Ssos#define MOUSE_BUTTON7DOWN 0x0040 6920073Ssos#define MOUSE_BUTTON8DOWN 0x0080 7031603Syokota#define MOUSE_MAXBUTTON 31 7131603Syokota#define MOUSE_STDBUTTONS 0x0007 /* buttons 1-3 */ 7231603Syokota#define MOUSE_EXTBUTTONS 0x7ffffff8 /* the others (28 of them!) */ 7331603Syokota#define MOUSE_BUTTONS (MOUSE_STDBUTTONS | MOUSE_EXTBUTTONS) 7420073Ssos 7531603Syokota/* flags */ 7631603Syokota#define MOUSE_STDBUTTONSCHANGED MOUSE_STDBUTTONS 7731603Syokota#define MOUSE_EXTBUTTONSCHANGED MOUSE_EXTBUTTONS 7831603Syokota#define MOUSE_BUTTONSCHANGED MOUSE_BUTTONS 7931603Syokota#define MOUSE_POSCHANGED 0x80000000 8031603Syokota 8119753Ssostypedef struct mousehw { 8231603Syokota int buttons; /* -1 if unknown */ 8319753Ssos int iftype; /* MOUSE_IF_XXX */ 8419753Ssos int type; /* mouse/track ball/pad... */ 8531603Syokota int model; /* I/F dependent model ID: MOUSE_MODEL_XXX */ 8619753Ssos int hwid; /* I/F dependent hardware ID 8721327Snate * for the PS/2 mouse, it will be PSM_XXX_ID 8821327Snate */ 8919753Ssos} mousehw_t; 9021327Snate 9119753Ssos/* iftype */ 9231603Syokota#define MOUSE_IF_UNKNOWN (-1) 9319753Ssos#define MOUSE_IF_SERIAL 0 9419753Ssos#define MOUSE_IF_BUS 1 9519753Ssos#define MOUSE_IF_INPORT 2 9619753Ssos#define MOUSE_IF_PS2 3 9731603Syokota#define MOUSE_IF_SYSMOUSE 4 9844186Sn_hibma#define MOUSE_IF_USB 5 9921327Snate 10019753Ssos/* type */ 10119753Ssos#define MOUSE_UNKNOWN (-1) /* should be treated as a mouse */ 10219753Ssos#define MOUSE_MOUSE 0 10319753Ssos#define MOUSE_TRACKBALL 1 10419753Ssos#define MOUSE_STICK 2 10519753Ssos#define MOUSE_PAD 3 1062606Sdfr 10731603Syokota/* model */ 10831603Syokota#define MOUSE_MODEL_UNKNOWN (-1) 10931603Syokota#define MOUSE_MODEL_GENERIC 0 11031603Syokota#define MOUSE_MODEL_GLIDEPOINT 1 11131603Syokota#define MOUSE_MODEL_NETSCROLL 2 11231603Syokota#define MOUSE_MODEL_NET 3 11331603Syokota#define MOUSE_MODEL_INTELLI 4 11431603Syokota#define MOUSE_MODEL_THINK 5 11531603Syokota#define MOUSE_MODEL_EASYSCROLL 6 11631603Syokota#define MOUSE_MODEL_MOUSEMANPLUS 7 11741271Syokota#define MOUSE_MODEL_KIDSPAD 8 11849964Syokota#define MOUSE_MODEL_VERSAPAD 9 11931603Syokota 12019753Ssostypedef struct mousemode { 12119753Ssos int protocol; /* MOUSE_PROTO_XXX */ 12219753Ssos int rate; /* report rate (per sec), -1 if unknown */ 12331603Syokota int resolution; /* MOUSE_RES_XXX, -1 if unknown */ 12419753Ssos int accelfactor; /* accelation factor (must be 1 or greater) */ 12531603Syokota int level; /* driver operation level */ 12631603Syokota int packetsize; /* the length of the data packet */ 12731603Syokota unsigned char syncmask[2]; /* sync. data bits in the header byte */ 12819753Ssos} mousemode_t; 12921327Snate 13019753Ssos/* protocol */ 13131603Syokota#define MOUSE_PROTO_UNKNOWN (-1) 13219753Ssos#define MOUSE_PROTO_MS 0 /* Microsoft Serial, 3 bytes */ 13319753Ssos#define MOUSE_PROTO_MSC 1 /* Mouse Systems, 5 bytes */ 13419753Ssos#define MOUSE_PROTO_LOGI 2 /* Logitech, 3 bytes */ 13519753Ssos#define MOUSE_PROTO_MM 3 /* MM series, 3 bytes */ 13619753Ssos#define MOUSE_PROTO_LOGIMOUSEMAN 4 /* Logitech MouseMan 3/4 bytes */ 13719753Ssos#define MOUSE_PROTO_BUS 5 /* MS/Logitech bus mouse */ 13831603Syokota#define MOUSE_PROTO_INPORT 6 /* MS/ATI InPort mouse */ 13919753Ssos#define MOUSE_PROTO_PS2 7 /* PS/2 mouse, 3 bytes */ 14031603Syokota#define MOUSE_PROTO_HITTAB 8 /* Hitachi Tablet 3 bytes */ 14131603Syokota#define MOUSE_PROTO_GLIDEPOINT 9 /* ALPS GlidePoint, 3/4 bytes */ 14231603Syokota#define MOUSE_PROTO_INTELLI 10 /* MS IntelliMouse, 4 bytes */ 14331603Syokota#define MOUSE_PROTO_THINK 11 /* Kensignton Thinking Mouse, 3/4 bytes */ 14431603Syokota#define MOUSE_PROTO_SYSMOUSE 12 /* /dev/sysmouse */ 14536991Sahasty#define MOUSE_PROTO_X10MOUSEREM 13 /* X10 MouseRemote, 3 bytes */ 14641271Syokota#define MOUSE_PROTO_KIDSPAD 14 /* Genius Kidspad */ 14749964Syokota#define MOUSE_PROTO_VERSAPAD 15 /* Interlink VersaPad, 6 bytes */ 14819753Ssos 14931603Syokota#define MOUSE_RES_UNKNOWN (-1) 15031603Syokota#define MOUSE_RES_DEFAULT 0 15131603Syokota#define MOUSE_RES_LOW (-2) 15231603Syokota#define MOUSE_RES_MEDIUMLOW (-3) 15331603Syokota#define MOUSE_RES_MEDIUMHIGH (-4) 15431603Syokota#define MOUSE_RES_HIGH (-5) 15531603Syokota 15631603Syokotatypedef struct mousedata { 15731603Syokota int len; /* # of data in the buffer */ 15831603Syokota int buf[16]; /* data buffer */ 15931603Syokota} mousedata_t; 16031603Syokota 16131603Syokota#if (defined(MOUSE_GETVARS)) 16231603Syokota 16331603Syokotatypedef struct mousevar { 16431603Syokota int var[16]; 16531603Syokota} mousevar_t; 16631603Syokota 16731603Syokota/* magic numbers in var[0] */ 16831603Syokota#define MOUSE_VARS_PS2_SIG 0x00325350 /* 'PS2' */ 16931603Syokota#define MOUSE_VARS_BUS_SIG 0x00535542 /* 'BUS' */ 17031603Syokota#define MOUSE_VARS_INPORT_SIG 0x00504e49 /* 'INP' */ 17131603Syokota 17231603Syokota#endif /* MOUSE_GETVARS */ 17331603Syokota 17419753Ssos/* Microsoft Serial mouse data packet */ 17519753Ssos#define MOUSE_MSS_PACKETSIZE 3 17619753Ssos#define MOUSE_MSS_SYNCMASK 0x40 17719753Ssos#define MOUSE_MSS_SYNC 0x40 17819753Ssos#define MOUSE_MSS_BUTTONS 0x30 17919753Ssos#define MOUSE_MSS_BUTTON1DOWN 0x20 /* left */ 18019753Ssos#define MOUSE_MSS_BUTTON2DOWN 0x00 /* no middle button */ 18119753Ssos#define MOUSE_MSS_BUTTON3DOWN 0x10 /* right */ 18219753Ssos 18320073Ssos/* Logitech MouseMan data packet (M+ protocol) */ 18431603Syokota#define MOUSE_LMAN_BUTTON2DOWN 0x20 /* middle button, the 4th byte */ 18520073Ssos 18631603Syokota/* ALPS GlidePoint extention (variant of M+ protocol) */ 18731603Syokota#define MOUSE_ALPS_BUTTON2DOWN 0x20 /* middle button, the 4th byte */ 18831603Syokota#define MOUSE_ALPS_TAP 0x10 /* `tapping' action, the 4th byte */ 18931603Syokota 19031603Syokota/* Kinsington Thinking Mouse extention (variant of M+ protocol) */ 19131603Syokota#define MOUSE_THINK_BUTTON2DOWN 0x20 /* lower-left button, the 4th byte */ 19231603Syokota#define MOUSE_THINK_BUTTON4DOWN 0x10 /* lower-right button, the 4th byte */ 19331603Syokota 19431603Syokota/* MS IntelliMouse (variant of MS Serial) */ 19531603Syokota#define MOUSE_INTELLI_PACKETSIZE 4 19631603Syokota#define MOUSE_INTELLI_BUTTON2DOWN 0x10 /* middle button the 4th byte */ 19731603Syokota 19819753Ssos/* Mouse Systems Corp. mouse data packet */ 19919753Ssos#define MOUSE_MSC_PACKETSIZE 5 20019753Ssos#define MOUSE_MSC_SYNCMASK 0xf8 20119753Ssos#define MOUSE_MSC_SYNC 0x80 20219753Ssos#define MOUSE_MSC_BUTTONS 0x07 20319753Ssos#define MOUSE_MSC_BUTTON1UP 0x04 /* left */ 20419753Ssos#define MOUSE_MSC_BUTTON2UP 0x02 /* middle */ 20519753Ssos#define MOUSE_MSC_BUTTON3UP 0x01 /* right */ 20644186Sn_hibma#define MOUSE_MSC_MAXBUTTON 3 20719753Ssos 20820073Ssos/* MM series mouse data packet */ 20920073Ssos#define MOUSE_MM_PACKETSIZE 3 21020073Ssos#define MOUSE_MM_SYNCMASK 0xe0 21120073Ssos#define MOUSE_MM_SYNC 0x80 21220073Ssos#define MOUSE_MM_BUTTONS 0x07 21320073Ssos#define MOUSE_MM_BUTTON1DOWN 0x04 /* left */ 21420073Ssos#define MOUSE_MM_BUTTON2DOWN 0x02 /* middle */ 21520073Ssos#define MOUSE_MM_BUTTON3DOWN 0x01 /* right */ 21620073Ssos#define MOUSE_MM_XPOSITIVE 0x10 21720073Ssos#define MOUSE_MM_YPOSITIVE 0x08 21820073Ssos 21919753Ssos/* PS/2 mouse data packet */ 22019753Ssos#define MOUSE_PS2_PACKETSIZE 3 22131603Syokota#define MOUSE_PS2_SYNCMASK 0xc8 22231603Syokota#define MOUSE_PS2_SYNC 0x08 22319753Ssos#define MOUSE_PS2_BUTTONS 0x07 /* 0x03 for 2 button mouse */ 22419753Ssos#define MOUSE_PS2_BUTTON1DOWN 0x01 /* left */ 22519753Ssos#define MOUSE_PS2_BUTTON2DOWN 0x04 /* middle */ 22619753Ssos#define MOUSE_PS2_BUTTON3DOWN 0x02 /* right */ 22731603Syokota#define MOUSE_PS2_TAP MOUSE_PS2_SYNC /* GlidePoint (PS/2) `tapping' 22831603Syokota * Yes! this is the same bit 22931603Syokota * as SYNC! 23031603Syokota */ 23131603Syokota#define MOUSE_PS2PLUS_BUTTON4DOWN 0x10 /* 4th button on MouseMan+ */ 23248778Syokota#define MOUSE_PS2PLUS_BUTTON5DOWN 0x20 23331603Syokota 23419753Ssos#define MOUSE_PS2_XNEG 0x10 23519753Ssos#define MOUSE_PS2_YNEG 0x20 23619753Ssos#define MOUSE_PS2_XOVERFLOW 0x40 23719753Ssos#define MOUSE_PS2_YOVERFLOW 0x80 23831603Syokota#define MOUSE_PS2PLUS_ZNEG 0x08 /* MouseMan+ negative wheel movement */ 23948778Syokota#define MOUSE_PS2PLUS_SYNCMASK 0x48 24048778Syokota#define MOUSE_PS2PLUS_SYNC 0x48 24119753Ssos 24249964Syokota/* Interlink VersaPad (serial I/F) data packet */ 24349964Syokota#define MOUSE_VERSA_PACKETSIZE 6 24449964Syokota#define MOUSE_VERSA_IN_USE 0x04 24549964Syokota#define MOUSE_VERSA_SYNCMASK 0xc3 24649964Syokota#define MOUSE_VERSA_SYNC 0xc0 24749964Syokota#define MOUSE_VERSA_BUTTONS 0x30 24849964Syokota#define MOUSE_VERSA_BUTTON1DOWN 0x20 /* left */ 24949964Syokota#define MOUSE_VERSA_BUTTON2DOWN 0x00 /* middle */ 25049964Syokota#define MOUSE_VERSA_BUTTON3DOWN 0x10 /* right */ 25149964Syokota#define MOUSE_VERSA_TAP 0x08 25249964Syokota 25349964Syokota/* Interlink VersaPad (PS/2 I/F) data packet */ 25449964Syokota#define MOUSE_PS2VERSA_PACKETSIZE 6 25549964Syokota#define MOUSE_PS2VERSA_IN_USE 0x10 25649964Syokota#define MOUSE_PS2VERSA_SYNCMASK 0xe8 25749964Syokota#define MOUSE_PS2VERSA_SYNC 0xc8 25849964Syokota#define MOUSE_PS2VERSA_BUTTONS 0x05 25949964Syokota#define MOUSE_PS2VERSA_BUTTON1DOWN 0x04 /* left */ 26049964Syokota#define MOUSE_PS2VERSA_BUTTON2DOWN 0x00 /* middle */ 26149964Syokota#define MOUSE_PS2VERSA_BUTTON3DOWN 0x01 /* right */ 26249964Syokota#define MOUSE_PS2VERSA_TAP 0x02 26349964Syokota 26431603Syokota/* sysmouse extended data packet */ 26531603Syokota/* 26631603Syokota * /dev/sysmouse sends data in two formats, depending on the protocol 26731603Syokota * level. At the level 0, format is exactly the same as MousSystems' 26831603Syokota * five byte packet. At the level 1, the first five bytes are the same 26931603Syokota * as at the level 0. There are additional three bytes which shows 27031603Syokota * `dz' and the states of additional buttons. `dz' is expressed as the 27131603Syokota * sum of the byte 5 and 6 which contain signed seven bit values. 27231603Syokota * The states of the button 4 though 10 are in the bit 0 though 6 in 27331603Syokota * the byte 7 respectively: 1 indicates the button is up. 27431603Syokota */ 27531603Syokota#define MOUSE_SYS_PACKETSIZE 8 27631603Syokota#define MOUSE_SYS_SYNCMASK 0xf8 27731603Syokota#define MOUSE_SYS_SYNC 0x80 27831603Syokota#define MOUSE_SYS_BUTTON1UP 0x04 /* left, 1st byte */ 27931603Syokota#define MOUSE_SYS_BUTTON2UP 0x02 /* middle, 1st byte */ 28031603Syokota#define MOUSE_SYS_BUTTON3UP 0x01 /* right, 1st byte */ 28131603Syokota#define MOUSE_SYS_BUTTON4UP 0x0001 /* 7th byte */ 28231603Syokota#define MOUSE_SYS_BUTTON5UP 0x0002 28331603Syokota#define MOUSE_SYS_BUTTON6UP 0x0004 28431603Syokota#define MOUSE_SYS_BUTTON7UP 0x0008 28531603Syokota#define MOUSE_SYS_BUTTON8UP 0x0010 28631603Syokota#define MOUSE_SYS_BUTTON9UP 0x0020 28731603Syokota#define MOUSE_SYS_BUTTON10UP 0x0040 28831603Syokota#define MOUSE_SYS_MAXBUTTON 10 28931603Syokota#define MOUSE_SYS_STDBUTTONS 0x07 29031603Syokota#define MOUSE_SYS_EXTBUTTONS 0x7f /* the others */ 29131603Syokota 29236991Sahasty/* Mouse remote socket */ 29336991Sahasty#define _PATH_MOUSEREMOTE "/var/run/MouseRemote" 29436991Sahasty 29519753Ssos#endif /* _MACHINE_MOUSE_H_ */ 296