1117N/A/*
1117N/A *
1117N/A * Copyright (c) 1997 Metro Link Incorporated
1117N/A *
1117N/A * Permission is hereby granted, free of charge, to any person obtaining a
1117N/A * copy of this software and associated documentation files (the "Software"),
1117N/A * to deal in the Software without restriction, including without limitation
1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1117N/A * and/or sell copies of the Software, and to permit persons to whom the
1117N/A * Software is furnished to do so, subject to the following conditions:
1117N/A *
1117N/A * The above copyright notice and this permission notice shall be included in
1117N/A * all copies or substantial portions of the Software.
1117N/A *
1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1117N/A * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
1117N/A * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
1117N/A * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1117N/A * SOFTWARE.
1117N/A *
1117N/A * Except as contained in this notice, the name of the Metro Link shall not be
1117N/A * used in advertising or otherwise to promote the sale, use or other dealings
1117N/A * in this Software without prior written authorization from Metro Link.
1117N/A *
1117N/A */
1117N/A/*
1117N/A * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
1117N/A *
1117N/A * Permission is hereby granted, free of charge, to any person obtaining a
1117N/A * copy of this software and associated documentation files (the "Software"),
1117N/A * to deal in the Software without restriction, including without limitation
1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1117N/A * and/or sell copies of the Software, and to permit persons to whom the
1117N/A * Software is furnished to do so, subject to the following conditions:
1117N/A *
1117N/A * The above copyright notice and this permission notice shall be included in
1117N/A * all copies or substantial portions of the Software.
1117N/A *
1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1117N/A * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1117N/A * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1117N/A * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1117N/A * OTHER DEALINGS IN THE SOFTWARE.
1117N/A *
1117N/A * Except as contained in this notice, the name of the copyright holder(s)
1117N/A * and author(s) shall not be used in advertising or otherwise to promote
1117N/A * the sale, use or other dealings in this Software without prior written
1117N/A * authorization from the copyright holder(s) and author(s).
1117N/A */
1117N/A
1117N/A
1117N/A/* View/edit this file with tab stops set to 4 */
1117N/A
1117N/A#ifdef HAVE_XORG_CONFIG_H
1117N/A#include <xorg-config.h>
1117N/A#endif
1117N/A
1117N/A#include "xf86Parser.h"
1117N/A#include "xf86tokens.h"
1117N/A#include "Configint.h"
1117N/A
1117N/Aextern LexRec val;
1117N/A
1117N/Astatic xf86ConfigSymTabRec PointerTab[] =
1117N/A{
1117N/A {PROTOCOL, "protocol"},
1117N/A {EMULATE3, "emulate3buttons"},
1117N/A {EM3TIMEOUT, "emulate3timeout"},
1117N/A {ENDSUBSECTION, "endsubsection"},
1117N/A {ENDSECTION, "endsection"},
1117N/A {PDEVICE, "device"},
1117N/A {PDEVICE, "port"},
1117N/A {BAUDRATE, "baudrate"},
1117N/A {SAMPLERATE, "samplerate"},
1117N/A {CLEARDTR, "cleardtr"},
1117N/A {CLEARRTS, "clearrts"},
1117N/A {CHORDMIDDLE, "chordmiddle"},
1117N/A {PRESOLUTION, "resolution"},
1117N/A {DEVICE_NAME, "devicename"},
1117N/A {ALWAYSCORE, "alwayscore"},
1117N/A {PBUTTONS, "buttons"},
1117N/A {ZAXISMAPPING, "zaxismapping"},
1117N/A {-1, ""},
1117N/A};
1117N/A
1117N/Astatic xf86ConfigSymTabRec ZMapTab[] =
1117N/A{
1117N/A {XAXIS, "x"},
1117N/A {YAXIS, "y"},
1117N/A {-1, ""},
1117N/A};
1117N/A
1117N/A#define CLEANUP xf86freeInputList
1117N/A
1117N/AXF86ConfInputPtr
1117N/Axf86parsePointerSection (void)
1117N/A{
1117N/A char *s, *s1, *s2;
1117N/A int l;
1117N/A int token;
1117N/A parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
1117N/A
1117N/A while ((token = xf86getToken (PointerTab)) != ENDSECTION)
1117N/A {
1117N/A switch (token)
1117N/A {
1117N/A case COMMENT:
1117N/A ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
1117N/A break;
1117N/A case PROTOCOL:
1117N/A if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "Protocol");
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("Protocol"),
1117N/A val.str);
1117N/A break;
1117N/A case PDEVICE:
1117N/A if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "Device");
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("Device"),
1117N/A val.str);
1117N/A break;
1117N/A case EMULATE3:
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("Emulate3Buttons"),
1117N/A NULL);
1117N/A break;
1117N/A case EM3TIMEOUT:
1117N/A if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
1117N/A Error (POSITIVE_INT_MSG, "Emulate3Timeout");
1117N/A s = xf86uLongToString(val.num);
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("Emulate3Timeout"),
1117N/A s);
1117N/A break;
1117N/A case CHORDMIDDLE:
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("ChordMiddle"),
1117N/A NULL);
1117N/A break;
1117N/A case PBUTTONS:
1117N/A if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
1117N/A Error (POSITIVE_INT_MSG, "Buttons");
1117N/A s = xf86uLongToString(val.num);
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("Buttons"), s);
1117N/A break;
1117N/A case BAUDRATE:
1117N/A if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
1117N/A Error (POSITIVE_INT_MSG, "BaudRate");
1117N/A s = xf86uLongToString(val.num);
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("BaudRate"), s);
1117N/A break;
1117N/A case SAMPLERATE:
1117N/A if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
1117N/A Error (POSITIVE_INT_MSG, "SampleRate");
1117N/A s = xf86uLongToString(val.num);
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("SampleRate"), s);
1117N/A break;
1117N/A case PRESOLUTION:
1117N/A if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
1117N/A Error (POSITIVE_INT_MSG, "Resolution");
1117N/A s = xf86uLongToString(val.num);
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("Resolution"), s);
1117N/A break;
1117N/A case CLEARDTR:
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("ClearDTR"), NULL);
1117N/A break;
1117N/A case CLEARRTS:
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("ClearRTS"), NULL);
1117N/A break;
1117N/A case ZAXISMAPPING:
1117N/A switch (xf86getToken(ZMapTab)) {
1117N/A case NUMBER:
1117N/A if (val.num < 0)
1117N/A Error (ZAXISMAPPING_MSG, NULL);
1117N/A s1 = xf86uLongToString(val.num);
1117N/A if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) {
1117N/A xf86conffree(s1);
1117N/A Error (ZAXISMAPPING_MSG, NULL);
1117N/A }
1117N/A s2 = xf86uLongToString(val.num);
1117N/A l = strlen(s1) + 1 + strlen(s2) + 1;
1117N/A s = xf86confmalloc(l);
1117N/A sprintf(s, "%s %s", s1, s2);
1117N/A xf86conffree(s1);
1117N/A xf86conffree(s2);
1117N/A break;
1117N/A case XAXIS:
1117N/A s = xf86configStrdup("x");
1117N/A break;
1117N/A case YAXIS:
1117N/A s = xf86configStrdup("y");
1117N/A break;
1117N/A default:
1117N/A Error (ZAXISMAPPING_MSG, NULL);
1117N/A break;
1117N/A }
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("ZAxisMapping"),
1117N/A s);
1117N/A break;
1117N/A case ALWAYSCORE:
1117N/A break;
1117N/A case EOF_TOKEN:
1117N/A Error (UNEXPECTED_EOF_MSG, NULL);
1117N/A break;
1117N/A default:
1117N/A Error (INVALID_KEYWORD_MSG, xf86tokenString ());
1117N/A break;
1117N/A }
1117N/A }
1117N/A
1117N/A ptr->inp_identifier = xf86configStrdup(CONF_IMPLICIT_POINTER);
1117N/A ptr->inp_driver = xf86configStrdup("mouse");
1117N/A ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
1117N/A xf86configStrdup("CorePointer"), NULL);
1117N/A
1117N/A#ifdef DEBUG
1117N/A printf ("Pointer section parsed\n");
1117N/A#endif
1117N/A
1117N/A return ptr;
1117N/A}
1117N/A
1117N/A#undef CLEANUP
1117N/A