1706f2543Smrg/************************************************************
2706f2543Smrg
3706f2543SmrgCopyright 1987, 1998  The Open Group
4706f2543Smrg
5706f2543SmrgPermission to use, copy, modify, distribute, and sell this software and its
6706f2543Smrgdocumentation for any purpose is hereby granted without fee, provided that
7706f2543Smrgthe above copyright notice appear in all copies and that both that
8706f2543Smrgcopyright notice and this permission notice appear in supporting
9706f2543Smrgdocumentation.
10706f2543Smrg
11706f2543SmrgThe above copyright notice and this permission notice shall be included in
12706f2543Smrgall copies or substantial portions of the Software.
13706f2543Smrg
14706f2543SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15706f2543SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16706f2543SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17706f2543SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18706f2543SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19706f2543SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20706f2543Smrg
21706f2543SmrgExcept as contained in this notice, the name of The Open Group shall not be
22706f2543Smrgused in advertising or otherwise to promote the sale, use or other dealings
23706f2543Smrgin this Software without prior written authorization from The Open Group.
24706f2543Smrg
25706f2543Smrg
26706f2543SmrgCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
27706f2543Smrg
28706f2543Smrg                        All Rights Reserved
29706f2543Smrg
30706f2543SmrgPermission to use, copy, modify, and distribute this software and its
31706f2543Smrgdocumentation for any purpose and without fee is hereby granted,
32706f2543Smrgprovided that the above copyright notice appear in all copies and that
33706f2543Smrgboth that copyright notice and this permission notice appear in
34706f2543Smrgsupporting documentation, and that the name of Digital not be
35706f2543Smrgused in advertising or publicity pertaining to distribution of the
36706f2543Smrgsoftware without specific, written prior permission.
37706f2543Smrg
38706f2543SmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39706f2543SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40706f2543SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41706f2543SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42706f2543SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43706f2543SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
44706f2543SmrgSOFTWARE.
45706f2543Smrg
46706f2543Smrg********************************************************/
47706f2543Smrg
48706f2543Smrg#ifndef INPUT_H
49706f2543Smrg#define INPUT_H
50706f2543Smrg
51706f2543Smrg#include "misc.h"
52706f2543Smrg#include "screenint.h"
53706f2543Smrg#include <X11/Xmd.h>
54706f2543Smrg#include <X11/Xproto.h>
55706f2543Smrg#include <stdint.h>
56706f2543Smrg#include "window.h"     /* for WindowPtr */
57706f2543Smrg#include "xkbrules.h"
58706f2543Smrg#include "events.h"
59706f2543Smrg
60706f2543Smrg#define DEVICE_INIT	0
61706f2543Smrg#define DEVICE_ON	1
62706f2543Smrg#define DEVICE_OFF	2
63706f2543Smrg#define DEVICE_CLOSE	3
64706f2543Smrg
65706f2543Smrg#define POINTER_RELATIVE	(1 << 1)
66706f2543Smrg#define POINTER_ABSOLUTE	(1 << 2)
67706f2543Smrg#define POINTER_ACCELERATE	(1 << 3)
68706f2543Smrg#define POINTER_SCREEN		(1 << 4)	/* Data in screen coordinates */
69706f2543Smrg#define POINTER_NORAW		(1 << 5)	/* Don't generate RawEvents */
70706f2543Smrg
71706f2543Smrg/*int constants for pointer acceleration schemes*/
72706f2543Smrg#define PtrAccelNoOp            0
73706f2543Smrg#define PtrAccelPredictable     1
74706f2543Smrg#define PtrAccelLightweight     2
75706f2543Smrg#define PtrAccelDefault         PtrAccelPredictable
76706f2543Smrg
77706f2543Smrg#define MAX_VALUATORS 36
78706f2543Smrg/* Maximum number of valuators, divided by six, rounded up, to get number
79706f2543Smrg * of events. */
80706f2543Smrg#define MAX_VALUATOR_EVENTS 6
81706f2543Smrg#define MAX_BUTTONS 256 /* completely arbitrarily chosen */
82706f2543Smrg
83706f2543Smrg#define NO_AXIS_LIMITS -1
84706f2543Smrg
85706f2543Smrg#define MAP_LENGTH	256
86706f2543Smrg#define DOWN_LENGTH	32	/* 256/8 => number of bytes to hold 256 bits */
87706f2543Smrg#define NullGrab ((GrabPtr)NULL)
88706f2543Smrg#define PointerRootWin ((WindowPtr)PointerRoot)
89706f2543Smrg#define NoneWin ((WindowPtr)None)
90706f2543Smrg#define NullDevice ((DevicePtr)NULL)
91706f2543Smrg
92706f2543Smrg#ifndef FollowKeyboard
93706f2543Smrg#define FollowKeyboard 		3
94706f2543Smrg#endif
95706f2543Smrg#ifndef FollowKeyboardWin
96706f2543Smrg#define FollowKeyboardWin  ((WindowPtr) FollowKeyboard)
97706f2543Smrg#endif
98706f2543Smrg#ifndef RevertToFollowKeyboard
99706f2543Smrg#define RevertToFollowKeyboard	3
100706f2543Smrg#endif
101706f2543Smrg
102706f2543Smrgtypedef unsigned long Leds;
103706f2543Smrgtypedef struct _OtherClients *OtherClientsPtr;
104706f2543Smrgtypedef struct _InputClients *InputClientsPtr;
105706f2543Smrgtypedef struct _DeviceIntRec *DeviceIntPtr;
106706f2543Smrgtypedef struct _ValuatorClassRec *ValuatorClassPtr;
107706f2543Smrgtypedef struct _ClassesRec *ClassesPtr;
108706f2543Smrgtypedef struct _SpriteRec *SpritePtr;
109706f2543Smrgtypedef union _GrabMask GrabMask;
110706f2543Smrg
111706f2543Smrgtypedef struct _EventList {
112706f2543Smrg    xEvent* event;
113706f2543Smrg    int evlen; /* length of allocated memory for event in bytes.  This is not
114706f2543Smrg                  the actual length of the event. The event's actual length is
115706f2543Smrg                  32 for standard events or 32 +
116706f2543Smrg                  ((xGenericEvent*)event)->length * 4 for GenericEvents.
117706f2543Smrg                  For events in the EQ, the length is
118706f2543Smrg                  ((InternalEvent*)event)->u.any.length */
119706f2543Smrg} EventList, *EventListPtr;
120706f2543Smrg
121706f2543Smrg/* The DIX stores incoming input events in this list */
122706f2543Smrgextern EventListPtr InputEventList;
123706f2543Smrgextern int InputEventListLen;
124706f2543Smrg
125706f2543Smrgtypedef int (*DeviceProc)(
126706f2543Smrg    DeviceIntPtr /*device*/,
127706f2543Smrg    int /*what*/);
128706f2543Smrg
129706f2543Smrgtypedef void (*ProcessInputProc)(
130706f2543Smrg    InternalEvent * /*event*/,
131706f2543Smrg    DeviceIntPtr /*device*/);
132706f2543Smrg
133706f2543Smrgtypedef Bool (*DeviceHandleProc)(
134706f2543Smrg    DeviceIntPtr /*device*/,
135706f2543Smrg    void* /*data*/
136706f2543Smrg    );
137706f2543Smrg
138706f2543Smrgtypedef void (*DeviceUnwrapProc)(
139706f2543Smrg    DeviceIntPtr /*device*/,
140706f2543Smrg    DeviceHandleProc /*proc*/,
141706f2543Smrg    void* /*data*/
142706f2543Smrg    );
143706f2543Smrg
144706f2543Smrg/* pointer acceleration handling */
145706f2543Smrgtypedef void (*PointerAccelSchemeProc)(
146706f2543Smrg    DeviceIntPtr /*pDev*/,
147706f2543Smrg    int /*first_valuator*/,
148706f2543Smrg    int /*num_valuators*/,
149706f2543Smrg    int* /*valuators*/,
150706f2543Smrg    int /*evtime*/);
151706f2543Smrg
152706f2543Smrgtypedef void (*DeviceCallbackProc)(
153706f2543Smrg              DeviceIntPtr /*pDev*/);
154706f2543Smrg
155706f2543Smrgtypedef struct _DeviceRec {
156706f2543Smrg    pointer	devicePrivate;
157706f2543Smrg    ProcessInputProc processInputProc;	/* current */
158706f2543Smrg    ProcessInputProc realInputProc;	/* deliver */
159706f2543Smrg    ProcessInputProc enqueueInputProc;	/* enqueue */
160706f2543Smrg    Bool	on;			/* used by DDX to keep state */
161706f2543Smrg} DeviceRec, *DevicePtr;
162706f2543Smrg
163706f2543Smrgtypedef struct _ValuatorMask ValuatorMask;
164706f2543Smrg
165706f2543Smrgtypedef struct {
166706f2543Smrg    int			click, bell, bell_pitch, bell_duration;
167706f2543Smrg    Bool		autoRepeat;
168706f2543Smrg    unsigned char	autoRepeats[32];
169706f2543Smrg    Leds		leds;
170706f2543Smrg    unsigned char	id;
171706f2543Smrg} KeybdCtrl;
172706f2543Smrg
173706f2543Smrgtypedef struct {
174706f2543Smrg    KeySym  *map;
175706f2543Smrg    KeyCode minKeyCode,
176706f2543Smrg	    maxKeyCode;
177706f2543Smrg    int     mapWidth;
178706f2543Smrg} KeySymsRec, *KeySymsPtr;
179706f2543Smrg
180706f2543Smrgtypedef struct {
181706f2543Smrg    int		num, den, threshold;
182706f2543Smrg    unsigned char id;
183706f2543Smrg} PtrCtrl;
184706f2543Smrg
185706f2543Smrgtypedef struct {
186706f2543Smrg    int         resolution, min_value, max_value;
187706f2543Smrg    int         integer_displayed;
188706f2543Smrg    unsigned char id;
189706f2543Smrg} IntegerCtrl;
190706f2543Smrg
191706f2543Smrgtypedef struct {
192706f2543Smrg    int         max_symbols, num_symbols_supported;
193706f2543Smrg    int         num_symbols_displayed;
194706f2543Smrg    KeySym      *symbols_supported;
195706f2543Smrg    KeySym      *symbols_displayed;
196706f2543Smrg    unsigned char id;
197706f2543Smrg} StringCtrl;
198706f2543Smrg
199706f2543Smrgtypedef struct {
200706f2543Smrg    int         percent, pitch, duration;
201706f2543Smrg    unsigned char id;
202706f2543Smrg} BellCtrl;
203706f2543Smrg
204706f2543Smrgtypedef struct {
205706f2543Smrg    Leds        led_values;
206706f2543Smrg    Mask        led_mask;
207706f2543Smrg    unsigned char id;
208706f2543Smrg} LedCtrl;
209706f2543Smrg
210706f2543Smrgextern _X_EXPORT KeybdCtrl	defaultKeyboardControl;
211706f2543Smrgextern _X_EXPORT PtrCtrl	defaultPointerControl;
212706f2543Smrg
213706f2543Smrgtypedef struct _InputOption {
214706f2543Smrg    char                *key;
215706f2543Smrg    char                *value;
216706f2543Smrg    struct _InputOption *next;
217706f2543Smrg} InputOption;
218706f2543Smrg
219706f2543Smrgtypedef struct _InputAttributes {
220706f2543Smrg    char                *product;
221706f2543Smrg    char                *vendor;
222706f2543Smrg    char                *device;
223706f2543Smrg    char                *pnp_id;
224706f2543Smrg    char                *usb_id;
225706f2543Smrg    char                **tags; /* null-terminated */
226706f2543Smrg    uint32_t            flags;
227706f2543Smrg} InputAttributes;
228706f2543Smrg
229706f2543Smrg#define ATTR_KEYBOARD (1<<0)
230706f2543Smrg#define ATTR_POINTER (1<<1)
231706f2543Smrg#define ATTR_JOYSTICK (1<<2)
232706f2543Smrg#define ATTR_TABLET (1<<3)
233706f2543Smrg#define ATTR_TOUCHPAD (1<<4)
234706f2543Smrg#define ATTR_TOUCHSCREEN (1<<5)
235706f2543Smrg
236706f2543Smrg/* Key/Button has been run through all input processing and events sent to clients. */
237706f2543Smrg#define KEY_PROCESSED 1
238706f2543Smrg#define BUTTON_PROCESSED 1
239706f2543Smrg/* Key/Button has not been fully processed, no events have been sent. */
240706f2543Smrg#define KEY_POSTED 2
241706f2543Smrg#define BUTTON_POSTED 2
242706f2543Smrg
243706f2543Smrgextern void set_key_down(DeviceIntPtr pDev, int key_code, int type);
244706f2543Smrgextern void set_key_up(DeviceIntPtr pDev, int key_code, int type);
245706f2543Smrgextern int key_is_down(DeviceIntPtr pDev, int key_code, int type);
246706f2543Smrgextern void set_button_down(DeviceIntPtr pDev, int button, int type);
247706f2543Smrgextern void set_button_up(DeviceIntPtr pDev, int button, int type);
248706f2543Smrgextern int button_is_down(DeviceIntPtr pDev, int button, int type);
249706f2543Smrg
250706f2543Smrgextern void InitCoreDevices(void);
251706f2543Smrgextern void InitXTestDevices(void);
252706f2543Smrg
253706f2543Smrgextern _X_EXPORT DeviceIntPtr AddInputDevice(
254706f2543Smrg    ClientPtr /*client*/,
255706f2543Smrg    DeviceProc /*deviceProc*/,
256706f2543Smrg    Bool /*autoStart*/);
257706f2543Smrg
258706f2543Smrgextern _X_EXPORT Bool EnableDevice(
259706f2543Smrg    DeviceIntPtr /*device*/,
260706f2543Smrg    BOOL /* sendevent */);
261706f2543Smrg
262706f2543Smrgextern _X_EXPORT Bool ActivateDevice(
263706f2543Smrg    DeviceIntPtr /*device*/,
264706f2543Smrg    BOOL /* sendevent */);
265706f2543Smrg
266706f2543Smrgextern _X_EXPORT Bool DisableDevice(
267706f2543Smrg    DeviceIntPtr /*device*/,
268706f2543Smrg    BOOL /* sendevent */);
269706f2543Smrg
270706f2543Smrgextern int InitAndStartDevices(void);
271706f2543Smrg
272706f2543Smrgextern void CloseDownDevices(void);
273706f2543Smrg
274706f2543Smrgextern void UndisplayDevices(void);
275706f2543Smrg
276706f2543Smrgextern _X_EXPORT int RemoveDevice(
277706f2543Smrg    DeviceIntPtr /*dev*/,
278706f2543Smrg    BOOL /* sendevent */);
279706f2543Smrg
280706f2543Smrgextern _X_EXPORT int NumMotionEvents(void);
281706f2543Smrg
282706f2543Smrgextern _X_EXPORT int dixLookupDevice(
283706f2543Smrg    DeviceIntPtr *         /* dev */,
284706f2543Smrg    int                    /* id */,
285706f2543Smrg    ClientPtr              /* client */,
286706f2543Smrg    Mask                   /* access_mode */);
287706f2543Smrg
288706f2543Smrgextern _X_EXPORT void QueryMinMaxKeyCodes(
289706f2543Smrg    KeyCode* /*minCode*/,
290706f2543Smrg    KeyCode* /*maxCode*/);
291706f2543Smrg
292706f2543Smrgextern _X_EXPORT Bool SetKeySymsMap(
293706f2543Smrg    KeySymsPtr /*dst*/,
294706f2543Smrg    KeySymsPtr /*src*/);
295706f2543Smrg
296706f2543Smrgextern _X_EXPORT Bool InitButtonClassDeviceStruct(
297706f2543Smrg    DeviceIntPtr /*device*/,
298706f2543Smrg    int /*numButtons*/,
299706f2543Smrg    Atom* /* labels */,
300706f2543Smrg    CARD8* /*map*/);
301706f2543Smrg
302706f2543Smrgextern _X_INTERNAL ValuatorClassPtr AllocValuatorClass(
303706f2543Smrg    ValuatorClassPtr src,
304706f2543Smrg    int numAxes);
305706f2543Smrg
306706f2543Smrgextern _X_EXPORT Bool InitValuatorClassDeviceStruct(
307706f2543Smrg    DeviceIntPtr /*device*/,
308706f2543Smrg    int /*numAxes*/,
309706f2543Smrg    Atom* /* labels */,
310706f2543Smrg    int /*numMotionEvents*/,
311706f2543Smrg    int /*mode*/);
312706f2543Smrg
313706f2543Smrgextern _X_EXPORT Bool InitPointerAccelerationScheme(
314706f2543Smrg    DeviceIntPtr /*dev*/,
315706f2543Smrg    int /*scheme*/);
316706f2543Smrg
317706f2543Smrgextern _X_EXPORT Bool InitAbsoluteClassDeviceStruct(
318706f2543Smrg    DeviceIntPtr /*device*/);
319706f2543Smrg
320706f2543Smrgextern _X_EXPORT Bool InitFocusClassDeviceStruct(
321706f2543Smrg    DeviceIntPtr /*device*/);
322706f2543Smrg
323706f2543Smrgtypedef void (*BellProcPtr)(
324706f2543Smrg    int /*percent*/,
325706f2543Smrg    DeviceIntPtr /*device*/,
326706f2543Smrg    pointer /*ctrl*/,
327706f2543Smrg    int);
328706f2543Smrg
329706f2543Smrgtypedef void (*KbdCtrlProcPtr)(
330706f2543Smrg    DeviceIntPtr /*device*/,
331706f2543Smrg    KeybdCtrl * /*ctrl*/);
332706f2543Smrg
333706f2543Smrgtypedef void (*PtrCtrlProcPtr)(
334706f2543Smrg    DeviceIntPtr /*device*/,
335706f2543Smrg    PtrCtrl * /*ctrl*/);
336706f2543Smrg
337706f2543Smrgextern _X_EXPORT Bool InitPtrFeedbackClassDeviceStruct(
338706f2543Smrg    DeviceIntPtr /*device*/,
339706f2543Smrg    PtrCtrlProcPtr /*controlProc*/);
340706f2543Smrg
341706f2543Smrgtypedef void (*StringCtrlProcPtr)(
342706f2543Smrg    DeviceIntPtr /*device*/,
343706f2543Smrg    StringCtrl * /*ctrl*/);
344706f2543Smrg
345706f2543Smrgextern _X_EXPORT Bool InitStringFeedbackClassDeviceStruct(
346706f2543Smrg    DeviceIntPtr /*device*/,
347706f2543Smrg    StringCtrlProcPtr /*controlProc*/,
348706f2543Smrg    int /*max_symbols*/,
349706f2543Smrg    int /*num_symbols_supported*/,
350706f2543Smrg    KeySym* /*symbols*/);
351706f2543Smrg
352706f2543Smrgtypedef void (*BellCtrlProcPtr)(
353706f2543Smrg    DeviceIntPtr /*device*/,
354706f2543Smrg    BellCtrl * /*ctrl*/);
355706f2543Smrg
356706f2543Smrgextern _X_EXPORT Bool InitBellFeedbackClassDeviceStruct(
357706f2543Smrg    DeviceIntPtr /*device*/,
358706f2543Smrg    BellProcPtr /*bellProc*/,
359706f2543Smrg    BellCtrlProcPtr /*controlProc*/);
360706f2543Smrg
361706f2543Smrgtypedef void (*LedCtrlProcPtr)(
362706f2543Smrg    DeviceIntPtr /*device*/,
363706f2543Smrg    LedCtrl * /*ctrl*/);
364706f2543Smrg
365706f2543Smrgextern _X_EXPORT Bool InitLedFeedbackClassDeviceStruct(
366706f2543Smrg    DeviceIntPtr /*device*/,
367706f2543Smrg    LedCtrlProcPtr /*controlProc*/);
368706f2543Smrg
369706f2543Smrgtypedef void (*IntegerCtrlProcPtr)(
370706f2543Smrg    DeviceIntPtr /*device*/,
371706f2543Smrg    IntegerCtrl * /*ctrl*/);
372706f2543Smrg
373706f2543Smrg
374706f2543Smrgextern _X_EXPORT Bool InitIntegerFeedbackClassDeviceStruct(
375706f2543Smrg    DeviceIntPtr /*device*/,
376706f2543Smrg    IntegerCtrlProcPtr /*controlProc*/);
377706f2543Smrg
378706f2543Smrgextern _X_EXPORT Bool InitPointerDeviceStruct(
379706f2543Smrg    DevicePtr /*device*/,
380706f2543Smrg    CARD8* /*map*/,
381706f2543Smrg    int /*numButtons*/,
382706f2543Smrg    Atom* /* btn_labels */,
383706f2543Smrg    PtrCtrlProcPtr /*controlProc*/,
384706f2543Smrg    int /*numMotionEvents*/,
385706f2543Smrg    int /*numAxes*/,
386706f2543Smrg    Atom* /* axes_labels */);
387706f2543Smrg
388706f2543Smrgextern _X_EXPORT Bool InitKeyboardDeviceStruct(
389706f2543Smrg    DeviceIntPtr /*device*/,
390706f2543Smrg    XkbRMLVOSet * /*rmlvo*/,
391706f2543Smrg    BellProcPtr /*bellProc*/,
392706f2543Smrg    KbdCtrlProcPtr /*controlProc*/);
393706f2543Smrg
394706f2543Smrgextern int ApplyPointerMapping(
395706f2543Smrg    DeviceIntPtr /* pDev */,
396706f2543Smrg    CARD8 *      /* map */,
397706f2543Smrg    int          /* len */,
398706f2543Smrg    ClientPtr	/* client */);
399706f2543Smrg
400706f2543Smrgextern Bool BadDeviceMap(
401706f2543Smrg    BYTE* /*buff*/,
402706f2543Smrg    int /*length*/,
403706f2543Smrg    unsigned /*low*/,
404706f2543Smrg    unsigned /*high*/,
405706f2543Smrg    XID* /*errval*/);
406706f2543Smrg
407706f2543Smrgextern void NoteLedState(
408706f2543Smrg    DeviceIntPtr /*keybd*/,
409706f2543Smrg    int /*led*/,
410706f2543Smrg    Bool /*on*/);
411706f2543Smrg
412706f2543Smrgextern void MaybeStopHint(
413706f2543Smrg    DeviceIntPtr /*device*/,
414706f2543Smrg    ClientPtr /*client*/);
415706f2543Smrg
416706f2543Smrgextern void ProcessPointerEvent(
417706f2543Smrg    InternalEvent* /* ev */,
418706f2543Smrg    DeviceIntPtr /*mouse*/);
419706f2543Smrg
420706f2543Smrgextern void ProcessKeyboardEvent(
421706f2543Smrg    InternalEvent* /*ev*/,
422706f2543Smrg    DeviceIntPtr   /*keybd*/);
423706f2543Smrg
424706f2543Smrgextern Bool LegalModifier(
425706f2543Smrg    unsigned int /*key*/,
426706f2543Smrg    DeviceIntPtr /*pDev*/);
427706f2543Smrg
428706f2543Smrgextern _X_EXPORT void ProcessInputEvents(void);
429706f2543Smrg
430706f2543Smrgextern _X_EXPORT void InitInput(
431706f2543Smrg    int  /*argc*/,
432706f2543Smrg    char ** /*argv*/);
433706f2543Smrgextern _X_EXPORT void CloseInput(void);
434706f2543Smrg
435706f2543Smrgextern _X_EXPORT int GetMaximumEventsNum(void);
436706f2543Smrg
437706f2543Smrgextern _X_EXPORT int GetEventList(EventListPtr* list);
438706f2543Smrgextern _X_EXPORT EventListPtr InitEventList(int num_events);
439706f2543Smrgextern _X_EXPORT void FreeEventList(EventListPtr list, int num_events);
440706f2543Smrg
441706f2543Smrgextern void CreateClassesChangedEvent(EventListPtr event,
442706f2543Smrg                                      DeviceIntPtr master,
443706f2543Smrg                                      DeviceIntPtr slave,
444706f2543Smrg                                      int type);
445706f2543Smrgextern EventListPtr UpdateFromMaster(
446706f2543Smrg    EventListPtr events,
447706f2543Smrg    DeviceIntPtr pDev,
448706f2543Smrg    int type,
449706f2543Smrg    int *num_events);
450706f2543Smrg
451706f2543Smrgextern _X_EXPORT int GetPointerEvents(
452706f2543Smrg    EventListPtr events,
453706f2543Smrg    DeviceIntPtr pDev,
454706f2543Smrg    int type,
455706f2543Smrg    int buttons,
456706f2543Smrg    int flags,
457706f2543Smrg    const ValuatorMask *mask);
458706f2543Smrg
459706f2543Smrgextern _X_EXPORT int GetKeyboardEvents(
460706f2543Smrg    EventListPtr events,
461706f2543Smrg    DeviceIntPtr pDev,
462706f2543Smrg    int type,
463706f2543Smrg    int key_code);
464706f2543Smrg
465706f2543Smrgextern int GetKeyboardValuatorEvents(
466706f2543Smrg    EventListPtr events,
467706f2543Smrg    DeviceIntPtr pDev,
468706f2543Smrg    int type,
469706f2543Smrg    int key_code,
470706f2543Smrg    const ValuatorMask *mask);
471706f2543Smrg
472706f2543Smrgextern int GetProximityEvents(
473706f2543Smrg    EventListPtr events,
474706f2543Smrg    DeviceIntPtr pDev,
475706f2543Smrg    int type,
476706f2543Smrg    const ValuatorMask *mask);
477706f2543Smrg
478706f2543Smrgextern void PostSyntheticMotion(
479706f2543Smrg    DeviceIntPtr pDev,
480706f2543Smrg    int x,
481706f2543Smrg    int y,
482706f2543Smrg    int screen,
483706f2543Smrg    unsigned long time);
484706f2543Smrg
485706f2543Smrgextern _X_EXPORT int GetMotionHistorySize(
486706f2543Smrg    void);
487706f2543Smrg
488706f2543Smrgextern _X_EXPORT void AllocateMotionHistory(
489706f2543Smrg    DeviceIntPtr pDev);
490706f2543Smrg
491706f2543Smrgextern _X_EXPORT int GetMotionHistory(
492706f2543Smrg    DeviceIntPtr pDev,
493706f2543Smrg    xTimecoord **buff,
494706f2543Smrg    unsigned long start,
495706f2543Smrg    unsigned long stop,
496706f2543Smrg    ScreenPtr pScreen,
497706f2543Smrg    BOOL core);
498706f2543Smrg
499706f2543Smrgextern void ReleaseButtonsAndKeys(DeviceIntPtr dev);
500706f2543Smrg
501706f2543Smrgextern int AttachDevice(ClientPtr client,
502706f2543Smrg                        DeviceIntPtr slave,
503706f2543Smrg                        DeviceIntPtr master);
504706f2543Smrg
505706f2543Smrgextern _X_EXPORT DeviceIntPtr GetPairedDevice(DeviceIntPtr kbd);
506706f2543Smrgextern DeviceIntPtr GetMaster(DeviceIntPtr dev, int type);
507706f2543Smrg
508706f2543Smrgextern _X_EXPORT int AllocDevicePair(ClientPtr client,
509706f2543Smrg                             char* name,
510706f2543Smrg                             DeviceIntPtr* ptr,
511706f2543Smrg                             DeviceIntPtr* keybd,
512706f2543Smrg                             DeviceProc ptr_proc,
513706f2543Smrg                             DeviceProc keybd_proc,
514706f2543Smrg                             Bool master);
515706f2543Smrgextern void DeepCopyDeviceClasses(DeviceIntPtr from,
516706f2543Smrg                                  DeviceIntPtr to,
517706f2543Smrg                                  DeviceChangedEvent *dce);
518706f2543Smrg
519706f2543Smrg/* Helper functions. */
520706f2543Smrgextern _X_EXPORT int generate_modkeymap(ClientPtr client, DeviceIntPtr dev,
521706f2543Smrg                              KeyCode **modkeymap, int *max_keys_per_mod);
522706f2543Smrgextern int change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *map,
523706f2543Smrg                         int max_keys_per_mod);
524706f2543Smrgextern int AllocXTestDevice(ClientPtr client,
525706f2543Smrg                             char* name,
526706f2543Smrg                             DeviceIntPtr* ptr,
527706f2543Smrg                             DeviceIntPtr* keybd,
528706f2543Smrg                             DeviceIntPtr master_ptr,
529706f2543Smrg                             DeviceIntPtr master_keybd);
530706f2543Smrgextern BOOL IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master);
531706f2543Smrgextern DeviceIntPtr GetXTestDevice(DeviceIntPtr master);
532706f2543Smrgextern void SendDevicePresenceEvent(int deviceid, int type);
533706f2543Smrgextern _X_EXPORT InputAttributes *DuplicateInputAttributes(InputAttributes *attrs);
534706f2543Smrgextern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
535706f2543Smrg
536706f2543Smrg/* misc event helpers */
537706f2543Smrgextern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
538706f2543Smrgextern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
539706f2543Smrgextern Mask GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev);
540706f2543Smrgvoid FixUpEventFromWindow(SpritePtr pSprite,
541706f2543Smrg                          xEvent *xE,
542706f2543Smrg                          WindowPtr pWin,
543706f2543Smrg                          Window child,
544706f2543Smrg                          Bool calcChild);
545706f2543Smrgextern WindowPtr XYToWindow(SpritePtr pSprite, int x, int y);
546706f2543Smrgextern int EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event,
547706f2543Smrg                              WindowPtr win);
548706f2543Smrg/**
549706f2543Smrg * Return masks for EventIsDeliverable.
550706f2543Smrg * @defgroup EventIsDeliverable return flags
551706f2543Smrg * @{
552706f2543Smrg */
553706f2543Smrg#define XI_MASK                 (1 << 0) /**< XI mask set on window */
554706f2543Smrg#define CORE_MASK               (1 << 1) /**< Core mask set on window */
555706f2543Smrg#define DONT_PROPAGATE_MASK     (1 << 2) /**< DontPropagate mask set on window */
556706f2543Smrg#define XI2_MASK                (1 << 3) /**< XI2 mask set on window */
557706f2543Smrg/* @} */
558706f2543Smrg
559706f2543Smrg/* Implemented by the DDX. */
560706f2543Smrgextern _X_EXPORT int NewInputDeviceRequest(
561706f2543Smrg    InputOption *options,
562706f2543Smrg    InputAttributes *attrs,
563706f2543Smrg    DeviceIntPtr *dev);
564706f2543Smrgextern  _X_EXPORT void DeleteInputDeviceRequest(
565706f2543Smrg    DeviceIntPtr dev);
566706f2543Smrg
567706f2543Smrgextern _X_EXPORT void DDXRingBell(
568706f2543Smrg    int volume,
569706f2543Smrg    int pitch,
570706f2543Smrg    int duration);
571706f2543Smrg
572706f2543Smrg#define VALUATOR_MODE_ALL_AXES -1
573706f2543Smrgextern _X_HIDDEN int valuator_get_mode(DeviceIntPtr dev, int axis);
574706f2543Smrgextern _X_HIDDEN void valuator_set_mode(DeviceIntPtr dev, int axis, int mode);
575706f2543Smrg
576706f2543Smrg/* Set to TRUE by default - os/utils.c sets it to FALSE on user request,
577706f2543Smrg   xfixes/cursor.c uses it to determine if the cursor is enabled */
578706f2543Smrgextern Bool EnableCursor;
579706f2543Smrg
580706f2543Smrgextern _X_EXPORT ValuatorMask  *valuator_mask_new(int num_valuators);
581706f2543Smrgextern _X_EXPORT void valuator_mask_free(ValuatorMask **mask);
582706f2543Smrgextern _X_EXPORT void valuator_mask_set_range(ValuatorMask *mask,
583706f2543Smrg                                       int first_valuator, int num_valuators,
584706f2543Smrg                                       const int* valuators);
585706f2543Smrgextern _X_EXPORT void valuator_mask_set(ValuatorMask *mask,
586706f2543Smrg                                        int valuator,
587706f2543Smrg                                        int data);
588706f2543Smrgextern _X_EXPORT void valuator_mask_zero(ValuatorMask *mask);
589706f2543Smrgextern _X_EXPORT int valuator_mask_size(const ValuatorMask *mask);
590706f2543Smrgextern _X_EXPORT int valuator_mask_isset(const ValuatorMask *mask, int bit);
591706f2543Smrgextern _X_EXPORT void valuator_mask_unset(ValuatorMask *mask, int bit);
592706f2543Smrgextern _X_EXPORT int valuator_mask_num_valuators(const ValuatorMask *mask);
593706f2543Smrgextern _X_EXPORT void valuator_mask_copy(ValuatorMask *dest,
594706f2543Smrg                                         const ValuatorMask *src);
595706f2543Smrgextern _X_EXPORT int valuator_mask_get(const ValuatorMask *mask, int valnum);
596706f2543Smrg
597706f2543Smrg#endif /* INPUT_H */
598