1706f2543Smrg/*
2706f2543Smrg * Copyright 2002,2003 Red Hat Inc., Durham, North Carolina.
3706f2543Smrg *
4706f2543Smrg * All Rights Reserved.
5706f2543Smrg *
6706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining
7706f2543Smrg * a copy of this software and associated documentation files (the
8706f2543Smrg * "Software"), to deal in the Software without restriction, including
9706f2543Smrg * without limitation on the rights to use, copy, modify, merge,
10706f2543Smrg * publish, distribute, sublicense, and/or sell copies of the Software,
11706f2543Smrg * and to permit persons to whom the Software is furnished to do so,
12706f2543Smrg * subject to the following conditions:
13706f2543Smrg *
14706f2543Smrg * The above copyright notice and this permission notice (including the
15706f2543Smrg * next paragraph) shall be included in all copies or substantial
16706f2543Smrg * portions of the Software.
17706f2543Smrg *
18706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19706f2543Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20706f2543Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21706f2543Smrg * NON-INFRINGEMENT.  IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
22706f2543Smrg * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23706f2543Smrg * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24706f2543Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25706f2543Smrg * SOFTWARE.
26706f2543Smrg */
27706f2543Smrg
28706f2543Smrg/*
29706f2543Smrg * Authors:
30706f2543Smrg *   Rickard E. (Rik) Faith <faith@redhat.com>
31706f2543Smrg *
32706f2543Smrg */
33706f2543Smrg
34706f2543Smrg/** \file
35706f2543Smrg * Interface to functions used by backend and console input devices.
36706f2543Smrg * \see dmxcommon.c \see dmxbackend.c \see dmxconsole.c */
37706f2543Smrg
38706f2543Smrg#ifndef _DMXCOMMON_H_
39706f2543Smrg#define _DMXCOMMON_H_
40706f2543Smrg
41706f2543Smrg#define DMX_COMMON_OTHER                    \
42706f2543Smrg    Display                 *display;       \
43706f2543Smrg    Window                  window;         \
44706f2543Smrg    DMXScreenInfo           *be;            \
45706f2543Smrg    DMXLocalInputInfoPtr    dmxLocal;       \
46706f2543Smrg    int                     initPointerX;   \
47706f2543Smrg    int                     initPointerY;   \
48706f2543Smrg    long                    eventMask;      \
49706f2543Smrg    KeybdCtrl               kctrl;          \
50706f2543Smrg    PtrCtrl                 mctrl;          \
51706f2543Smrg    int                     kctrlset;       \
52706f2543Smrg    int                     mctrlset;       \
53706f2543Smrg    KeybdCtrl               savedKctrl;     \
54706f2543Smrg    XModifierKeymap         *savedModMap;   \
55706f2543Smrg    int                     stateSaved
56706f2543Smrg
57706f2543Smrg#define DMX_COMMON_XKB                      \
58706f2543Smrg    DMX_COMMON_OTHER;                       \
59706f2543Smrg    XkbDescPtr              xkb;            \
60706f2543Smrg    XkbIndicatorRec         savedIndicators
61706f2543Smrg
62706f2543Smrg#define DMX_COMMON_PRIVATE                  \
63706f2543Smrg    DMX_COMMON_XKB;                         \
64706f2543Smrg    XDevice                 *xi
65706f2543Smrg
66706f2543Smrg#define GETONLYPRIVFROMPRIVATE                                          \
67706f2543Smrg    myPrivate            *priv     = private
68706f2543Smrg
69706f2543Smrg#define GETPRIVFROMPRIVATE                                              \
70706f2543Smrg    GETONLYPRIVFROMPRIVATE;                                             \
71706f2543Smrg    DMXInputInfo         *dmxInput = &dmxInputs[priv->dmxLocal->inputIdx]
72706f2543Smrg
73706f2543Smrg#define GETDMXLOCALFROMPDEVICE                                          \
74706f2543Smrg    DevicePtr            pDev      = &pDevice->public;                  \
75706f2543Smrg    DMXLocalInputInfoPtr dmxLocal  = pDev->devicePrivate
76706f2543Smrg
77706f2543Smrg#define GETDMXINPUTFROMPRIV                                             \
78706f2543Smrg    DMXInputInfo         *dmxInput = &dmxInputs[priv->dmxLocal->inputIdx]
79706f2543Smrg
80706f2543Smrg#define GETDMXINPUTFROMPDEVICE                                          \
81706f2543Smrg    GETDMXLOCALFROMPDEVICE;                                             \
82706f2543Smrg    DMXInputInfo         *dmxInput = &dmxInputs[dmxLocal->inputIdx]
83706f2543Smrg
84706f2543Smrg#define GETDMXLOCALFROMPDEV                                             \
85706f2543Smrg    DMXLocalInputInfoPtr dmxLocal  = pDev->devicePrivate
86706f2543Smrg
87706f2543Smrg#define GETDMXINPUTFROMPDEV                                             \
88706f2543Smrg    GETDMXLOCALFROMPDEV;                                                \
89706f2543Smrg    DMXInputInfo         *dmxInput = &dmxInputs[dmxLocal->inputIdx]
90706f2543Smrg
91706f2543Smrg#define GETPRIVFROMPDEV                                                 \
92706f2543Smrg    GETDMXLOCALFROMPDEV;                                                \
93706f2543Smrg    myPrivate            *priv     = dmxLocal->private
94706f2543Smrg
95706f2543Smrg#define DMX_KEYBOARD_EVENT_MASK                                         \
96706f2543Smrg    (KeyPressMask | KeyReleaseMask | KeymapStateMask)
97706f2543Smrg
98706f2543Smrg#define DMX_POINTER_EVENT_MASK                                          \
99706f2543Smrg    (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
100706f2543Smrg
101706f2543Smrgextern void    dmxCommonKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
102706f2543Smrgextern void    dmxCommonKbdGetMap(DevicePtr pDev,
103706f2543Smrg                                  KeySymsPtr pKeySyms, CARD8 *pModMap);
104706f2543Smrgextern void    dmxCommonKbdCtrl(DevicePtr pDev, KeybdCtrl *ctrl);
105706f2543Smrgextern void    dmxCommonKbdBell(DevicePtr pDev, int percent,
106706f2543Smrg                                int volume, int pitch, int duration);
107706f2543Smrgextern int     dmxCommonKbdOn(DevicePtr pDev);
108706f2543Smrgextern void    dmxCommonKbdOff(DevicePtr pDev);
109706f2543Smrgextern void    dmxCommonMouGetMap(DevicePtr pDev,
110706f2543Smrg                                  unsigned char *map, int *nButtons);
111706f2543Smrgextern void    dmxCommonMouCtrl(DevicePtr pDev, PtrCtrl *ctrl);
112706f2543Smrgextern int     dmxCommonMouOn(DevicePtr pDev);
113706f2543Smrgextern void    dmxCommonMouOff(DevicePtr pDev);
114706f2543Smrgextern int     dmxFindPointerScreen(int x, int y);
115706f2543Smrg
116706f2543Smrgextern int     dmxCommonOthOn(DevicePtr pDev);
117706f2543Smrgextern void    dmxCommonOthOff(DevicePtr pDev);
118706f2543Smrgextern void    dmxCommonOthGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
119706f2543Smrg
120706f2543Smrg                                /* helper functions */
121706f2543Smrgextern pointer dmxCommonCopyPrivate(DeviceIntPtr pDevice);
122706f2543Smrgextern void    dmxCommonSaveState(pointer private);
123706f2543Smrgextern void    dmxCommonRestoreState(pointer private);
124706f2543Smrg#endif
125