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 65static 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 86static const xf86ConfigSymTabRec ZMapTab[] = { 87 {XAXIS, "x"}, 88 {YAXIS, "y"}, 89 {-1, ""}, 90}; 91 92#define CLEANUP xf86freeInputList 93 94XF86ConfInputPtr 95xf86parsePointerSection(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 free(xf86_lex_val.str); 108 xf86_lex_val.str = NULL; 109 break; 110 case PROTOCOL: 111 if (xf86getSubToken(&(ptr->inp_comment)) != STRING) 112 Error(QUOTE_MSG, "Protocol"); 113 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 114 strdup("Protocol"), xf86_lex_val.str); 115 break; 116 case PDEVICE: 117 if (xf86getSubToken(&(ptr->inp_comment)) != STRING) 118 Error(QUOTE_MSG, "Device"); 119 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 120 strdup("Device"), xf86_lex_val.str); 121 break; 122 case EMULATE3: 123 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 124 strdup("Emulate3Buttons"), 125 NULL); 126 break; 127 case EM3TIMEOUT: 128 if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0) 129 Error(POSITIVE_INT_MSG, "Emulate3Timeout"); 130 s = xf86uLongToString(xf86_lex_val.num); 131 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 132 strdup("Emulate3Timeout"), 133 s); 134 break; 135 case CHORDMIDDLE: 136 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 137 strdup("ChordMiddle"), NULL); 138 break; 139 case PBUTTONS: 140 if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0) 141 Error(POSITIVE_INT_MSG, "Buttons"); 142 s = xf86uLongToString(xf86_lex_val.num); 143 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 144 strdup("Buttons"), s); 145 break; 146 case BAUDRATE: 147 if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0) 148 Error(POSITIVE_INT_MSG, "BaudRate"); 149 s = xf86uLongToString(xf86_lex_val.num); 150 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 151 strdup("BaudRate"), s); 152 break; 153 case SAMPLERATE: 154 if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0) 155 Error(POSITIVE_INT_MSG, "SampleRate"); 156 s = xf86uLongToString(xf86_lex_val.num); 157 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 158 strdup("SampleRate"), s); 159 break; 160 case PRESOLUTION: 161 if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0) 162 Error(POSITIVE_INT_MSG, "Resolution"); 163 s = xf86uLongToString(xf86_lex_val.num); 164 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 165 strdup("Resolution"), s); 166 break; 167 case CLEARDTR: 168 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 169 strdup("ClearDTR"), NULL); 170 break; 171 case CLEARRTS: 172 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 173 strdup("ClearRTS"), NULL); 174 break; 175 case ZAXISMAPPING: 176 switch (xf86getToken(ZMapTab)) { 177 case NUMBER: 178 if (xf86_lex_val.num < 0) 179 Error(ZAXISMAPPING_MSG); 180 val1 = xf86_lex_val.num; 181 if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || 182 xf86_lex_val.num < 0) { 183 Error(ZAXISMAPPING_MSG); 184 } 185 if (asprintf(&s, "%lu %u", val1, xf86_lex_val.num) == -1) 186 s = NULL; 187 break; 188 case XAXIS: 189 s = strdup("x"); 190 break; 191 case YAXIS: 192 s = strdup("y"); 193 break; 194 default: 195 Error(ZAXISMAPPING_MSG); 196 break; 197 } 198 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 199 strdup("ZAxisMapping"), s); 200 break; 201 case ALWAYSCORE: 202 break; 203 case EOF_TOKEN: 204 Error(UNEXPECTED_EOF_MSG); 205 break; 206 default: 207 Error(INVALID_KEYWORD_MSG, xf86tokenString()); 208 break; 209 } 210 } 211 212 ptr->inp_identifier = strdup(CONF_IMPLICIT_POINTER); 213 ptr->inp_driver = strdup("mouse"); 214 ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, 215 strdup("CorePointer"), NULL); 216 217#ifdef DEBUG 218 printf("Pointer section parsed\n"); 219#endif 220 221 return ptr; 222} 223 224#undef CLEANUP 225