xref: /OK3568_Linux_fs/external/xserver/hw/dmx/input/dmxinputinit.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright 2002 Red Hat Inc., Durham, North Carolina.
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * All Rights Reserved.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining
7*4882a593Smuzhiyun  * a copy of this software and associated documentation files (the
8*4882a593Smuzhiyun  * "Software"), to deal in the Software without restriction, including
9*4882a593Smuzhiyun  * without limitation on the rights to use, copy, modify, merge,
10*4882a593Smuzhiyun  * publish, distribute, sublicense, and/or sell copies of the Software,
11*4882a593Smuzhiyun  * and to permit persons to whom the Software is furnished to do so,
12*4882a593Smuzhiyun  * subject to the following conditions:
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  * The above copyright notice and this permission notice (including the
15*4882a593Smuzhiyun  * next paragraph) shall be included in all copies or substantial
16*4882a593Smuzhiyun  * portions of the Software.
17*4882a593Smuzhiyun  *
18*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19*4882a593Smuzhiyun  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20*4882a593Smuzhiyun  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21*4882a593Smuzhiyun  * NON-INFRINGEMENT.  IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
22*4882a593Smuzhiyun  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23*4882a593Smuzhiyun  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24*4882a593Smuzhiyun  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25*4882a593Smuzhiyun  * SOFTWARE.
26*4882a593Smuzhiyun  */
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun /*
29*4882a593Smuzhiyun  * Authors:
30*4882a593Smuzhiyun  *   Rickard E. (Rik) Faith <faith@redhat.com>
31*4882a593Smuzhiyun  *
32*4882a593Smuzhiyun  */
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun /** \file
35*4882a593Smuzhiyun  * Interface for low-level input support.  \see dmxinputinit.c */
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun #ifndef _DMXINPUTINIT_H_
38*4882a593Smuzhiyun #define _DMXINPUTINIT_H_
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun #include "dmx.h"
41*4882a593Smuzhiyun #include "dmxinput.h"
42*4882a593Smuzhiyun #include "dmxlog.h"
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun #define DMX_LOCAL_DEFAULT_KEYBOARD "kbd"
45*4882a593Smuzhiyun #define DMX_LOCAL_DEFAULT_POINTER  "ps2"
46*4882a593Smuzhiyun #define DMX_MAX_BUTTONS            256
47*4882a593Smuzhiyun #define DMX_MOTION_SIZE            256
48*4882a593Smuzhiyun #define DMX_MAX_VALUATORS          32
49*4882a593Smuzhiyun #define DMX_MAX_AXES               32
50*4882a593Smuzhiyun #define DMX_MAX_XINPUT_EVENT_TYPES 100
51*4882a593Smuzhiyun #define DMX_MAP_ENTRIES            16   /* Must be a power of 2 */
52*4882a593Smuzhiyun #define DMX_MAP_MASK               (DMX_MAP_ENTRIES - 1)
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun typedef enum {
55*4882a593Smuzhiyun     DMX_FUNCTION_GRAB,
56*4882a593Smuzhiyun     DMX_FUNCTION_TERMINATE,
57*4882a593Smuzhiyun     DMX_FUNCTION_FINE
58*4882a593Smuzhiyun } DMXFunctionType;
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun typedef enum {
61*4882a593Smuzhiyun     DMX_LOCAL_HIGHLEVEL,
62*4882a593Smuzhiyun     DMX_LOCAL_KEYBOARD,
63*4882a593Smuzhiyun     DMX_LOCAL_MOUSE,
64*4882a593Smuzhiyun     DMX_LOCAL_OTHER
65*4882a593Smuzhiyun } DMXLocalInputType;
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun typedef enum {
68*4882a593Smuzhiyun     DMX_LOCAL_TYPE_LOCAL,
69*4882a593Smuzhiyun     DMX_LOCAL_TYPE_CONSOLE,
70*4882a593Smuzhiyun     DMX_LOCAL_TYPE_BACKEND,
71*4882a593Smuzhiyun     DMX_LOCAL_TYPE_COMMON
72*4882a593Smuzhiyun } DMXLocalInputExtType;
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun typedef enum {
75*4882a593Smuzhiyun     DMX_RELATIVE,
76*4882a593Smuzhiyun     DMX_ABSOLUTE,
77*4882a593Smuzhiyun     DMX_ABSOLUTE_CONFINED
78*4882a593Smuzhiyun } DMXMotionType;
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun /** Stores information from low-level device that is used to initialize
81*4882a593Smuzhiyun  * the device at the dix level. */
82*4882a593Smuzhiyun typedef struct _DMXLocalInitInfo {
83*4882a593Smuzhiyun     int keyboard;                  /**< Non-zero if the device is a keyboard */
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun     int keyClass;                  /**< Non-zero if keys are present */
86*4882a593Smuzhiyun     KeySymsRec keySyms;            /**< Key symbols */
87*4882a593Smuzhiyun     int freemap;                   /**< If non-zero, free keySyms.map */
88*4882a593Smuzhiyun     CARD8 modMap[MAP_LENGTH];                /**< Modifier map */
89*4882a593Smuzhiyun     XkbDescPtr xkb;                 /**< XKB description */
90*4882a593Smuzhiyun     XkbComponentNamesRec names;     /**< XKB component names */
91*4882a593Smuzhiyun     int freenames;                  /**< Non-zero if names should be free'd */
92*4882a593Smuzhiyun     int force;                      /**< Do not allow command line override */
93*4882a593Smuzhiyun 
94*4882a593Smuzhiyun     int buttonClass;                  /**< Non-zero if buttons are present */
95*4882a593Smuzhiyun     int numButtons;                   /**< Number of buttons */
96*4882a593Smuzhiyun     unsigned char map[DMX_MAX_BUTTONS];        /**< Button map */
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun     int valuatorClass;                  /**< Non-zero if valuators are
99*4882a593Smuzhiyun                                          * present */
100*4882a593Smuzhiyun     int numRelAxes;                     /**< Number of relative axes */
101*4882a593Smuzhiyun     int numAbsAxes;                     /**< Number of absolute axes */
102*4882a593Smuzhiyun     int minval[DMX_MAX_AXES];                  /**< Minimum values */
103*4882a593Smuzhiyun     int maxval[DMX_MAX_AXES];                  /**< Maximum values */
104*4882a593Smuzhiyun     int res[DMX_MAX_AXES];                     /**< Resolution */
105*4882a593Smuzhiyun     int minres[DMX_MAX_AXES];                  /**< Minimum resolutions */
106*4882a593Smuzhiyun     int maxres[DMX_MAX_AXES];                  /**< Maximum resolutions */
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun     int focusClass;                        /**< Non-zero if device can
109*4882a593Smuzhiyun                                             * cause focus */
110*4882a593Smuzhiyun     int proximityClass;                    /**< Non-zero if device
111*4882a593Smuzhiyun                                             * causes proximity events */
112*4882a593Smuzhiyun     int kbdFeedbackClass;                  /**< Non-zero if device has
113*4882a593Smuzhiyun                                             * keyboard feedback */
114*4882a593Smuzhiyun     int ptrFeedbackClass;                  /**< Non-zero if device has
115*4882a593Smuzhiyun                                             * pointer feedback */
116*4882a593Smuzhiyun     int ledFeedbackClass;                  /**< Non-zero if device has
117*4882a593Smuzhiyun                                             * LED indicators */
118*4882a593Smuzhiyun     int belFeedbackClass;                  /**< Non-zero if device has a
119*4882a593Smuzhiyun                                             * bell */
120*4882a593Smuzhiyun     int intFeedbackClass;                  /**< Non-zero if device has
121*4882a593Smuzhiyun                                             * integer feedback */
122*4882a593Smuzhiyun     int strFeedbackClass;                  /**< Non-zero if device has
123*4882a593Smuzhiyun                                             * string feedback */
124*4882a593Smuzhiyun 
125*4882a593Smuzhiyun     int maxSymbols;                           /**< Maximum symbols */
126*4882a593Smuzhiyun     int maxSymbolsSupported;                  /**< Maximum symbols supported */
127*4882a593Smuzhiyun     KeySym *symbols;                          /**< Key symbols */
128*4882a593Smuzhiyun } DMXLocalInitInfo, *DMXLocalInitInfoPtr;
129*4882a593Smuzhiyun 
130*4882a593Smuzhiyun typedef void *(*dmxCreatePrivateProcPtr) (DeviceIntPtr);
131*4882a593Smuzhiyun typedef void (*dmxDestroyPrivateProcPtr) (void *);
132*4882a593Smuzhiyun 
133*4882a593Smuzhiyun typedef void (*dmxInitProcPtr) (DevicePtr);
134*4882a593Smuzhiyun typedef void (*dmxReInitProcPtr) (DevicePtr);
135*4882a593Smuzhiyun typedef void (*dmxLateReInitProcPtr) (DevicePtr);
136*4882a593Smuzhiyun typedef void (*dmxGetInfoProcPtr) (DevicePtr, DMXLocalInitInfoPtr);
137*4882a593Smuzhiyun typedef int (*dmxOnProcPtr) (DevicePtr);
138*4882a593Smuzhiyun typedef void (*dmxOffProcPtr) (DevicePtr);
139*4882a593Smuzhiyun typedef void (*dmxUpdatePositionProcPtr) (void *, int x, int y);
140*4882a593Smuzhiyun 
141*4882a593Smuzhiyun typedef void (*dmxVTPreSwitchProcPtr) (void *);        /* Turn I/O Off */
142*4882a593Smuzhiyun typedef void (*dmxVTPostSwitchProcPtr) (void *);       /* Turn I/O On */
143*4882a593Smuzhiyun typedef void (*dmxVTSwitchReturnProcPtr) (void *);
144*4882a593Smuzhiyun typedef int (*dmxVTSwitchProcPtr) (void *, int vt,
145*4882a593Smuzhiyun                                    dmxVTSwitchReturnProcPtr, void *);
146*4882a593Smuzhiyun 
147*4882a593Smuzhiyun typedef void (*dmxMotionProcPtr) (DevicePtr,
148*4882a593Smuzhiyun                                   int *valuators,
149*4882a593Smuzhiyun                                   int firstAxis,
150*4882a593Smuzhiyun                                   int axesCount,
151*4882a593Smuzhiyun                                   DMXMotionType type, DMXBlockType block);
152*4882a593Smuzhiyun typedef void (*dmxEnqueueProcPtr) (DevicePtr, int type, int detail,
153*4882a593Smuzhiyun                                    KeySym keySym, XEvent * e,
154*4882a593Smuzhiyun                                    DMXBlockType block);
155*4882a593Smuzhiyun typedef int (*dmxCheckSpecialProcPtr) (DevicePtr, KeySym keySym);
156*4882a593Smuzhiyun typedef void (*dmxCollectEventsProcPtr) (DevicePtr,
157*4882a593Smuzhiyun                                          dmxMotionProcPtr,
158*4882a593Smuzhiyun                                          dmxEnqueueProcPtr,
159*4882a593Smuzhiyun                                          dmxCheckSpecialProcPtr, DMXBlockType);
160*4882a593Smuzhiyun typedef void (*dmxProcessInputProcPtr) (void *);
161*4882a593Smuzhiyun typedef void (*dmxUpdateInfoProcPtr) (void *, DMXUpdateType, WindowPtr);
162*4882a593Smuzhiyun typedef int (*dmxFunctionsProcPtr) (void *, DMXFunctionType);
163*4882a593Smuzhiyun 
164*4882a593Smuzhiyun typedef void (*dmxKBCtrlProcPtr) (DevicePtr, KeybdCtrl * ctrl);
165*4882a593Smuzhiyun typedef void (*dmxMCtrlProcPtr) (DevicePtr, PtrCtrl * ctrl);
166*4882a593Smuzhiyun typedef void (*dmxKBBellProcPtr) (DevicePtr, int percent,
167*4882a593Smuzhiyun                                   int volume, int pitch, int duration);
168*4882a593Smuzhiyun 
169*4882a593Smuzhiyun /** Stores a mapping between the device id on the remote X server and
170*4882a593Smuzhiyun  * the id on the DMX server */
171*4882a593Smuzhiyun typedef struct _DMXEventMap {
172*4882a593Smuzhiyun     int remote;                 /**< Event number on remote X server */
173*4882a593Smuzhiyun     int server;                 /**< Event number (unbiased) on DMX server */
174*4882a593Smuzhiyun } DMXEventMap;
175*4882a593Smuzhiyun 
176*4882a593Smuzhiyun /** This is the device-independent structure used by the low-level input
177*4882a593Smuzhiyun  * routines.  The contents are not exposed to top-level .c files (except
178*4882a593Smuzhiyun  * dmxextensions.c).  \see dmxinput.h \see dmxextensions.c */
179*4882a593Smuzhiyun typedef struct _DMXLocalInputInfo {
180*4882a593Smuzhiyun     const char *name;                 /**< Device name */
181*4882a593Smuzhiyun     DMXLocalInputType type;           /**< Device type  */
182*4882a593Smuzhiyun     DMXLocalInputExtType extType;     /**< Extended device type */
183*4882a593Smuzhiyun     int binding;                      /**< Count of how many consecutive
184*4882a593Smuzhiyun                                        * structs are bound to the same
185*4882a593Smuzhiyun                                        * device */
186*4882a593Smuzhiyun 
187*4882a593Smuzhiyun     /* Low-level (e.g., keyboard/mouse drivers) */
188*4882a593Smuzhiyun 
189*4882a593Smuzhiyun     dmxCreatePrivateProcPtr create_private;   /**< Create
190*4882a593Smuzhiyun                                                * device-dependent
191*4882a593Smuzhiyun                                                * private */
192*4882a593Smuzhiyun     dmxDestroyPrivateProcPtr destroy_private; /**< Destroy
193*4882a593Smuzhiyun                                                * device-dependent
194*4882a593Smuzhiyun                                                * private */
195*4882a593Smuzhiyun     dmxInitProcPtr init;                      /**< Initialize device  */
196*4882a593Smuzhiyun     dmxReInitProcPtr reinit;                  /**< Reinitialize device
197*4882a593Smuzhiyun                                                * (during a
198*4882a593Smuzhiyun                                                * reconfiguration) */
199*4882a593Smuzhiyun     dmxLateReInitProcPtr latereinit;          /**< Reinitialize a device
200*4882a593Smuzhiyun                                                * (called very late
201*4882a593Smuzhiyun                                                * during a
202*4882a593Smuzhiyun                                                * reconfiguration) */
203*4882a593Smuzhiyun     dmxGetInfoProcPtr get_info;               /**< Get device information */
204*4882a593Smuzhiyun     dmxOnProcPtr on;                          /**< Turn device on */
205*4882a593Smuzhiyun     dmxOffProcPtr off;                        /**< Turn device off */
206*4882a593Smuzhiyun     dmxUpdatePositionProcPtr update_position; /**< Called when another
207*4882a593Smuzhiyun                                                * device updates the
208*4882a593Smuzhiyun                                                * cursor position */
209*4882a593Smuzhiyun     dmxVTPreSwitchProcPtr vt_pre_switch;      /**< Called before a VT switch */
210*4882a593Smuzhiyun     dmxVTPostSwitchProcPtr vt_post_switch;    /**< Called after a VT switch */
211*4882a593Smuzhiyun     dmxVTSwitchProcPtr vt_switch;             /**< Causes a VT switch */
212*4882a593Smuzhiyun 
213*4882a593Smuzhiyun     dmxCollectEventsProcPtr collect_events;   /**< Collect and enqueue
214*4882a593Smuzhiyun                                                * events from the
215*4882a593Smuzhiyun                                                * device*/
216*4882a593Smuzhiyun     dmxProcessInputProcPtr process_input;     /**< Process event (from
217*4882a593Smuzhiyun                                                * queue)  */
218*4882a593Smuzhiyun     dmxFunctionsProcPtr functions;
219*4882a593Smuzhiyun     dmxUpdateInfoProcPtr update_info;         /**< Update window layout
220*4882a593Smuzhiyun                                                * information */
221*4882a593Smuzhiyun 
222*4882a593Smuzhiyun     dmxMCtrlProcPtr mCtrl;                    /**< Pointer control */
223*4882a593Smuzhiyun     dmxKBCtrlProcPtr kCtrl;                   /**< Keyboard control */
224*4882a593Smuzhiyun     dmxKBBellProcPtr kBell;                   /**< Bell control */
225*4882a593Smuzhiyun 
226*4882a593Smuzhiyun     void *private;                            /**< Device-dependent private  */
227*4882a593Smuzhiyun     int isCore;                               /**< Is a DMX core device  */
228*4882a593Smuzhiyun     int sendsCore;                            /**< Sends DMX core events */
229*4882a593Smuzhiyun     KeybdCtrl kctrl;                          /**< Keyboard control */
230*4882a593Smuzhiyun     PtrCtrl mctrl;                            /**< Pointer control */
231*4882a593Smuzhiyun 
232*4882a593Smuzhiyun     DeviceIntPtr pDevice;                     /**< X-level device  */
233*4882a593Smuzhiyun     int inputIdx;                             /**< High-level index */
234*4882a593Smuzhiyun     int lastX, lastY;                         /**< Last known position;
235*4882a593Smuzhiyun                                                * for XInput in
236*4882a593Smuzhiyun                                                * dmxevents.c */
237*4882a593Smuzhiyun 
238*4882a593Smuzhiyun     int head;                                 /**< XInput motion history
239*4882a593Smuzhiyun                                                * head */
240*4882a593Smuzhiyun     int tail;                                 /**< XInput motion history
241*4882a593Smuzhiyun                                                * tail */
242*4882a593Smuzhiyun     unsigned long *history;                   /**< XInput motion history */
243*4882a593Smuzhiyun     int *valuators;                           /**< Cache of previous values */
244*4882a593Smuzhiyun 
245*4882a593Smuzhiyun     /* for XInput ChangePointerDevice */
246*4882a593Smuzhiyun     int (*savedMotionProc) (DeviceIntPtr,
247*4882a593Smuzhiyun                             xTimecoord *,
248*4882a593Smuzhiyun                             unsigned long, unsigned long, ScreenPtr);
249*4882a593Smuzhiyun     int savedMotionEvents;                      /**< Saved motion events */
250*4882a593Smuzhiyun     int savedSendsCore;                         /**< Saved sends-core flag */
251*4882a593Smuzhiyun 
252*4882a593Smuzhiyun     DMXEventMap map[DMX_MAP_ENTRIES];              /**< XInput device id map */
253*4882a593Smuzhiyun     int mapOptimize;                               /**< XInput device id
254*4882a593Smuzhiyun                                                     * map
255*4882a593Smuzhiyun                                                     * optimization */
256*4882a593Smuzhiyun 
257*4882a593Smuzhiyun     long deviceId;                        /**< device id on remote side,
258*4882a593Smuzhiyun                                            * if any */
259*4882a593Smuzhiyun     const char *deviceName;               /**< devive name on remote
260*4882a593Smuzhiyun                                            * side, if any */
261*4882a593Smuzhiyun } DMXLocalInputInfoRec;
262*4882a593Smuzhiyun 
263*4882a593Smuzhiyun extern DMXLocalInputInfoPtr dmxLocalCorePointer, dmxLocalCoreKeyboard;
264*4882a593Smuzhiyun 
265*4882a593Smuzhiyun extern void dmxLocalInitInput(DMXInputInfo * dmxInput);
266*4882a593Smuzhiyun extern DMXLocalInputInfoPtr dmxInputCopyLocal(DMXInputInfo * dmxInput,
267*4882a593Smuzhiyun                                               DMXLocalInputInfoPtr s);
268*4882a593Smuzhiyun 
269*4882a593Smuzhiyun extern void dmxChangePointerControl(DeviceIntPtr pDevice, PtrCtrl * ctrl);
270*4882a593Smuzhiyun extern void dmxKeyboardKbdCtrlProc(DeviceIntPtr pDevice, KeybdCtrl * ctrl);
271*4882a593Smuzhiyun extern void dmxKeyboardBellProc(int percent, DeviceIntPtr pDevice,
272*4882a593Smuzhiyun                                 void *ctrl, int unknown);
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun extern int dmxInputExtensionErrorHandler(Display * dsp, _Xconst char *name,
275*4882a593Smuzhiyun                                          _Xconst char *reason);
276*4882a593Smuzhiyun 
277*4882a593Smuzhiyun extern int dmxInputDetach(DMXInputInfo * dmxInput);
278*4882a593Smuzhiyun extern void dmxInputDetachAll(DMXScreenInfo * dmxScreen);
279*4882a593Smuzhiyun extern int dmxInputDetachId(int id);
280*4882a593Smuzhiyun extern DMXInputInfo *dmxInputLocateId(int id);
281*4882a593Smuzhiyun extern int dmxInputAttachConsole(const char *name, int isCore, int *id);
282*4882a593Smuzhiyun extern int dmxInputAttachBackend(int physicalScreen, int isCore, int *id);
283*4882a593Smuzhiyun 
284*4882a593Smuzhiyun #endif
285