1/*
2 * Copyright 2002,2003 Red Hat Inc., Durham, North Carolina.
3 *
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation on the rights to use, copy, modify, merge,
10 * publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NON-INFRINGEMENT.  IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 */
27
28/*
29 * Authors:
30 *   Rickard E. (Rik) Faith <faith@redhat.com>
31 *
32 */
33
34/** \file
35 * Interface to functions used by backend and console input devices.
36 * \see dmxcommon.c \see dmxbackend.c \see dmxconsole.c */
37
38#ifndef _DMXCOMMON_H_
39#define _DMXCOMMON_H_
40
41#define DMX_COMMON_OTHER                    \
42    Display                 *display;       \
43    Window                  window;         \
44    DMXScreenInfo           *be;            \
45    DMXLocalInputInfoPtr    dmxLocal;       \
46    int                     initPointerX;   \
47    int                     initPointerY;   \
48    long                    eventMask;      \
49    KeybdCtrl               kctrl;          \
50    PtrCtrl                 mctrl;          \
51    int                     kctrlset;       \
52    int                     mctrlset;       \
53    KeybdCtrl               savedKctrl;     \
54    XModifierKeymap         *savedModMap;   \
55    int                     stateSaved
56
57#define DMX_COMMON_XKB                      \
58    DMX_COMMON_OTHER;                       \
59    XkbDescPtr              xkb;            \
60    XkbIndicatorRec         savedIndicators
61
62#define DMX_COMMON_PRIVATE                  \
63    DMX_COMMON_XKB;                         \
64    XDevice                 *xi
65
66#define GETONLYPRIVFROMPRIVATE                                          \
67    myPrivate            *priv     = private
68
69#define GETPRIVFROMPRIVATE                                              \
70    GETONLYPRIVFROMPRIVATE;                                             \
71    DMXInputInfo         *dmxInput = &dmxInputs[priv->dmxLocal->inputIdx]
72
73#define GETDMXLOCALFROMPDEVICE                                          \
74    DevicePtr            pDev      = &pDevice->public;                  \
75    DMXLocalInputInfoPtr dmxLocal  = pDev->devicePrivate
76
77#define GETDMXINPUTFROMPRIV                                             \
78    DMXInputInfo         *dmxInput = &dmxInputs[priv->dmxLocal->inputIdx]
79
80#define GETDMXINPUTFROMPDEVICE                                          \
81    GETDMXLOCALFROMPDEVICE;                                             \
82    DMXInputInfo         *dmxInput = &dmxInputs[dmxLocal->inputIdx]
83
84#define GETDMXLOCALFROMPDEV                                             \
85    DMXLocalInputInfoPtr dmxLocal  = pDev->devicePrivate
86
87#define GETDMXINPUTFROMPDEV                                             \
88    GETDMXLOCALFROMPDEV;                                                \
89    DMXInputInfo         *dmxInput = &dmxInputs[dmxLocal->inputIdx]
90
91#define GETPRIVFROMPDEV                                                 \
92    GETDMXLOCALFROMPDEV;                                                \
93    myPrivate            *priv     = dmxLocal->private
94
95#define DMX_KEYBOARD_EVENT_MASK                                         \
96    (KeyPressMask | KeyReleaseMask | KeymapStateMask)
97
98#define DMX_POINTER_EVENT_MASK                                          \
99    (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
100
101extern void    dmxCommonKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
102extern void    dmxCommonKbdGetMap(DevicePtr pDev,
103                                  KeySymsPtr pKeySyms, CARD8 *pModMap);
104extern void    dmxCommonKbdCtrl(DevicePtr pDev, KeybdCtrl *ctrl);
105extern void    dmxCommonKbdBell(DevicePtr pDev, int percent,
106                                int volume, int pitch, int duration);
107extern int     dmxCommonKbdOn(DevicePtr pDev);
108extern void    dmxCommonKbdOff(DevicePtr pDev);
109extern void    dmxCommonMouGetMap(DevicePtr pDev,
110                                  unsigned char *map, int *nButtons);
111extern void    dmxCommonMouCtrl(DevicePtr pDev, PtrCtrl *ctrl);
112extern int     dmxCommonMouOn(DevicePtr pDev);
113extern void    dmxCommonMouOff(DevicePtr pDev);
114extern int     dmxFindPointerScreen(int x, int y);
115
116extern int     dmxCommonOthOn(DevicePtr pDev);
117extern void    dmxCommonOthOff(DevicePtr pDev);
118extern void    dmxCommonOthGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
119
120                                /* helper functions */
121extern pointer dmxCommonCopyPrivate(DeviceIntPtr pDevice);
122extern void    dmxCommonSaveState(pointer private);
123extern void    dmxCommonRestoreState(pointer private);
124#endif
125