xserver

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

Pointer.c (9017B)


      1 /*
      2  *
      3  * Copyright (c) 1997  Metro Link Incorporated
      4  *
      5  * Permission is hereby granted, free of charge, to any person obtaining a
      6  * copy of this software and associated documentation files (the "Software"),
      7  * to deal in the Software without restriction, including without limitation
      8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      9  * and/or sell copies of the Software, and to permit persons to whom the
     10  * Software is furnished to do so, subject to the following conditions:
     11  *
     12  * The above copyright notice and this permission notice shall be included in
     13  * all copies or substantial portions of the Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     18  * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
     19  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
     20  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     21  * SOFTWARE.
     22  *
     23  * Except as contained in this notice, the name of the Metro Link shall not be
     24  * used in advertising or otherwise to promote the sale, use or other dealings
     25  * in this Software without prior written authorization from Metro Link.
     26  *
     27  */
     28 /*
     29  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
     30  *
     31  * Permission is hereby granted, free of charge, to any person obtaining a
     32  * copy of this software and associated documentation files (the "Software"),
     33  * to deal in the Software without restriction, including without limitation
     34  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     35  * and/or sell copies of the Software, and to permit persons to whom the
     36  * Software is furnished to do so, subject to the following conditions:
     37  *
     38  * The above copyright notice and this permission notice shall be included in
     39  * all copies or substantial portions of the Software.
     40  *
     41  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     42  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     43  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     44  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     45  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     46  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     47  * OTHER DEALINGS IN THE SOFTWARE.
     48  *
     49  * Except as contained in this notice, the name of the copyright holder(s)
     50  * and author(s) shall not be used in advertising or otherwise to promote
     51  * the sale, use or other dealings in this Software without prior written
     52  * authorization from the copyright holder(s) and author(s).
     53  */
     54 
     55 #ifdef HAVE_XORG_CONFIG_H
     56 #include <xorg-config.h>
     57 #endif
     58 
     59 #include "xf86Parser.h"
     60 #include "xf86tokens.h"
     61 #include "Configint.h"
     62 #include "Xprintf.h"
     63 
     64 
     65 static const xf86ConfigSymTabRec PointerTab[] = {
     66     {PROTOCOL, "protocol"},
     67     {EMULATE3, "emulate3buttons"},
     68     {EM3TIMEOUT, "emulate3timeout"},
     69     {ENDSUBSECTION, "endsubsection"},
     70     {ENDSECTION, "endsection"},
     71     {PDEVICE, "device"},
     72     {PDEVICE, "port"},
     73     {BAUDRATE, "baudrate"},
     74     {SAMPLERATE, "samplerate"},
     75     {CLEARDTR, "cleardtr"},
     76     {CLEARRTS, "clearrts"},
     77     {CHORDMIDDLE, "chordmiddle"},
     78     {PRESOLUTION, "resolution"},
     79     {DEVICE_NAME, "devicename"},
     80     {ALWAYSCORE, "alwayscore"},
     81     {PBUTTONS, "buttons"},
     82     {ZAXISMAPPING, "zaxismapping"},
     83     {-1, ""},
     84 };
     85 
     86 static const xf86ConfigSymTabRec ZMapTab[] = {
     87     {XAXIS, "x"},
     88     {YAXIS, "y"},
     89     {-1, ""},
     90 };
     91 
     92 #define CLEANUP xf86freeInputList
     93 
     94 XF86ConfInputPtr
     95 xf86parsePointerSection(void)
     96 {
     97     char *s;
     98     unsigned long val1;
     99     int token;
    100 
    101     parsePrologue(XF86ConfInputPtr, XF86ConfInputRec)
    102 
    103         while ((token = xf86getToken(PointerTab)) != ENDSECTION) {
    104         switch (token) {
    105         case COMMENT:
    106             ptr->inp_comment = xf86addComment(ptr->inp_comment, xf86_lex_val.str);
    107             break;
    108         case PROTOCOL:
    109             if (xf86getSubToken(&(ptr->inp_comment)) != STRING)
    110                 Error(QUOTE_MSG, "Protocol");
    111             ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    112                                                    strdup("Protocol"), xf86_lex_val.str);
    113             break;
    114         case PDEVICE:
    115             if (xf86getSubToken(&(ptr->inp_comment)) != STRING)
    116                 Error(QUOTE_MSG, "Device");
    117             ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    118                                                    strdup("Device"), xf86_lex_val.str);
    119             break;
    120         case EMULATE3:
    121             ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    122                                                    strdup("Emulate3Buttons"),
    123                                                    NULL);
    124             break;
    125         case EM3TIMEOUT:
    126             if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0)
    127                 Error(POSITIVE_INT_MSG, "Emulate3Timeout");
    128             s = xf86uLongToString(xf86_lex_val.num);
    129             ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    130                                                    strdup("Emulate3Timeout"),
    131                                                    s);
    132             break;
    133         case CHORDMIDDLE:
    134             ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    135                                                    strdup("ChordMiddle"), NULL);
    136             break;
    137         case PBUTTONS:
    138             if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0)
    139                 Error(POSITIVE_INT_MSG, "Buttons");
    140             s = xf86uLongToString(xf86_lex_val.num);
    141             ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    142                                                    strdup("Buttons"), s);
    143             break;
    144         case BAUDRATE:
    145             if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0)
    146                 Error(POSITIVE_INT_MSG, "BaudRate");
    147             s = xf86uLongToString(xf86_lex_val.num);
    148             ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    149                                                    strdup("BaudRate"), s);
    150             break;
    151         case SAMPLERATE:
    152             if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0)
    153                 Error(POSITIVE_INT_MSG, "SampleRate");
    154             s = xf86uLongToString(xf86_lex_val.num);
    155             ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    156                                                    strdup("SampleRate"), s);
    157             break;
    158         case PRESOLUTION:
    159             if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0)
    160                 Error(POSITIVE_INT_MSG, "Resolution");
    161             s = xf86uLongToString(xf86_lex_val.num);
    162             ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    163                                                    strdup("Resolution"), s);
    164             break;
    165         case CLEARDTR:
    166             ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    167                                                    strdup("ClearDTR"), NULL);
    168             break;
    169         case CLEARRTS:
    170             ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    171                                                    strdup("ClearRTS"), NULL);
    172             break;
    173         case ZAXISMAPPING:
    174             switch (xf86getToken(ZMapTab)) {
    175             case NUMBER:
    176                 if (xf86_lex_val.num < 0)
    177                     Error(ZAXISMAPPING_MSG);
    178                 val1 = xf86_lex_val.num;
    179                 if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER ||
    180                     xf86_lex_val.num < 0) {
    181                     Error(ZAXISMAPPING_MSG);
    182                 }
    183                 if (asprintf(&s, "%lu %u", val1, xf86_lex_val.num) == -1)
    184                     s = NULL;
    185                 break;
    186             case XAXIS:
    187                 s = strdup("x");
    188                 break;
    189             case YAXIS:
    190                 s = strdup("y");
    191                 break;
    192             default:
    193                 Error(ZAXISMAPPING_MSG);
    194                 break;
    195             }
    196             ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    197                                                    strdup("ZAxisMapping"), s);
    198             break;
    199         case ALWAYSCORE:
    200             break;
    201         case EOF_TOKEN:
    202             Error(UNEXPECTED_EOF_MSG);
    203             break;
    204         default:
    205             Error(INVALID_KEYWORD_MSG, xf86tokenString());
    206             break;
    207         }
    208     }
    209 
    210     ptr->inp_identifier = strdup(CONF_IMPLICIT_POINTER);
    211     ptr->inp_driver = strdup("mouse");
    212     ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
    213                                            strdup("CorePointer"), NULL);
    214 
    215 #ifdef DEBUG
    216     printf("Pointer section parsed\n");
    217 #endif
    218 
    219     return ptr;
    220 }
    221 
    222 #undef CLEANUP