xserver

xserver with xephyr scale patch
git clone https://git.neptards.moe/u3shit/xserver.git
Log | Files | Refs | README | LICENSE

InitInput.c (3680B)


      1 /*
      2 
      3 Copyright 1993, 1998  The Open Group
      4 
      5 Permission to use, copy, modify, distribute, and sell this software and its
      6 documentation for any purpose is hereby granted without fee, provided that
      7 the above copyright notice appear in all copies and that both that
      8 copyright notice and this permission notice appear in supporting
      9 documentation.
     10 
     11 The above copyright notice and this permission notice shall be included
     12 in all copies or substantial portions of the Software.
     13 
     14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
     18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     20 OTHER DEALINGS IN THE SOFTWARE.
     21 
     22 Except as contained in this notice, the name of The Open Group shall
     23 not be used in advertising or otherwise to promote the sale, use or
     24 other dealings in this Software without prior written authorization
     25 from The Open Group.
     26 
     27 */
     28 
     29 #ifdef HAVE_DIX_CONFIG_H
     30 #include <dix-config.h>
     31 #endif
     32 
     33 #include <X11/X.h>
     34 #include "mi.h"
     35 #include <X11/Xproto.h>
     36 #include "scrnintstr.h"
     37 #include "inputstr.h"
     38 #include <X11/Xos.h>
     39 #include "mipointer.h"
     40 #include "xkbsrv.h"
     41 #include <X11/keysym.h>
     42 #include "xserver-properties.h"
     43 #include "exevents.h"
     44 #include "extinit.h"
     45 
     46 void
     47 ProcessInputEvents(void)
     48 {
     49     mieqProcessInputEvents();
     50 }
     51 
     52 void
     53 DDXRingBell(int volume, int pitch, int duration)
     54 {
     55 }
     56 
     57 #define VFB_MIN_KEY 8
     58 #define VFB_MAX_KEY 255
     59 
     60 static int
     61 vfbKeybdProc(DeviceIntPtr pDevice, int onoff)
     62 {
     63     DevicePtr pDev = (DevicePtr) pDevice;
     64 
     65     switch (onoff) {
     66     case DEVICE_INIT:
     67         InitKeyboardDeviceStruct(pDevice, NULL, NULL, NULL);
     68         break;
     69     case DEVICE_ON:
     70         pDev->on = TRUE;
     71         break;
     72     case DEVICE_OFF:
     73         pDev->on = FALSE;
     74         break;
     75     case DEVICE_CLOSE:
     76         break;
     77     }
     78     return Success;
     79 }
     80 
     81 static int
     82 vfbMouseProc(DeviceIntPtr pDevice, int onoff)
     83 {
     84 #define NBUTTONS 3
     85 #define NAXES 2
     86 
     87     BYTE map[NBUTTONS + 1];
     88     DevicePtr pDev = (DevicePtr) pDevice;
     89     Atom btn_labels[NBUTTONS] = { 0 };
     90     Atom axes_labels[NAXES] = { 0 };
     91 
     92     switch (onoff) {
     93     case DEVICE_INIT:
     94         map[1] = 1;
     95         map[2] = 2;
     96         map[3] = 3;
     97 
     98         btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
     99         btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
    100         btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
    101 
    102         axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
    103         axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
    104 
    105         InitPointerDeviceStruct(pDev, map, NBUTTONS, btn_labels,
    106                                 (PtrCtrlProcPtr) NoopDDA,
    107                                 GetMotionHistorySize(), NAXES, axes_labels);
    108         break;
    109 
    110     case DEVICE_ON:
    111         pDev->on = TRUE;
    112         break;
    113 
    114     case DEVICE_OFF:
    115         pDev->on = FALSE;
    116         break;
    117 
    118     case DEVICE_CLOSE:
    119         break;
    120     }
    121     return Success;
    122 
    123 #undef NBUTTONS
    124 #undef NAXES
    125 }
    126 
    127 void
    128 InitInput(int argc, char *argv[])
    129 {
    130     DeviceIntPtr p, k;
    131     Atom xiclass;
    132 
    133     p = AddInputDevice(serverClient, vfbMouseProc, TRUE);
    134     k = AddInputDevice(serverClient, vfbKeybdProc, TRUE);
    135     xiclass = MakeAtom(XI_MOUSE, sizeof(XI_MOUSE) - 1, TRUE);
    136     AssignTypeAndName(p, xiclass, "Xvfb mouse");
    137     xiclass = MakeAtom(XI_KEYBOARD, sizeof(XI_KEYBOARD) - 1, TRUE);
    138     AssignTypeAndName(k, xiclass, "Xvfb keyboard");
    139     (void) mieqInit();
    140 }
    141 
    142 void
    143 CloseInput(void)
    144 {
    145     mieqFini();
    146 }