2
* Copyright (c) 1998 Metro Link Incorporated
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
* THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* Except as contained in this notice, the name of the Metro Link shall not be
23
* used in advertising or otherwise to promote the sale, use or other dealings
24
* in this Software without prior written authorization from Metro Link.
27
/* $XFree86: xc/programs/Xserver/hw/xfree86/input/magellan/magellan.h,v 1.4 2002/06/07 21:03:27 alanh Exp $ */
32
/******************************************************************************
34
* structs, typedefs, #defines, enums
35
*****************************************************************************/
36
#define MAGELLAN_PACKET_SIZE 256
37
#define MAGELLAN_RES 200
39
These numbers are difficult to pick because the user can change a
40
multiplier using the buttons which changes the output range. However, many
41
programs use this range to perform operations of their own and the XInput
42
extension expects these to be constant for a given device. Hence, I've picked
43
values that are slightly higher than any reported by my test device in default
44
(no multiplier) mode. The documentation says the range is roughly +/- 400 but
45
I have seen numbers close to 1800 using the "sensitivity" setting as set below.
46
Some programs (GLUT) may get upset if the device reports a value greater than
47
XInput reported it could.
49
#define MAGELLAN_MIN -1800
50
#define MAGELLAN_MAX +1800
52
#define MagellanAttention "\r\r" /* get device's attention */
53
#define MagellanInitString "z\r" /* switch in 3D mode */
54
#define MagellanShortBeep "b9\r" /* a short beep */
55
#define MagellanMode "m3\r" /* translation and rotation data ON */
56
#define MagellanPeriod "pAA\r" /* transmit every 60 ms data */
57
#define MagellanNullRadius "nH\r" /* null radius to value 8 */
58
#define MagellanZero "z\r" /* detect zero position */
59
#define MagellanSensitivity "q00\r" /* no extra sensitivity */
60
#define MagellanVersion "vQ\r" /* get version string */
61
#define MagellanModeOff "\r\rm0\r"
69
#define MagellanNibble(Value) (Value&0x0F)
71
#define milisleep(ms) xf86usleep (ms * 1000)
73
typedef struct _MagellanPrivateRec
76
unsigned char packet_type;
77
char packet[MAGELLAN_PACKET_SIZE]; /* packet being/just read */
78
int packeti; /* index into packet */
80
MAGELLANState lex_mode;
83
MAGELLANPrivateRec, *MAGELLANPrivatePtr;
85
/******************************************************************************
87
*****************************************************************************/
89
static MODULESETUPPROTO( MAGELLANSetupProc );
90
static void TearDownProc (pointer p);
92
static Bool DeviceControl (DeviceIntPtr, int);
93
static Bool DeviceOn (DeviceIntPtr);
94
static Bool DeviceOff (DeviceIntPtr);
95
static Bool DeviceClose (DeviceIntPtr);
96
static Bool DeviceInit (DeviceIntPtr);
97
static void ReadInput (LocalDevicePtr);
98
static int ControlProc (LocalDevicePtr, xDeviceCtl *);
99
static void CloseProc (LocalDevicePtr);
100
static int SwitchMode (ClientPtr, DeviceIntPtr, int);
101
static Bool ConvertProc (LocalDevicePtr, int, int, int, int, int, int, int, int, int *, int *);
102
static Bool QueryHardware (MAGELLANPrivatePtr);
103
static void NewPacket (MAGELLANPrivatePtr priv);
104
static Bool MAGELLANGetPacket (MAGELLANPrivatePtr priv);
107
MagellanPreInit(InputDriverPtr drv, IDevPtr dev, int flags);
109
#ifdef BELL_FEEDBACK_SUPPORT
110
static void MagellanBellCtrl( DeviceIntPtr, BellCtrl *);
111
static void MagellanBellSound(int percent, DeviceIntPtr dev, pointer ctrl, int
115
* DO NOT PUT ANYTHING AFTER THIS ENDIF