1706f2543Smrg/* 2706f2543Smrg * Copyright 2002 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 for low-level input support. \see dmxinputinit.c */ 36706f2543Smrg 37706f2543Smrg#ifndef _DMXINPUTINIT_H_ 38706f2543Smrg#define _DMXINPUTINIT_H_ 39706f2543Smrg 40706f2543Smrg#include "dmx.h" 41706f2543Smrg#include "dmxinput.h" 42706f2543Smrg#include "dmxlog.h" 43706f2543Smrg 44706f2543Smrg 45706f2543Smrg#define DMX_LOCAL_DEFAULT_KEYBOARD "kbd" 46706f2543Smrg#define DMX_LOCAL_DEFAULT_POINTER "ps2" 47706f2543Smrg#define DMX_MAX_BUTTONS 256 48706f2543Smrg#define DMX_MOTION_SIZE 256 49706f2543Smrg#define DMX_MAX_VALUATORS 32 50706f2543Smrg#define DMX_MAX_AXES 32 51706f2543Smrg#define DMX_MAX_XINPUT_EVENT_TYPES 100 52706f2543Smrg#define DMX_MAP_ENTRIES 16 /* Must be a power of 2 */ 53706f2543Smrg#define DMX_MAP_MASK (DMX_MAP_ENTRIES - 1) 54706f2543Smrg 55706f2543Smrgtypedef enum { 56706f2543Smrg DMX_FUNCTION_GRAB, 57706f2543Smrg DMX_FUNCTION_TERMINATE, 58706f2543Smrg DMX_FUNCTION_FINE 59706f2543Smrg} DMXFunctionType; 60706f2543Smrg 61706f2543Smrgtypedef enum { 62706f2543Smrg DMX_LOCAL_HIGHLEVEL, 63706f2543Smrg DMX_LOCAL_KEYBOARD, 64706f2543Smrg DMX_LOCAL_MOUSE, 65706f2543Smrg DMX_LOCAL_OTHER 66706f2543Smrg} DMXLocalInputType; 67706f2543Smrg 68706f2543Smrgtypedef enum { 69706f2543Smrg DMX_LOCAL_TYPE_LOCAL, 70706f2543Smrg DMX_LOCAL_TYPE_CONSOLE, 71706f2543Smrg DMX_LOCAL_TYPE_BACKEND, 72706f2543Smrg DMX_LOCAL_TYPE_COMMON 73706f2543Smrg} DMXLocalInputExtType; 74706f2543Smrg 75706f2543Smrgtypedef enum { 76706f2543Smrg DMX_RELATIVE, 77706f2543Smrg DMX_ABSOLUTE, 78706f2543Smrg DMX_ABSOLUTE_CONFINED 79706f2543Smrg} DMXMotionType; 80706f2543Smrg 81706f2543Smrg/** Stores information from low-level device that is used to initialize 82706f2543Smrg * the device at the dix level. */ 83706f2543Smrgtypedef struct _DMXLocalInitInfo { 84706f2543Smrg int keyboard; /**< Non-zero if the device is a keyboard */ 85706f2543Smrg 86706f2543Smrg int keyClass; /**< Non-zero if keys are present */ 87706f2543Smrg KeySymsRec keySyms; /**< Key symbols */ 88706f2543Smrg int freemap; /**< If non-zero, free keySyms.map */ 89706f2543Smrg CARD8 modMap[MAP_LENGTH]; /**< Modifier map */ 90706f2543Smrg XkbDescPtr xkb; /**< XKB description */ 91706f2543Smrg XkbComponentNamesRec names; /**< XKB component names */ 92706f2543Smrg int freenames; /**< Non-zero if names should be free'd */ 93706f2543Smrg int force; /**< Do not allow command line override */ 94706f2543Smrg 95706f2543Smrg int buttonClass; /**< Non-zero if buttons are present */ 96706f2543Smrg int numButtons; /**< Number of buttons */ 97706f2543Smrg unsigned char map[DMX_MAX_BUTTONS]; /**< Button map */ 98706f2543Smrg 99706f2543Smrg int valuatorClass; /**< Non-zero if valuators are 100706f2543Smrg * present */ 101706f2543Smrg int numRelAxes; /**< Number of relative axes */ 102706f2543Smrg int numAbsAxes; /**< Number of absolute axes */ 103706f2543Smrg int minval[DMX_MAX_AXES]; /**< Minimum values */ 104706f2543Smrg int maxval[DMX_MAX_AXES]; /**< Maximum values */ 105706f2543Smrg int res[DMX_MAX_AXES]; /**< Resolution */ 106706f2543Smrg int minres[DMX_MAX_AXES]; /**< Minimum resolutions */ 107706f2543Smrg int maxres[DMX_MAX_AXES]; /**< Maximum resolutions */ 108706f2543Smrg 109706f2543Smrg int focusClass; /**< Non-zero if device can 110706f2543Smrg * cause focus */ 111706f2543Smrg int proximityClass; /**< Non-zero if device 112706f2543Smrg * causes proximity events */ 113706f2543Smrg int kbdFeedbackClass; /**< Non-zero if device has 114706f2543Smrg * keyboard feedback */ 115706f2543Smrg int ptrFeedbackClass; /**< Non-zero if device has 116706f2543Smrg * pointer feedback */ 117706f2543Smrg int ledFeedbackClass; /**< Non-zero if device has 118706f2543Smrg * LED indicators */ 119706f2543Smrg int belFeedbackClass; /**< Non-zero if device has a 120706f2543Smrg * bell */ 121706f2543Smrg int intFeedbackClass; /**< Non-zero if device has 122706f2543Smrg * integer feedback */ 123706f2543Smrg int strFeedbackClass; /**< Non-zero if device has 124706f2543Smrg * string feedback */ 125706f2543Smrg 126706f2543Smrg int maxSymbols; /**< Maximum symbols */ 127706f2543Smrg int maxSymbolsSupported; /**< Maximum symbols supported */ 128706f2543Smrg KeySym *symbols; /**< Key symbols */ 129706f2543Smrg} DMXLocalInitInfo, *DMXLocalInitInfoPtr; 130706f2543Smrg 131706f2543Smrgtypedef pointer (*dmxCreatePrivateProcPtr)(DeviceIntPtr); 132706f2543Smrgtypedef void (*dmxDestroyPrivateProcPtr)(pointer); 133706f2543Smrg 134706f2543Smrgtypedef void (*dmxInitProcPtr)(DevicePtr); 135706f2543Smrgtypedef void (*dmxReInitProcPtr)(DevicePtr); 136706f2543Smrgtypedef void (*dmxLateReInitProcPtr)(DevicePtr); 137706f2543Smrgtypedef void (*dmxGetInfoProcPtr)(DevicePtr, DMXLocalInitInfoPtr); 138706f2543Smrgtypedef int (*dmxOnProcPtr)(DevicePtr); 139706f2543Smrgtypedef void (*dmxOffProcPtr)(DevicePtr); 140706f2543Smrgtypedef void (*dmxUpdatePositionProcPtr)(pointer, int x, int y); 141706f2543Smrg 142706f2543Smrgtypedef void (*dmxVTPreSwitchProcPtr)(pointer); /* Turn I/O Off */ 143706f2543Smrgtypedef void (*dmxVTPostSwitchProcPtr)(pointer); /* Turn I/O On */ 144706f2543Smrgtypedef void (*dmxVTSwitchReturnProcPtr)(pointer); 145706f2543Smrgtypedef int (*dmxVTSwitchProcPtr)(pointer, int vt, 146706f2543Smrg dmxVTSwitchReturnProcPtr, pointer); 147706f2543Smrg 148706f2543Smrgtypedef void (*dmxMotionProcPtr)(DevicePtr, 149706f2543Smrg int *valuators, 150706f2543Smrg int firstAxis, 151706f2543Smrg int axesCount, 152706f2543Smrg DMXMotionType type, 153706f2543Smrg DMXBlockType block); 154706f2543Smrgtypedef void (*dmxEnqueueProcPtr)(DevicePtr, int type, int detail, 155706f2543Smrg KeySym keySym, XEvent *e, 156706f2543Smrg DMXBlockType block); 157706f2543Smrgtypedef int (*dmxCheckSpecialProcPtr)(DevicePtr, KeySym keySym); 158706f2543Smrgtypedef void (*dmxCollectEventsProcPtr)(DevicePtr, 159706f2543Smrg dmxMotionProcPtr, 160706f2543Smrg dmxEnqueueProcPtr, 161706f2543Smrg dmxCheckSpecialProcPtr, 162706f2543Smrg DMXBlockType); 163706f2543Smrgtypedef void (*dmxProcessInputProcPtr)(pointer); 164706f2543Smrgtypedef void (*dmxUpdateInfoProcPtr)(pointer, DMXUpdateType, WindowPtr); 165706f2543Smrgtypedef int (*dmxFunctionsProcPtr)(pointer, DMXFunctionType); 166706f2543Smrg 167706f2543Smrgtypedef void (*dmxKBCtrlProcPtr)(DevicePtr, KeybdCtrl *ctrl); 168706f2543Smrgtypedef void (*dmxMCtrlProcPtr)(DevicePtr, PtrCtrl *ctrl); 169706f2543Smrgtypedef void (*dmxKBBellProcPtr)(DevicePtr, int percent, 170706f2543Smrg int volume, int pitch, int duration); 171706f2543Smrg 172706f2543Smrg/** Stores a mapping between the device id on the remote X server and 173706f2543Smrg * the id on the DMX server */ 174706f2543Smrgtypedef struct _DMXEventMap { 175706f2543Smrg int remote; /**< Event number on remote X server */ 176706f2543Smrg int server; /**< Event number (unbiased) on DMX server */ 177706f2543Smrg} DMXEventMap; 178706f2543Smrg 179706f2543Smrg/** This is the device-independent structure used by the low-level input 180706f2543Smrg * routines. The contents are not exposed to top-level .c files (except 181706f2543Smrg * dmxextensions.c). \see dmxinput.h \see dmxextensions.c */ 182706f2543Smrgtypedef struct _DMXLocalInputInfo { 183706f2543Smrg const char *name; /**< Device name */ 184706f2543Smrg DMXLocalInputType type; /**< Device type */ 185706f2543Smrg DMXLocalInputExtType extType; /**< Extended device type */ 186706f2543Smrg int binding; /**< Count of how many consecutive 187706f2543Smrg * structs are bound to the same 188706f2543Smrg * device */ 189706f2543Smrg 190706f2543Smrg /* Low-level (e.g., keyboard/mouse drivers) */ 191706f2543Smrg 192706f2543Smrg dmxCreatePrivateProcPtr create_private; /**< Create 193706f2543Smrg * device-dependent 194706f2543Smrg * private */ 195706f2543Smrg dmxDestroyPrivateProcPtr destroy_private; /**< Destroy 196706f2543Smrg * device-dependent 197706f2543Smrg * private */ 198706f2543Smrg dmxInitProcPtr init; /**< Initialize device */ 199706f2543Smrg dmxReInitProcPtr reinit; /**< Reinitialize device 200706f2543Smrg * (during a 201706f2543Smrg * reconfiguration) */ 202706f2543Smrg dmxLateReInitProcPtr latereinit; /**< Reinitialize a device 203706f2543Smrg * (called very late 204706f2543Smrg * during a 205706f2543Smrg * reconfiguration) */ 206706f2543Smrg dmxGetInfoProcPtr get_info; /**< Get device information */ 207706f2543Smrg dmxOnProcPtr on; /**< Turn device on */ 208706f2543Smrg dmxOffProcPtr off; /**< Turn device off */ 209706f2543Smrg dmxUpdatePositionProcPtr update_position; /**< Called when another 210706f2543Smrg * device updates the 211706f2543Smrg * cursor position */ 212706f2543Smrg dmxVTPreSwitchProcPtr vt_pre_switch; /**< Called before a VT switch */ 213706f2543Smrg dmxVTPostSwitchProcPtr vt_post_switch; /**< Called after a VT switch */ 214706f2543Smrg dmxVTSwitchProcPtr vt_switch; /**< Causes a VT switch */ 215706f2543Smrg 216706f2543Smrg dmxCollectEventsProcPtr collect_events; /**< Collect and enqueue 217706f2543Smrg * events from the 218706f2543Smrg * device*/ 219706f2543Smrg dmxProcessInputProcPtr process_input; /**< Process event (from 220706f2543Smrg * queue) */ 221706f2543Smrg dmxFunctionsProcPtr functions; 222706f2543Smrg dmxUpdateInfoProcPtr update_info; /**< Update window layout 223706f2543Smrg * information */ 224706f2543Smrg 225706f2543Smrg dmxMCtrlProcPtr mCtrl; /**< Pointer control */ 226706f2543Smrg dmxKBCtrlProcPtr kCtrl; /**< Keyboard control */ 227706f2543Smrg dmxKBBellProcPtr kBell; /**< Bell control */ 228706f2543Smrg 229706f2543Smrg pointer private; /**< Device-dependent private */ 230706f2543Smrg int isCore; /**< Is a DMX core device */ 231706f2543Smrg int sendsCore; /**< Sends DMX core events */ 232706f2543Smrg KeybdCtrl kctrl; /**< Keyboard control */ 233706f2543Smrg PtrCtrl mctrl; /**< Pointer control */ 234706f2543Smrg 235706f2543Smrg DeviceIntPtr pDevice; /**< X-level device */ 236706f2543Smrg int inputIdx; /**< High-level index */ 237706f2543Smrg int lastX, lastY; /**< Last known position; 238706f2543Smrg * for XInput in 239706f2543Smrg * dmxevents.c */ 240706f2543Smrg 241706f2543Smrg int head; /**< XInput motion history 242706f2543Smrg * head */ 243706f2543Smrg int tail; /**< XInput motion history 244706f2543Smrg * tail */ 245706f2543Smrg unsigned long *history; /**< XInput motion history */ 246706f2543Smrg int *valuators; /**< Cache of previous values */ 247706f2543Smrg 248706f2543Smrg /* for XInput ChangePointerDevice */ 249706f2543Smrg int (*savedMotionProc)(DeviceIntPtr, 250706f2543Smrg xTimecoord *, 251706f2543Smrg unsigned long, 252706f2543Smrg unsigned long, 253706f2543Smrg ScreenPtr); 254706f2543Smrg int savedMotionEvents; /**< Saved motion events */ 255706f2543Smrg int savedSendsCore; /**< Saved sends-core flag */ 256706f2543Smrg 257706f2543Smrg DMXEventMap map[DMX_MAP_ENTRIES]; /**< XInput device id map */ 258706f2543Smrg int mapOptimize; /**< XInput device id 259706f2543Smrg * map 260706f2543Smrg * optimization */ 261706f2543Smrg 262706f2543Smrg long deviceId; /**< device id on remote side, 263706f2543Smrg * if any */ 264706f2543Smrg const char *deviceName; /**< devive name on remote 265706f2543Smrg * side, if any */ 266706f2543Smrg} DMXLocalInputInfoRec; 267706f2543Smrg 268706f2543Smrgextern DMXLocalInputInfoPtr dmxLocalCorePointer, dmxLocalCoreKeyboard; 269706f2543Smrg 270706f2543Smrgextern void dmxLocalInitInput(DMXInputInfo *dmxInput); 271706f2543Smrgextern DMXLocalInputInfoPtr dmxInputCopyLocal(DMXInputInfo *dmxInput, 272706f2543Smrg DMXLocalInputInfoPtr s); 273706f2543Smrg 274706f2543Smrgextern void dmxChangePointerControl(DeviceIntPtr pDevice, PtrCtrl *ctrl); 275706f2543Smrgextern void dmxKeyboardKbdCtrlProc(DeviceIntPtr pDevice, KeybdCtrl *ctrl); 276706f2543Smrgextern void dmxKeyboardBellProc(int percent, DeviceIntPtr pDevice, 277706f2543Smrg pointer ctrl, int unknown); 278706f2543Smrg 279706f2543Smrgextern int dmxInputExtensionErrorHandler(Display *dsp, _Xconst char *name, 280706f2543Smrg _Xconst char *reason); 281706f2543Smrg 282706f2543Smrgextern int dmxInputDetach(DMXInputInfo *dmxInput); 283706f2543Smrgextern void dmxInputDetachAll(DMXScreenInfo *dmxScreen); 284706f2543Smrgextern int dmxInputDetachId(int id); 285706f2543Smrgextern DMXInputInfo *dmxInputLocateId(int id); 286706f2543Smrgextern int dmxInputAttachConsole(const char *name, int isCore, 287706f2543Smrg int *id); 288706f2543Smrgextern int dmxInputAttachBackend(int physicalScreen, int isCore, 289706f2543Smrg int *id); 290706f2543Smrg 291706f2543Smrg#endif 292