Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 276599
Collapse All | Expand All

(-)xf86-input-digitaledge-1.1.1/src/DigitalEdge.c.orig (-391 / +2 lines)
Lines 36-46 Link Here
36
#include "config.h"
36
#include "config.h"
37
#endif
37
#endif
38
38
39
#include "xf86Version.h"
39
//#include "xorgVersion.h"
40
41
#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(3,9,0,0,0)
42
#define XFREE86_V4 1
43
#endif
44
40
45
/* post 3.9 headers */
41
/* post 3.9 headers */
46
42
Lines 150-211 Link Here
150
*/
146
*/
151
#define DEDGE_SECTION_NAME "DigitalEdge"
147
#define DEDGE_SECTION_NAME "DigitalEdge"
152
148
153
#ifndef XFREE86_V4
154
155
#define PORT		1
156
#define DEVICENAME	2
157
#define THE_MODE	3
158
#define CURSOR		4
159
#define INCREMENT	5
160
#define BORDER		6
161
#define DEBUG_LEVEL     7
162
#define HISTORY_SIZE	8
163
#define ALWAYS_CORE	9
164
#define ACTIVE_AREA	10
165
#define ACTIVE_OFFSET	11
166
#define COMPATIBLE	12
167
#define CLICK_THRESHOLD	13
168
169
#if !defined(sun) || defined(i386)
170
static SymTabRec SumTab[] = {
171
    {ENDSUBSECTION, "endsubsection"},
172
    {PORT, "port"},
173
    {DEVICENAME, "devicename"},
174
    {THE_MODE, "mode"},
175
    {CURSOR, "cursor"},
176
    {INCREMENT, "increment"},
177
    {BORDER, "border"},
178
    {DEBUG_LEVEL, "debuglevel"},
179
    {HISTORY_SIZE, "historysize"},
180
    {ALWAYS_CORE, "alwayscore"},
181
    {ACTIVE_AREA, "activearea"},
182
    {ACTIVE_OFFSET, "activeoffset"},
183
    {COMPATIBLE, "compatible"},
184
    {CLICK_THRESHOLD, "clickthreshold"},
185
    {-1, ""}
186
};
187
188
#define RELATIVE	1
189
#define ABSOLUTE	2
190
191
static SymTabRec SumModeTabRec[] = {
192
    {RELATIVE, "relative"},
193
    {ABSOLUTE, "absolute"},
194
    {-1, ""}
195
};
196
197
#define PUCK		1
198
#define STYLUS		2
199
200
static SymTabRec SumPointTabRec[] = {
201
    {PUCK, "puck"},
202
    {STYLUS, "stylus"},
203
    {-1, ""}
204
};
205
206
#endif
207
#endif /* Pre 3.9 headers */
208
209
/*
149
/*
210
** Contants and macro
150
** Contants and macro
211
*/
151
*/
Lines 243-450 Link Here
243
#define COORD_BITS	0x7f
183
#define COORD_BITS	0x7f
244
184
245
/*
185
/*
246
** External declarations
247
*/
248
249
#ifndef XFREE86_V4
250
251
#if defined(sun) && !defined(i386)
252
#define ENQUEUE	suneqEnqueue
253
#else
254
#define ENQUEUE	xf86eqEnqueue
255
256
extern void xf86eqEnqueue(
257
			     xEventPtr	/*e */
258
    );
259
#endif
260
261
extern void miPointerDeltaCursor(
262
				    int /*dx */ ,
263
				    int /*dy */ ,
264
				    unsigned long	/*time */
265
    );
266
267
#if !defined(sun) || defined(i386)
268
/*
269
** xf86SumConfig
270
** Reads the DigitalEdge section from the XF86Config file
271
*/
272
static Bool
273
xf86SumConfig(LocalDevicePtr * array, int inx, int max, LexPtr val)
274
{
275
    LocalDevicePtr dev = array[inx];
276
    DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) (dev->private);
277
    int token;
278
    int mtoken;
279
280
    DBG(1, ErrorF("xf86SumConfig\n"));
281
282
    while ((token = xf86GetToken(SumTab)) != ENDSUBSECTION) {
283
	switch (token) {
284
	case DEVICENAME:
285
	    if (xf86GetToken(NULL) != STRING)
286
		xf86ConfigError("Option string expected");
287
	    else {
288
		dev->name = strdup(val->str);
289
		if (xf86Verbose)
290
		    ErrorF("%s DigitalEdge X device name is %s\n",
291
			   XCONFIG_GIVEN, dev->name);
292
	    }
293
	    break;
294
295
	case PORT:
296
	    if (xf86GetToken(NULL) != STRING)
297
		xf86ConfigError("Option string expected");
298
	    else {
299
		priv->dedgeDevice = strdup(val->str);
300
		if (xf86Verbose)
301
		    ErrorF("%s DigitalEdge port is %s\n", XCONFIG_GIVEN,
302
			   priv->dedgeDevice);
303
	    }
304
	    break;
305
306
	case THE_MODE:
307
	    mtoken = xf86GetToken(SumModeTabRec);
308
	    if ((mtoken == EOF) || (mtoken == STRING)
309
		|| (mtoken ==
310
		    NUMBER)) xf86ConfigError("Mode type token expected");
311
	    else {
312
		switch (mtoken) {
313
		case ABSOLUTE:
314
		    priv->flags |= ABSOLUTE_FLAG;
315
		    break;
316
		case RELATIVE:
317
		    priv->flags &= ~ABSOLUTE_FLAG;
318
		    break;
319
		default:
320
		    xf86ConfigError("Illegal Mode type");
321
		    break;
322
		}
323
	    }
324
	    break;
325
326
	case CURSOR:
327
	    mtoken = xf86GetToken(SumPointTabRec);
328
	    if ((mtoken == EOF) || (mtoken == STRING)
329
		|| (mtoken ==
330
		    NUMBER)) xf86ConfigError("Cursor token expected");
331
	    else {
332
		switch (mtoken) {
333
		case STYLUS:
334
		    priv->flags |= STYLUS_FLAG;
335
		    break;
336
		case PUCK:
337
		    priv->flags &= ~STYLUS_FLAG;
338
		    break;
339
		default:
340
		    xf86ConfigError("Illegal cursor type");
341
		    break;
342
		}
343
	    }
344
	    break;
345
346
	case INCREMENT:
347
	    if (xf86GetToken(NULL) != NUMBER)
348
		xf86ConfigError("Option number expected");
349
	    priv->dedgeInc = val->num;
350
	    if (xf86Verbose)
351
		ErrorF("%s DigitalEdge increment value is %d\n",
352
		       XCONFIG_GIVEN, priv->dedgeInc);
353
	    break;
354
355
	case CLICK_THRESHOLD:
356
	    if (xf86GetToken(NULL) != NUMBER)
357
		xf86ConfigError("Option number expected");
358
	    priv->dedgeClickThresh = val->num;
359
	    if (xf86Verbose)
360
		ErrorF("%s DigitalEdge click threshold is %d\n",
361
		       XCONFIG_GIVEN, priv->dedgeClickThresh);
362
	    break;
363
		
364
	case DEBUG_LEVEL:
365
	    if (xf86GetToken(NULL) != NUMBER)
366
		xf86ConfigError("Option number expected");
367
	    debug_level = val->num;
368
	    if (xf86Verbose) {
369
#if DEBUG
370
		ErrorF("%s DigitalEdge debug level sets to %d\n",
371
		       XCONFIG_GIVEN, debug_level);
372
#else
373
		ErrorF("%s DigitalEdge debug level not sets to %d because"
374
		       " debugging is not compiled\n", XCONFIG_GIVEN,
375
		       debug_level);
376
#endif
377
	    }
378
	    break;
379
380
	case HISTORY_SIZE:
381
	    if (xf86GetToken(NULL) != NUMBER)
382
		xf86ConfigError("Option number expected");
383
	    dev->history_size = val->num;
384
	    if (xf86Verbose)
385
		ErrorF("%s DigitalEdge Motion history size is %d\n",
386
		       XCONFIG_GIVEN, dev->history_size);
387
	    break;
388
	case COMPATIBLE:
389
	    priv->flags |= COMPATIBLE_FLAG;
390
	    if (xf86Verbose)
391
		ErrorF
392
		    ("DigitalEdge compatible - will not query firmware ID\n");
393
	    break;
394
395
	case ALWAYS_CORE:
396
	    xf86AlwaysCore(dev, TRUE);
397
	    if (xf86Verbose)
398
		ErrorF("%s DigitalEdge device always stays core pointer\n",
399
		       XCONFIG_GIVEN);
400
	    break;
401
402
	case ACTIVE_AREA:
403
	    if (xf86GetToken(NULL) != NUMBER)
404
		xf86ConfigError("Option number expected");
405
	    priv->dedgeXSize = val->num;
406
	    if (xf86GetToken(NULL) != NUMBER)
407
		xf86ConfigError("Option number expected");
408
	    priv->dedgeYSize = val->num;
409
		ErrorF("%s DigitalEdge active area set to %d.%1dx%d.%1d"
410
		       " inches\n", XCONFIG_GIVEN, priv->dedgeXSize / 10,
411
		       priv->dedgeXSize % 10, priv->dedgeYSize / 10,
412
		       priv->dedgeYSize % 10);
413
	    break;
414
415
	case ACTIVE_OFFSET:
416
	    if (xf86GetToken(NULL) != NUMBER)
417
		xf86ConfigError("Option number expected");
418
	    priv->dedgeXOffset = val->num;
419
	    if (xf86GetToken(NULL) != NUMBER)
420
		xf86ConfigError("Option number expected");
421
	    priv->dedgeYOffset = val->num;
422
	    if (xf86Verbose)
423
		ErrorF
424
		    ("%s DigitalEdge active area offset set to %d.%1dx%d.%1d"
425
		     " inches\n", XCONFIG_GIVEN, priv->dedgeXOffset / 10,
426
		     priv->dedgeXOffset % 10, priv->dedgeYOffset / 10,
427
		     priv->dedgeYOffset % 10);
428
	    break;
429
430
	case EOF:
431
	    FatalError("Unexpected EOF (missing EndSubSection)");
432
	    break;
433
434
	default:
435
	    xf86ConfigError("DigitalEdge subsection keyword expected");
436
	    break;
437
	}
438
    }
439
440
    DBG(1, ErrorF("xf86SumConfig name=%s\n", priv->dedgeDevice));
441
442
    return Success;
443
}
444
#endif
445
#endif /* pre 3.9 headers */
446
447
/*
448
** xf86SumConvert
186
** xf86SumConvert
449
** Convert valuators to X and Y.
187
** Convert valuators to X and Y.
450
*/
188
*/
Lines 719-796 Link Here
719
*/
457
*/
720
static Bool xf86SumOpen(LocalDevicePtr local)
458
static Bool xf86SumOpen(LocalDevicePtr local)
721
{
459
{
722
#ifndef XFREE86_V4
723
    struct termios termios_tty;
724
    struct timeval timeout;
725
#endif
726
    char buffer[256];
460
    char buffer[256];
727
    int err, idx;
461
    int err, idx;
728
    DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) local->private;
462
    DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) local->private;
729
463
730
    DBG(1, ErrorF("opening %s\n", priv->dedgeDevice));
464
    DBG(1, ErrorF("opening %s\n", priv->dedgeDevice));
731
465
732
#ifdef XFREE86_V4
733
    local->fd = xf86OpenSerial(local->options);
466
    local->fd = xf86OpenSerial(local->options);
734
#else
735
    SYSCALL(local->fd = open(priv->dedgeDevice, O_RDWR | O_NDELAY, 0));
736
#endif
737
    if (local->fd == -1) {
467
    if (local->fd == -1) {
738
	Error(priv->dedgeDevice);
468
	Error(priv->dedgeDevice);
739
	return !Success;
469
	return !Success;
740
    }
470
    }
741
    DBG(2, ErrorF("%s opened as fd %d\n", priv->dedgeDevice, local->fd));
471
    DBG(2, ErrorF("%s opened as fd %d\n", priv->dedgeDevice, local->fd));
742
472
743
#ifndef XFREE86_V4
473
    DBG(1, ErrorF("initializing DigitalEdge tablet\n"));
744
#ifdef POSIX_TTY
745
    err = tcgetattr(local->fd, &termios_tty);
746
    if (err == -1) {
747
	Error("DigitalEdge tcgetattr");
748
	return !Success;
749
    }
750
    termios_tty.c_iflag = IXOFF;
751
    termios_tty.c_cflag =
752
	B9600 | CS8 | CREAD | CLOCAL | HUPCL | PARENB | PARODD;
753
    termios_tty.c_lflag = 0;
754
755
/* I wonder what these all do, anyway */
756
    termios_tty.c_cc[VINTR] = 0;
757
    termios_tty.c_cc[VQUIT] = 0;
758
    termios_tty.c_cc[VERASE] = 0;
759
#ifdef VWERASE
760
    termios_tty.c_cc[VWERASE] = 0;
761
#endif
762
#ifdef VREPRINT
763
    termios_tty.c_cc[VREPRINT] = 0;
764
#endif
765
    termios_tty.c_cc[VKILL] = 0;
766
    termios_tty.c_cc[VEOF] = 0;
767
    termios_tty.c_cc[VEOL] = 0;
768
#ifdef VEOL2
769
    termios_tty.c_cc[VEOL2] = 0;
770
#endif
771
    termios_tty.c_cc[VSUSP] = 0;
772
#ifdef VDISCARD
773
    termios_tty.c_cc[VDISCARD] = 0;
774
#endif
775
#ifdef VLNEXT
776
    termios_tty.c_cc[VLNEXT] = 0;
777
#endif
778
779
    termios_tty.c_cc[VMIN] = 1;
780
    termios_tty.c_cc[VTIME] = 10;
781
782
    err = tcsetattr(local->fd, TCSANOW, &termios_tty);
783
    if (err == -1) {
784
	Error("DigitalEdge tcsetattr TCSANOW");
785
	return !Success;
786
    }
787
#else
788
    Code for someone
789
    else
790
     to write to handle OSs without POSIX tty functions
791
#endif
792
#endif
793
     DBG(1, ErrorF("initializing DigitalEdge tablet\n"));
794
474
795
/* Send reset (NULL) to the tablet */
475
/* Send reset (NULL) to the tablet */
796
    SYSCALL(err = write(local->fd, "", 1));
476
    SYSCALL(err = write(local->fd, "", 1));
Lines 800-812 Link Here
800
    }
480
    }
801
481
802
/* wait 200 mSecs, just in case */
482
/* wait 200 mSecs, just in case */
803
#ifndef XFREE86_V4
804
    timeout.tv_sec = 0;
805
    timeout.tv_usec = 200000;
806
    SYSCALL(err = select(0, NULL, NULL, NULL, &timeout));
807
#else
808
    err = xf86WaitForInput(-1, 200);
483
    err = xf86WaitForInput(-1, 200);
809
#endif
810
    if (err == -1) {
484
    if (err == -1) {
811
	Error("DigitalEdge select");
485
	Error("DigitalEdge select");
812
	return !Success;
486
	return !Success;
Lines 820-830 Link Here
820
	return !Success;
494
	return !Success;
821
    }
495
    }
822
/* Clear any pending input */
496
/* Clear any pending input */
823
#ifndef XFREE86_V4
824
    tcflush(local->fd, TCIFLUSH);
825
#else
826
    xf86FlushInput(local->fd);
497
    xf86FlushInput(local->fd);
827
#endif
828
498
829
    if (priv->dedgeXOffset > 0 && priv->dedgeYOffset > 0) {
499
    if (priv->dedgeXOffset > 0 && priv->dedgeYOffset > 0) {
830
	if (priv->dedgeXSize * 50 < priv->dedgeMaxX - priv->dedgeXOffset &&
500
	if (priv->dedgeXSize * 50 < priv->dedgeMaxX - priv->dedgeXOffset &&
Lines 972-978 Link Here
972
642
973
	if (InitValuatorClassDeviceStruct(pSum,
643
	if (InitValuatorClassDeviceStruct(pSum,
974
					  nbaxes,
644
					  nbaxes,
975
					  xf86GetMotionEvents,
976
					  local->history_size,
645
					  local->history_size,
977
					  (priv->flags & ABSOLUTE_FLAG) ?
646
					  (priv->flags & ABSOLUTE_FLAG) ?
978
					  Absolute : Relative) == FALSE) {
647
					  Absolute : Relative) == FALSE) {
Lines 981-989 Link Here
981
	}
650
	}
982
/* allocate the motion history buffer if needed */
651
/* allocate the motion history buffer if needed */
983
	xf86MotionHistoryAllocate(local);
652
	xf86MotionHistoryAllocate(local);
984
#ifndef XFREE86_V4
985
	    AssignTypeAndName(pSum, local->atom, local->name);
986
#endif
987
653
988
/* open the device to gather informations */
654
/* open the device to gather informations */
989
	xf86SumOpenDevice(pSum);
655
	xf86SumOpenDevice(pSum);
Lines 996-1006 Link Here
996
	    return !Success;
662
	    return !Success;
997
	}
663
	}
998
	SYSCALL(write(local->fd, SS_PROMPT, strlen(SS_PROMPT)));
664
	SYSCALL(write(local->fd, SS_PROMPT, strlen(SS_PROMPT)));
999
#ifdef XFREE86_V4
1000
	    xf86AddEnabledDevice(local);
665
	    xf86AddEnabledDevice(local);
1001
#else
1002
	    AddEnabledDevice(local->fd);
1003
#endif
1004
	pSum->public.on = TRUE;
666
	pSum->public.on = TRUE;
1005
	break;
667
	break;
1006
668
Lines 1008-1018 Link Here
1008
	DBG(1, ErrorF("xf86SumProc  pSum=%p what=%s\n", (void *)pSum,
670
	DBG(1, ErrorF("xf86SumProc  pSum=%p what=%s\n", (void *)pSum,
1009
		      (what == DEVICE_CLOSE) ? "CLOSE" : "OFF"));
671
		      (what == DEVICE_CLOSE) ? "CLOSE" : "OFF"));
1010
	if (local->fd >= 0)
672
	if (local->fd >= 0)
1011
#ifdef XFREE86_V4
1012
		    xf86RemoveEnabledDevice(local);
673
		    xf86RemoveEnabledDevice(local);
1013
#else
1014
	            RemoveEnabledDevice(local->fd);
1015
#endif
1016
	pSum->public.on = FALSE;
674
	pSum->public.on = FALSE;
1017
	break;
675
	break;
1018
676
Lines 1100-1110 Link Here
1100
*/
758
*/
1101
static LocalDevicePtr xf86SumAllocate(void)
759
static LocalDevicePtr xf86SumAllocate(void)
1102
{
760
{
1103
#ifdef XFREE86_V4
1104
    LocalDevicePtr	local = xf86AllocateInput(dedgeDrv, 0);
761
    LocalDevicePtr	local = xf86AllocateInput(dedgeDrv, 0);
1105
#else
1106
    LocalDevicePtr local = (LocalDevicePtr) xalloc(sizeof(LocalDeviceRec));
1107
#endif
1108
    DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) xalloc(sizeof(DigitalEdgeDeviceRec));
762
    DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) xalloc(sizeof(DigitalEdgeDeviceRec));
1109
#if defined (sun) && !defined(i386)
763
#if defined (sun) && !defined(i386)
1110
    char *dev_name = getenv("DEDGESKETCH_DEV");
764
    char *dev_name = getenv("DEDGESKETCH_DEV");
Lines 1113-1123 Link Here
1113
    local->name = XI_NAME;
767
    local->name = XI_NAME;
1114
    local->type_name = "DigitalEdge Tablet";
768
    local->type_name = "DigitalEdge Tablet";
1115
    local->flags = 0;		/*XI86_NO_OPEN_ON_INIT; */
769
    local->flags = 0;		/*XI86_NO_OPEN_ON_INIT; */
1116
#ifndef XFREE86_V4
1117
#if !defined(sun) || defined(i386)
1118
    local->device_config = xf86SumConfig;
1119
#endif
1120
#endif
1121
    local->device_control = xf86SumProc;
770
    local->device_control = xf86SumProc;
1122
    local->read_input = xf86SumReadInput;
771
    local->read_input = xf86SumReadInput;
1123
    local->control_proc = xf86SumChangeControl;
772
    local->control_proc = xf86SumChangeControl;
Lines 1161-1203 Link Here
1161
    return local;
810
    return local;
1162
}
811
}
1163
812
1164
#ifndef XFREE86_V4
1165
1166
/*
1167
** DigitalEdge device association
1168
** Device section name and allocation function.
1169
*/
1170
DeviceAssocRec dedgemasketch_assoc = {
1171
    DEDGE_SECTION_NAME,		/* config_section_name */
1172
    xf86SumAllocate		/* device_allocate */
1173
};
1174
1175
#ifdef DYNAMIC_MODULE
1176
/*
1177
** init_module
1178
** Entry point for dynamic module.
1179
*/
1180
int
1181
#ifndef DLSYM_BUG
1182
init_module(unsigned long server_version)
1183
#else
1184
init_xf86DigitalEdge(unsigned long server_version)
1185
#endif
1186
{
1187
    xf86AddDeviceAssoc(&dedgemasketch_assoc);
1188
1189
    if (server_version != XF86_VERSION_CURRENT) {
1190
	ErrorF("Warning: DigitalEdgeKetch module compiled for version%s\n",
1191
	       XF86_VERSION);
1192
	return 0;
1193
    } else {
1194
	return 1;
1195
    }
1196
}
1197
#endif
1198
1199
#else
1200
1201
/*
813
/*
1202
 * xf86SumUninit --
814
 * xf86SumUninit --
1203
 *
815
 *
Lines 1422-1427 Link Here
1422
};
1034
};
1423
1035
1424
#endif /* XFree86LOADER */
1036
#endif /* XFree86LOADER */
1425
#endif /* XFREE86_V4 */
1426
1037
1427
/* end of xf86DigitalEdge.c */
1038
/* end of xf86DigitalEdge.c */

Return to bug 276599