mouse.h revision 48778
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 * 2348778Syokota * $Id: mouse.h,v 1.12 1999/02/21 16:08:43 n_hibma 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 11831603Syokota 11919753Ssostypedef struct mousemode { 12019753Ssos int protocol; /* MOUSE_PROTO_XXX */ 12119753Ssos int rate; /* report rate (per sec), -1 if unknown */ 12231603Syokota int resolution; /* MOUSE_RES_XXX, -1 if unknown */ 12319753Ssos int accelfactor; /* accelation factor (must be 1 or greater) */ 12431603Syokota int level; /* driver operation level */ 12531603Syokota int packetsize; /* the length of the data packet */ 12631603Syokota unsigned char syncmask[2]; /* sync. data bits in the header byte */ 12719753Ssos} mousemode_t; 12821327Snate 12919753Ssos/* protocol */ 13031603Syokota#define MOUSE_PROTO_UNKNOWN (-1) 13119753Ssos#define MOUSE_PROTO_MS 0 /* Microsoft Serial, 3 bytes */ 13219753Ssos#define MOUSE_PROTO_MSC 1 /* Mouse Systems, 5 bytes */ 13319753Ssos#define MOUSE_PROTO_LOGI 2 /* Logitech, 3 bytes */ 13419753Ssos#define MOUSE_PROTO_MM 3 /* MM series, 3 bytes */ 13519753Ssos#define MOUSE_PROTO_LOGIMOUSEMAN 4 /* Logitech MouseMan 3/4 bytes */ 13619753Ssos#define MOUSE_PROTO_BUS 5 /* MS/Logitech bus mouse */ 13731603Syokota#define MOUSE_PROTO_INPORT 6 /* MS/ATI InPort mouse */ 13819753Ssos#define MOUSE_PROTO_PS2 7 /* PS/2 mouse, 3 bytes */ 13931603Syokota#define MOUSE_PROTO_HITTAB 8 /* Hitachi Tablet 3 bytes */ 14031603Syokota#define MOUSE_PROTO_GLIDEPOINT 9 /* ALPS GlidePoint, 3/4 bytes */ 14131603Syokota#define MOUSE_PROTO_INTELLI 10 /* MS IntelliMouse, 4 bytes */ 14231603Syokota#define MOUSE_PROTO_THINK 11 /* Kensignton Thinking Mouse, 3/4 bytes */ 14331603Syokota#define MOUSE_PROTO_SYSMOUSE 12 /* /dev/sysmouse */ 14436991Sahasty#define MOUSE_PROTO_X10MOUSEREM 13 /* X10 MouseRemote, 3 bytes */ 14541271Syokota#define MOUSE_PROTO_KIDSPAD 14 /* Genius Kidspad */ 14619753Ssos 14731603Syokota#define MOUSE_RES_UNKNOWN (-1) 14831603Syokota#define MOUSE_RES_DEFAULT 0 14931603Syokota#define MOUSE_RES_LOW (-2) 15031603Syokota#define MOUSE_RES_MEDIUMLOW (-3) 15131603Syokota#define MOUSE_RES_MEDIUMHIGH (-4) 15231603Syokota#define MOUSE_RES_HIGH (-5) 15331603Syokota 15431603Syokotatypedef struct mousedata { 15531603Syokota int len; /* # of data in the buffer */ 15631603Syokota int buf[16]; /* data buffer */ 15731603Syokota} mousedata_t; 15831603Syokota 15931603Syokota#if (defined(MOUSE_GETVARS)) 16031603Syokota 16131603Syokotatypedef struct mousevar { 16231603Syokota int var[16]; 16331603Syokota} mousevar_t; 16431603Syokota 16531603Syokota/* magic numbers in var[0] */ 16631603Syokota#define MOUSE_VARS_PS2_SIG 0x00325350 /* 'PS2' */ 16731603Syokota#define MOUSE_VARS_BUS_SIG 0x00535542 /* 'BUS' */ 16831603Syokota#define MOUSE_VARS_INPORT_SIG 0x00504e49 /* 'INP' */ 16931603Syokota 17031603Syokota#endif /* MOUSE_GETVARS */ 17131603Syokota 17219753Ssos/* Microsoft Serial mouse data packet */ 17319753Ssos#define MOUSE_MSS_PACKETSIZE 3 17419753Ssos#define MOUSE_MSS_SYNCMASK 0x40 17519753Ssos#define MOUSE_MSS_SYNC 0x40 17619753Ssos#define MOUSE_MSS_BUTTONS 0x30 17719753Ssos#define MOUSE_MSS_BUTTON1DOWN 0x20 /* left */ 17819753Ssos#define MOUSE_MSS_BUTTON2DOWN 0x00 /* no middle button */ 17919753Ssos#define MOUSE_MSS_BUTTON3DOWN 0x10 /* right */ 18019753Ssos 18120073Ssos/* Logitech MouseMan data packet (M+ protocol) */ 18231603Syokota#define MOUSE_LMAN_BUTTON2DOWN 0x20 /* middle button, the 4th byte */ 18320073Ssos 18431603Syokota/* ALPS GlidePoint extention (variant of M+ protocol) */ 18531603Syokota#define MOUSE_ALPS_BUTTON2DOWN 0x20 /* middle button, the 4th byte */ 18631603Syokota#define MOUSE_ALPS_TAP 0x10 /* `tapping' action, the 4th byte */ 18731603Syokota 18831603Syokota/* Kinsington Thinking Mouse extention (variant of M+ protocol) */ 18931603Syokota#define MOUSE_THINK_BUTTON2DOWN 0x20 /* lower-left button, the 4th byte */ 19031603Syokota#define MOUSE_THINK_BUTTON4DOWN 0x10 /* lower-right button, the 4th byte */ 19131603Syokota 19231603Syokota/* MS IntelliMouse (variant of MS Serial) */ 19331603Syokota#define MOUSE_INTELLI_PACKETSIZE 4 19431603Syokota#define MOUSE_INTELLI_BUTTON2DOWN 0x10 /* middle button the 4th byte */ 19531603Syokota 19619753Ssos/* Mouse Systems Corp. mouse data packet */ 19719753Ssos#define MOUSE_MSC_PACKETSIZE 5 19819753Ssos#define MOUSE_MSC_SYNCMASK 0xf8 19919753Ssos#define MOUSE_MSC_SYNC 0x80 20019753Ssos#define MOUSE_MSC_BUTTONS 0x07 20119753Ssos#define MOUSE_MSC_BUTTON1UP 0x04 /* left */ 20219753Ssos#define MOUSE_MSC_BUTTON2UP 0x02 /* middle */ 20319753Ssos#define MOUSE_MSC_BUTTON3UP 0x01 /* right */ 20444186Sn_hibma#define MOUSE_MSC_MAXBUTTON 3 20519753Ssos 20620073Ssos/* MM series mouse data packet */ 20720073Ssos#define MOUSE_MM_PACKETSIZE 3 20820073Ssos#define MOUSE_MM_SYNCMASK 0xe0 20920073Ssos#define MOUSE_MM_SYNC 0x80 21020073Ssos#define MOUSE_MM_BUTTONS 0x07 21120073Ssos#define MOUSE_MM_BUTTON1DOWN 0x04 /* left */ 21220073Ssos#define MOUSE_MM_BUTTON2DOWN 0x02 /* middle */ 21320073Ssos#define MOUSE_MM_BUTTON3DOWN 0x01 /* right */ 21420073Ssos#define MOUSE_MM_XPOSITIVE 0x10 21520073Ssos#define MOUSE_MM_YPOSITIVE 0x08 21620073Ssos 21719753Ssos/* PS/2 mouse data packet */ 21819753Ssos#define MOUSE_PS2_PACKETSIZE 3 21931603Syokota#define MOUSE_PS2_SYNCMASK 0xc8 22031603Syokota#define MOUSE_PS2_SYNC 0x08 22119753Ssos#define MOUSE_PS2_BUTTONS 0x07 /* 0x03 for 2 button mouse */ 22219753Ssos#define MOUSE_PS2_BUTTON1DOWN 0x01 /* left */ 22319753Ssos#define MOUSE_PS2_BUTTON2DOWN 0x04 /* middle */ 22419753Ssos#define MOUSE_PS2_BUTTON3DOWN 0x02 /* right */ 22531603Syokota#define MOUSE_PS2_TAP MOUSE_PS2_SYNC /* GlidePoint (PS/2) `tapping' 22631603Syokota * Yes! this is the same bit 22731603Syokota * as SYNC! 22831603Syokota */ 22931603Syokota#define MOUSE_PS2PLUS_BUTTON4DOWN 0x10 /* 4th button on MouseMan+ */ 23048778Syokota#define MOUSE_PS2PLUS_BUTTON5DOWN 0x20 23131603Syokota 23219753Ssos#define MOUSE_PS2_XNEG 0x10 23319753Ssos#define MOUSE_PS2_YNEG 0x20 23419753Ssos#define MOUSE_PS2_XOVERFLOW 0x40 23519753Ssos#define MOUSE_PS2_YOVERFLOW 0x80 23631603Syokota#define MOUSE_PS2PLUS_ZNEG 0x08 /* MouseMan+ negative wheel movement */ 23748778Syokota#define MOUSE_PS2PLUS_SYNCMASK 0x48 23848778Syokota#define MOUSE_PS2PLUS_SYNC 0x48 23919753Ssos 24031603Syokota/* sysmouse extended data packet */ 24131603Syokota/* 24231603Syokota * /dev/sysmouse sends data in two formats, depending on the protocol 24331603Syokota * level. At the level 0, format is exactly the same as MousSystems' 24431603Syokota * five byte packet. At the level 1, the first five bytes are the same 24531603Syokota * as at the level 0. There are additional three bytes which shows 24631603Syokota * `dz' and the states of additional buttons. `dz' is expressed as the 24731603Syokota * sum of the byte 5 and 6 which contain signed seven bit values. 24831603Syokota * The states of the button 4 though 10 are in the bit 0 though 6 in 24931603Syokota * the byte 7 respectively: 1 indicates the button is up. 25031603Syokota */ 25131603Syokota#define MOUSE_SYS_PACKETSIZE 8 25231603Syokota#define MOUSE_SYS_SYNCMASK 0xf8 25331603Syokota#define MOUSE_SYS_SYNC 0x80 25431603Syokota#define MOUSE_SYS_BUTTON1UP 0x04 /* left, 1st byte */ 25531603Syokota#define MOUSE_SYS_BUTTON2UP 0x02 /* middle, 1st byte */ 25631603Syokota#define MOUSE_SYS_BUTTON3UP 0x01 /* right, 1st byte */ 25731603Syokota#define MOUSE_SYS_BUTTON4UP 0x0001 /* 7th byte */ 25831603Syokota#define MOUSE_SYS_BUTTON5UP 0x0002 25931603Syokota#define MOUSE_SYS_BUTTON6UP 0x0004 26031603Syokota#define MOUSE_SYS_BUTTON7UP 0x0008 26131603Syokota#define MOUSE_SYS_BUTTON8UP 0x0010 26231603Syokota#define MOUSE_SYS_BUTTON9UP 0x0020 26331603Syokota#define MOUSE_SYS_BUTTON10UP 0x0040 26431603Syokota#define MOUSE_SYS_MAXBUTTON 10 26531603Syokota#define MOUSE_SYS_STDBUTTONS 0x07 26631603Syokota#define MOUSE_SYS_EXTBUTTONS 0x7f /* the others */ 26731603Syokota 26836991Sahasty/* Mouse remote socket */ 26936991Sahasty#define _PATH_MOUSEREMOTE "/var/run/MouseRemote" 27036991Sahasty 27119753Ssos#endif /* _MACHINE_MOUSE_H_ */ 272