1/*
2 * Copyright 1995-1999 by Frederic Lepied, France. <Lepied@XFree86.org>
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is  hereby granted without fee, provided that
6 * the  above copyright   notice appear  in   all  copies and  that both  that
7 * copyright  notice   and   this  permission   notice  appear  in  supporting
8 * documentation, and that   the  name of  Frederic   Lepied not  be  used  in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific,  written      prior  permission.     Frederic  Lepied   makes  no
11 * representations about the suitability of this software for any purpose.  It
12 * is provided "as is" without express or implied warranty.
13 *
14 * FREDERIC  LEPIED DISCLAIMS ALL   WARRANTIES WITH REGARD  TO  THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED   WARRANTIES OF MERCHANTABILITY  AND   FITNESS, IN NO
16 * EVENT  SHALL FREDERIC  LEPIED BE   LIABLE   FOR ANY  SPECIAL, INDIRECT   OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA  OR PROFITS, WHETHER  IN  AN ACTION OF  CONTRACT,  NEGLIGENCE OR OTHER
19 * TORTIOUS  ACTION, ARISING    OUT OF OR   IN  CONNECTION  WITH THE USE    OR
20 * PERFORMANCE OF THIS SOFTWARE.
21 *
22 */
23
24/*
25 * Copyright (c) 2000-2002 by The XFree86 Project, Inc.
26 *
27 * Permission is hereby granted, free of charge, to any person obtaining a
28 * copy of this software and associated documentation files (the "Software"),
29 * to deal in the Software without restriction, including without limitation
30 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
31 * and/or sell copies of the Software, and to permit persons to whom the
32 * Software is furnished to do so, subject to the following conditions:
33 *
34 * The above copyright notice and this permission notice shall be included in
35 * all copies or substantial portions of the Software.
36 *
37 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
40 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
41 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
42 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
43 * OTHER DEALINGS IN THE SOFTWARE.
44 *
45 * Except as contained in this notice, the name of the copyright holder(s)
46 * and author(s) shall not be used in advertising or otherwise to promote
47 * the sale, use or other dealings in this Software without prior written
48 * authorization from the copyright holder(s) and author(s).
49 */
50
51
52#ifndef _xf86Xinput_h
53#define _xf86Xinput_h
54
55#include "xf86str.h"
56#include "inputstr.h"
57#include <X11/extensions/XI.h>
58#include <X11/extensions/XIproto.h>
59#include "XIstubs.h"
60
61/* Input device flags */
62#define XI86_ALWAYS_CORE	0x04 /* device always controls the pointer */
63/* the device sends Xinput and core pointer events */
64#define XI86_SEND_CORE_EVENTS	XI86_ALWAYS_CORE
65
66/* This holds the input driver entry and module information. */
67typedef struct _InputDriverRec {
68    int			    driverVersion;
69    char *		    driverName;
70    void		    (*Identify)(int flags);
71    int			    (*PreInit)(struct _InputDriverRec *drv,
72				       struct _InputInfoRec* pInfo, int flags);
73    void		    (*UnInit)(struct _InputDriverRec *drv,
74				      struct _InputInfoRec *pInfo,
75				      int flags);
76    pointer		    module;
77    char **		    default_options;
78} InputDriverRec, *InputDriverPtr;
79
80/* This is to input devices what the ScrnInfoRec is to screens. */
81
82typedef struct _InputInfoRec {
83    struct _InputInfoRec *next;
84    char *		    name;
85    char *		    driver;
86
87    int			    flags;
88
89    Bool		    (*device_control)(DeviceIntPtr device, int what);
90    void		    (*read_input)(struct _InputInfoRec *local);
91    int			    (*control_proc)(struct _InputInfoRec *local,
92					   xDeviceCtl *control);
93    int			    (*switch_mode)(ClientPtr client, DeviceIntPtr dev,
94					  int mode);
95    int                     (*set_device_valuators)
96				(struct _InputInfoRec *local,
97				 int *valuators, int first_valuator,
98				 int num_valuators);
99
100    int			    fd;
101    DeviceIntPtr	    dev;
102    pointer		    private;
103    char *		    type_name;
104    InputDriverPtr	    drv;
105    pointer		    module;
106    pointer		    options;
107    InputAttributes         *attrs;
108} *InputInfoPtr;
109
110/* xf86Globals.c */
111extern InputInfoPtr xf86InputDevs;
112
113/* xf86Xinput.c */
114extern _X_EXPORT void xf86PostMotionEvent(DeviceIntPtr device, int is_absolute,
115			 int first_valuator, int num_valuators, ...);
116extern _X_EXPORT void xf86PostMotionEventP(DeviceIntPtr device, int is_absolute,
117			 int first_valuator, int num_valuators, const int *valuators);
118extern _X_EXPORT void xf86PostMotionEventM(DeviceIntPtr device, int is_absolute,
119			 const ValuatorMask *mask);
120extern _X_EXPORT void xf86PostProximityEvent(DeviceIntPtr device, int is_in,
121			    int first_valuator, int num_valuators, ...);
122extern _X_EXPORT void xf86PostProximityEventP(DeviceIntPtr device, int is_in, int first_valuator,
123			     int num_valuators, const int *valuators);
124extern _X_EXPORT void xf86PostProximityEventM(DeviceIntPtr device, int is_in,
125			 const ValuatorMask *mask);
126extern _X_EXPORT void xf86PostButtonEvent(DeviceIntPtr device, int is_absolute, int button,
127		    	 int is_down, int first_valuator, int num_valuators,
128			 ...);
129extern _X_EXPORT void xf86PostButtonEventP(DeviceIntPtr device, int is_absolute, int button,
130			  int is_down, int first_valuator, int num_valuators,
131			  const int *valuators);
132extern _X_EXPORT void xf86PostButtonEventM(DeviceIntPtr device, int is_absolute, int button,
133			  int is_down, const ValuatorMask *mask);
134extern _X_EXPORT void xf86PostKeyEvent(DeviceIntPtr device, unsigned int key_code, int is_down,
135		      int is_absolute, int first_valuator, int num_valuators,
136		      ...);
137extern _X_EXPORT void xf86PostKeyEventM(DeviceIntPtr device, unsigned int key_code, int is_down,
138		       int is_absolute, const ValuatorMask *mask);
139extern _X_EXPORT void xf86PostKeyEventP(DeviceIntPtr device, unsigned int key_code, int is_down,
140		       int is_absolute, int first_valuator, int num_valuators,
141		       const int *valuators);
142extern _X_EXPORT void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code,
143                           int is_down);
144extern _X_EXPORT InputInfoPtr xf86FirstLocalDevice(void);
145extern _X_EXPORT int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min);
146extern _X_EXPORT void xf86XInputSetScreen(InputInfoPtr pInfo, int screen_number, int x, int y);
147extern _X_EXPORT void xf86ProcessCommonOptions(InputInfoPtr pInfo, pointer options);
148extern _X_EXPORT void xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
149				int maxval, int resolution, int min_res,
150				int max_res, int mode);
151extern _X_EXPORT void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum);
152extern _X_EXPORT void xf86AddEnabledDevice(InputInfoPtr pInfo);
153extern _X_EXPORT void xf86RemoveEnabledDevice(InputInfoPtr pInfo);
154extern _X_EXPORT void xf86DisableDevice(DeviceIntPtr dev, Bool panic);
155extern _X_EXPORT void xf86EnableDevice(DeviceIntPtr dev);
156/* not exported */
157int xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL is_auto);
158InputInfoPtr xf86AllocateInput(void);
159
160/* xf86Helper.c */
161extern _X_EXPORT void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags);
162extern _X_EXPORT void xf86DeleteInputDriver(int drvIndex);
163extern _X_EXPORT InputDriverPtr xf86LookupInputDriver(const char *name);
164extern _X_EXPORT InputInfoPtr xf86LookupInput(const char *name);
165extern _X_EXPORT void xf86DeleteInput(InputInfoPtr pInp, int flags);
166extern _X_EXPORT void xf86MotionHistoryAllocate(InputInfoPtr pInfo);
167extern _X_EXPORT void xf86IDrvMsgVerb(InputInfoPtr dev,
168				      MessageType type, int verb,
169				      const char *format, ...) _X_ATTRIBUTE_PRINTF(4,5);
170extern _X_EXPORT void xf86IDrvMsg(InputInfoPtr dev,
171				  MessageType type,
172				  const char *format, ...) _X_ATTRIBUTE_PRINTF(3,4);
173extern _X_EXPORT void xf86VIDrvMsgVerb(InputInfoPtr dev,
174				       MessageType type,
175				       int verb,
176				       const char *format,
177				       va_list args);
178
179/* xf86Option.c */
180extern _X_EXPORT void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts);
181
182#endif /* _xf86Xinput_h */
183