Merge lp:~gerard-/wizardpen/unstuck into lp:wizardpen

Proposed by Gerard Krol
Status: Merged
Merged at revision: not available
Proposed branch: lp:~gerard-/wizardpen/unstuck
Merge into: lp:wizardpen
Diff against target: 1218 lines (+457/-463)
2 files modified
src/wizardpen.c (+402/-408)
src/wizardpen.h (+55/-55)
To merge this branch: bzr merge lp:~gerard-/wizardpen/unstuck
Reviewer Review Type Date Requested Status
Martin Owens Approve
Review via email: mp+21781@code.launchpad.net

Description of the change

Includes compatibility for the new API (xorg-x11-1.7.x-api-changes.patch by panemade), formatting changes and it now always sends button events, so the pen will not get stuck pressed down sometimes after you draw a line.

Works fine for me with a Trust TB6300 (UC-LOGIC Tablet WP8060U), debian testing, AMD64

To post a comment you must log in.
Revision history for this message
Martin Owens (doctormo) wrote :

Merged

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/wizardpen.c'
--- src/wizardpen.c 2009-07-17 19:56:32 +0000
+++ src/wizardpen.c 2010-03-20 19:15:26 +0000
@@ -29,7 +29,7 @@
2929
30#define _WIZARDPEN_C_30#define _WIZARDPEN_C_
31/*****************************************************************************31/*****************************************************************************
32 * Standard Headers32 * Standard Headers
33 ****************************************************************************/33 ****************************************************************************/
3434
35#ifdef LINUX_INPUT35#ifdef LINUX_INPUT
@@ -71,16 +71,16 @@
71#endif71#endif
7272
73/*****************************************************************************73/*****************************************************************************
74 * Local Headers74 * Local Headers
75 ****************************************************************************/75 ****************************************************************************/
76#include "wizardpen.h"76#include "wizardpen.h"
7777
78/*****************************************************************************78/*****************************************************************************
79 * Variables without includable headers79 * Variables without includable headers
80 ****************************************************************************/80 ****************************************************************************/
8181
82/*****************************************************************************82/*****************************************************************************
83 * Local Variables83 * Local Variables
84 ****************************************************************************/84 ****************************************************************************/
8585
86float rz;86float rz;
@@ -103,79 +103,79 @@
103103
104_X_EXPORT InputDriverRec WIZARDPEN =104_X_EXPORT InputDriverRec WIZARDPEN =
105{105{
106 6,106 6,
107 "wizardpen",107 "wizardpen",
108 NULL,108 NULL,
109 WizardPenPreInit,109 WizardPenPreInit,
110 NULL,110 NULL,
111 NULL,111 NULL,
112 0112 0
113};113};
114114
115#ifdef XFree86LOADER115#ifdef XFree86LOADER
116static XF86ModuleVersionInfo VersionRec =116static XF86ModuleVersionInfo VersionRec =
117{117{
118 "wizardpen",118 "wizardpen",
119 MODULEVENDORSTRING,119 MODULEVENDORSTRING,
120 MODINFOSTRING1,120 MODINFOSTRING1,
121 MODINFOSTRING2,121 MODINFOSTRING2,
122 XORG_VERSION_CURRENT,122 XORG_VERSION_CURRENT,
123 PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL,123 PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL,
124 ABI_CLASS_XINPUT,124 ABI_CLASS_XINPUT,
125 ABI_XINPUT_VERSION,125 ABI_XINPUT_VERSION,
126 MOD_CLASS_XINPUT,126 MOD_CLASS_XINPUT,
127 {0, 0, 0, 0}127 {0, 0, 0, 0}
128};128};
129129
130130
131_X_EXPORT XF86ModuleData wizardpenModuleData = {131_X_EXPORT XF86ModuleData wizardpenModuleData = {
132 &VersionRec,132 &VersionRec,
133 SetupProc,133 SetupProc,
134 TearDownProc134 TearDownProc
135};135};
136136
137/*****************************************************************************137/*****************************************************************************
138 * Function Definitions138 * Function Definitions
139 ****************************************************************************/139 ****************************************************************************/
140140
141static pointer141static pointer
142SetupProc( pointer module,142SetupProc( pointer module,
143 pointer options,143 pointer options,
144 int *errmaj,144 int *errmaj,
145 int *errmin )145 int *errmin )
146{146{
147 xf86AddInputDriver(&WIZARDPEN, module, 0);147 xf86AddInputDriver(&WIZARDPEN, module, 0);
148 return module;148 return module;
149}149}
150150
151static void151static void
152TearDownProc( pointer p )152TearDownProc( pointer p )
153{153{
154#if 0154#if 0
155 LocalDevicePtr local = (LocalDevicePtr) p;155 LocalDevicePtr local = (LocalDevicePtr) p;
156 AceCadPrivatePtr priv = (AceCadPrivatePtr) local->private;156 AceCadPrivatePtr priv = (AceCadPrivatePtr) local->private;
157157
158 DeviceOff (local->dev);158 DeviceOff (local->dev);
159159
160 xf86CloseSerial (local->fd);160 xf86CloseSerial (local->fd);
161 XisbFree (priv->buffer);161 XisbFree (priv->buffer);
162 xfree (priv);162 xfree (priv);
163 xfree (local->name);163 xfree (local->name);
164 xfree (local);164 xfree (local);
165#endif165#endif
166}166}
167#endif167#endif
168168
169static const char *default_options[] =169static const char *default_options[] =
170{170{
171 "BaudRate", "9600",171 "BaudRate", "9600",
172 "StopBits", "1",172 "StopBits", "1",
173 "DataBits", "8",173 "DataBits", "8",
174 "Parity", "Odd",174 "Parity", "Odd",
175 "Vmin", "1",175 "Vmin", "1",
176 "Vtime", "10",176 "Vtime", "10",
177 "FlowControl", "Xoff",177 "FlowControl", "Xoff",
178 NULL178 NULL
179};179};
180180
181#ifdef LINUX_INPUT181#ifdef LINUX_INPUT
@@ -212,7 +212,7 @@
212 cmp_at = 256;212 cmp_at = 256;
213 ioctl(fd, EVIOCGNAME(sizeof(name)), name);213 ioctl(fd, EVIOCGNAME(sizeof(name)), name);
214 name[cmp_at] = '\0';214 name[cmp_at] = '\0';
215 if (xf86NameCmp(name, wizardpen_name) == 0)215 if (xf86NameCmp(name, wizardpen_name) == 0)
216 return TRUE;216 return TRUE;
217 return FALSE;217 return FALSE;
218}218}
@@ -253,7 +253,7 @@
253 xf86MsgVerb(X_INFO, verb, "%s: probing event devices for WizardPen tablets\n", local->name);253 xf86MsgVerb(X_INFO, verb, "%s: probing event devices for WizardPen tablets\n", local->name);
254 for (i = 0; ; i++) {254 for (i = 0; ; i++) {
255 int fd = -1;255 int fd = -1;
256 Bool is_wizardpen;256 Bool is_wizardpen;
257257
258 np = SET_EVENT_NUM(fname, i);258 np = SET_EVENT_NUM(fname, i);
259 if (np < 0 || np >= EV_DEV_NAME_MAXLEN) {259 if (np < 0 || np >= EV_DEV_NAME_MAXLEN) {
@@ -334,98 +334,98 @@
334 /* deprecated box settings, Z axis */334 /* deprecated box settings, Z axis */
335 s = xf86FindOptionValue(local->options, "ClickPressureLevel");335 s = xf86FindOptionValue(local->options, "ClickPressureLevel");
336 if (s && strlen(s) > 0) {336 if (s && strlen(s) > 0) {
337 xf86Msg(X_WARNING, "%s: Option \"ClickPressureLevel\" "337 xf86Msg(X_WARNING, "%s: Option \"ClickPressureLevel\" "
338 "is DEPRECATED, please use \"TopZ\"\n", local->name);338 "is DEPRECATED, please use \"TopZ\"\n", local->name);
339 priv->topZ = atoi(s);339 priv->topZ = atoi(s);
340 xf86Msg(X_CONFIG, "%s: TopZ = %d\n", local->name, priv->topZ);340 xf86Msg(X_CONFIG, "%s: TopZ = %d\n", local->name, priv->topZ);
341 }341 }
342 /* end of deprecated box settings, Z axis */342 /* end of deprecated box settings, Z axis */
343343
344 /* box settings */344 /* box settings */
345 s = xf86FindOptionValue(local->options, "TopX");345 s = xf86FindOptionValue(local->options, "TopX");
346 if (s && strlen(s) > 0) {346 if (s && strlen(s) > 0) {
347 priv->topX = atoi(s);347 priv->topX = atoi(s);
348 xf86Msg(X_CONFIG, "%s: TopX = %d\n", local->name, priv->topX);348 xf86Msg(X_CONFIG, "%s: TopX = %d\n", local->name, priv->topX);
349 }349 }
350350
351 s = xf86FindOptionValue(local->options, "TopY");351 s = xf86FindOptionValue(local->options, "TopY");
352 if (s && strlen(s) > 0) {352 if (s && strlen(s) > 0) {
353 priv->topY = atoi(s);353 priv->topY = atoi(s);
354 xf86Msg(X_CONFIG, "%s: TopY = %d\n", local->name, priv->topY);354 xf86Msg(X_CONFIG, "%s: TopY = %d\n", local->name, priv->topY);
355 }355 }
356356
357 s = xf86FindOptionValue(local->options, "TopZ");357 s = xf86FindOptionValue(local->options, "TopZ");
358 if (s && strlen(s) > 0) {358 if (s && strlen(s) > 0) {
359 priv->topZ = atoi(s);359 priv->topZ = atoi(s);
360 xf86Msg(X_CONFIG, "%s: TopZ = %d\n", local->name, priv->topZ);360 xf86Msg(X_CONFIG, "%s: TopZ = %d\n", local->name, priv->topZ);
361 }361 }
362362
363 s = xf86FindOptionValue(local->options, "BottomX");363 s = xf86FindOptionValue(local->options, "BottomX");
364 if (s && strlen(s) > 0) {364 if (s && strlen(s) > 0) {
365 priv->bottomX = atoi(s);365 priv->bottomX = atoi(s);
366 xf86Msg(X_CONFIG, "%s: BottomX = %d\n", local->name, priv->bottomX);366 xf86Msg(X_CONFIG, "%s: BottomX = %d\n", local->name, priv->bottomX);
367 }367 }
368368
369 s = xf86FindOptionValue(local->options, "BottomY");369 s = xf86FindOptionValue(local->options, "BottomY");
370 if (s && strlen(s) > 0) {370 if (s && strlen(s) > 0) {
371 priv->bottomY = atoi(s);371 priv->bottomY = atoi(s);
372 xf86Msg(X_CONFIG, "%s: BottomY = %d\n", local->name, priv->bottomY);372 xf86Msg(X_CONFIG, "%s: BottomY = %d\n", local->name, priv->bottomY);
373 }373 }
374374
375 s = xf86FindOptionValue(local->options, "BottomZ");375 s = xf86FindOptionValue(local->options, "BottomZ");
376 if (s && strlen(s) > 0) {376 if (s && strlen(s) > 0) {
377 priv->bottomZ = atoi(s);377 priv->bottomZ = atoi(s);
378 xf86Msg(X_CONFIG, "%s: BottomZ = %d\n", local->name, priv->bottomZ);378 xf86Msg(X_CONFIG, "%s: BottomZ = %d\n", local->name, priv->bottomZ);
379 }379 }
380380
381 s = xf86FindOptionValue(local->options, "ScreenX");381 s = xf86FindOptionValue(local->options, "ScreenX");
382 if (s && strlen(s) > 0) {382 if (s && strlen(s) > 0) {
383 screenmaxx = atoi(s);383 screenmaxx = atoi(s);
384 xf86Msg(X_CONFIG, "%s: ScreenX = %d\n", local->name, screenmaxx);384 xf86Msg(X_CONFIG, "%s: ScreenX = %d\n", local->name, screenmaxx);
385 }else385 }else
386 screenmaxx = screenInfo.screens[0]->width;386 screenmaxx = screenInfo.screens[0]->width;
387 387
388 s = xf86FindOptionValue(local->options, "ScreenY");388 s = xf86FindOptionValue(local->options, "ScreenY");
389 if (s && strlen(s) > 0) {389 if (s && strlen(s) > 0) {
390 screenmaxy = atoi(s);390 screenmaxy = atoi(s);
391 xf86Msg(X_CONFIG, "%s: ScreenY = %d\n", local->name, screenmaxy);391 xf86Msg(X_CONFIG, "%s: ScreenY = %d\n", local->name, screenmaxy);
392 }else392 }else
393 screenmaxy = screenInfo.screens[0]->height;393 screenmaxy = screenInfo.screens[0]->height;
394394
395 s = xf86FindOptionValue(local->options, "debugyn");395 s = xf86FindOptionValue(local->options, "debugyn");
396 if (s && strlen(s) > 0) {396 if (s && strlen(s) > 0) {
397 debugyn = atoi(s);397 debugyn = atoi(s);
398 xf86Msg(X_CONFIG, "%s: debugyn = %d\n", local->name, debugyn);398 xf86Msg(X_CONFIG, "%s: debugyn = %d\n", local->name, debugyn);
399 }399 }
400400
401 s = xf86FindOptionValue(local->options, "MouseSpeed");401 s = xf86FindOptionValue(local->options, "MouseSpeed");
402 if (s && strlen(s) > 0) {402 if (s && strlen(s) > 0) {
403 mousespeed = atoi(s);403 mousespeed = atoi(s);
404 xf86Msg(X_CONFIG, "%s: MouseSpeed = %d\n", local->name, mousespeed);404 xf86Msg(X_CONFIG, "%s: MouseSpeed = %d\n", local->name, mousespeed);
405 }405 }
406 406
407 s = xf86FindOptionValue(local->options, "MouseAccel");407 s = xf86FindOptionValue(local->options, "MouseAccel");
408 if (s && strlen(s) > 0) {408 if (s && strlen(s) > 0) {
409 mouseaccel = atoi(s);409 mouseaccel = atoi(s);
410 xf86Msg(X_CONFIG, "%s: MouseAccel = %d\n", local->name, mouseaccel);410 xf86Msg(X_CONFIG, "%s: MouseAccel = %d\n", local->name, mouseaccel);
411 }411 }
412412
413 s = xf86FindOptionValue(local->options, "Rotate90");413 s = xf86FindOptionValue(local->options, "Rotate90");
414 if (s && strlen(s) > 0) {414 if (s && strlen(s) > 0) {
415 int rotate;415 int rotate;
416 rotate90 = atoi(s);416 rotate90 = atoi(s);
417 xf86Msg(X_CONFIG, "%s: Rotate90 = %d\n", local->name, rotate90);417 xf86Msg(X_CONFIG, "%s: Rotate90 = %d\n", local->name, rotate90);
418 if(rotate90){418 if(rotate90){
419 int temp;419 int temp;
420 temp = priv->bottomY;420 temp = priv->bottomY;
421 priv->bottomY = priv->bottomX;421 priv->bottomY = priv->bottomX;
422 priv->bottomX = temp;422 priv->bottomX = temp;
423 temp = priv->topY;423 temp = priv->topY;
424 priv->topY = priv->topX;424 priv->topY = priv->topX;
425 priv->topX = temp;425 priv->topX = temp;
426 }426 }
427 }427 }
428 428
429 /* end of box settings */429 /* end of box settings */
430430
431 // increment setting431 // increment setting
@@ -631,14 +631,25 @@
631 LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate;631 LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate;
632 WizardPenPrivatePtr priv = (WizardPenPrivatePtr) (local->private);632 WizardPenPrivatePtr priv = (WizardPenPrivatePtr) (local->private);
633 priv->wizardpenOldX = 0;633 priv->wizardpenOldX = 0;
634 priv->wizardpenOldY = 0;634 priv->wizardpenOldY = 0;
635 priv->wizardpenOldZ = 0;635 priv->wizardpenOldZ = 0;
636 unsigned char map[] =636 unsigned char map[] =
637 {0, 1, 2, 3, 4, 5};637 {0, 1, 2, 3, 4, 5};
638 xf86MsgVerb(X_INFO, 4, "%s Init\n", local->name);638 xf86MsgVerb(X_INFO, 4, "%s Init\n", local->name);
639639
640#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
641 Atom label=0;
642 Atom atoms[MAX_VALUATORS] = { 0 };
643#endif
644
640 /* 3 buttons changed to SIX */645 /* 3 buttons changed to SIX */
641 if (InitButtonClassDeviceStruct (dev, 6, map) == FALSE)646 if (InitButtonClassDeviceStruct(
647 dev,
648 6,
649#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
650 atoms,
651#endif
652 map) == FALSE)
642 {653 {
643 xf86Msg(X_ERROR, "%s: unable to allocate ButtonClassDeviceStruct\n", local->name);654 xf86Msg(X_ERROR, "%s: unable to allocate ButtonClassDeviceStruct\n", local->name);
644 return !Success;655 return !Success;
@@ -657,52 +668,58 @@
657668
658669
659 /* 3 axes */670 /* 3 axes */
660 if (InitValuatorClassDeviceStruct (dev, 3,671 if (InitValuatorClassDeviceStruct(dev, 3,
672#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
673 atoms,
674#endif
661#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3675#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3
662 xf86GetMotionEvents,676 xf86GetMotionEvents,
663#endif677#endif
664 local->history_size,678 local->history_size,
665 ((priv->flags & ABSOLUTE_FLAG)? Absolute: Relative)|OutOfProximity)679 ((priv->flags & ABSOLUTE_FLAG)? Absolute: Relative)|OutOfProximity) == FALSE)
666 == FALSE)
667 {680 {
668 xf86Msg(X_ERROR, "%s: unable to allocate ValuatorClassDeviceStruct\n", local->name);681 xf86Msg(X_ERROR, "%s: unable to allocate ValuatorClassDeviceStruct\n", local->name);
669 return !Success;682 return !Success;
670 }683 }
671 else684 else
672 {685 {
673
674 InitValuatorAxisStruct(dev,686 InitValuatorAxisStruct(dev,
675 0,687 0,
676 0, /* min val */688#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
677 /*screenInfo.screens[0]->width,*/ /* max val */689 label,
678 screenmaxx, /* max val */690#endif
679 1000, /* resolution */691 0, /* min val */
680 0, /* min_res */692 screenmaxx, /* max val */
681 1000); /* max_res */693 1000, /* resolution */
694 0, /* min_res */
695 1000); /* max_res */
682 InitValuatorAxisStruct(dev,696 InitValuatorAxisStruct(dev,
683 1,697 1,
684 0, /* min val */698#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
685 /*screenInfo.screens[0]->height,*/ /* max val */699 label,
686 screenmaxy, /* max val */700#endif
687 1000, /* resolution */701 0, /* min val */
688 0, /* min_res */702 screenmaxy, /* max val */
689 1000); /* max_res */703 1000, /* resolution */
704 0, /* min_res */
705 1000); /* max_res */
690 InitValuatorAxisStruct(dev,706 InitValuatorAxisStruct(dev,
691 2,707 2,
692 0, /* min val */708#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
693 /*priv->bottomZ,*/ /* max val */709 label,
694 1023,710#endif
695 1000, /* resolution */711 0, /* min val */
696 0, /* min_res */712 1023, /* max val */
697 1000); /* max_res */713 1000, /* resolution */
698 714 0, /* min_res */
699 if(rotate90){715 1000); /* max_res */
700 int tempval;
701 tempval = screenmaxx;
702 screenmaxx = screenmaxy;
703 screenmaxy = tempval;
704 }
705716
717 if (rotate90) {
718 int tempval;
719 tempval = screenmaxx;
720 screenmaxx = screenmaxy;
721 screenmaxy = tempval;
722 }
706 }723 }
707724
708 if (InitProximityClassDeviceStruct (dev) == FALSE)725 if (InitProximityClassDeviceStruct (dev) == FALSE)
@@ -738,7 +755,7 @@
738}755}
739756
740#ifdef LINUX_INPUT757#ifdef LINUX_INPUT
741#define set_bit(byte,nb,bit) (bit ? byte | (1<<nb) : byte & (~(1<<nb)))758#define set_bit(byte,nb,bit) (bit ? byte | (1<<nb) : byte & (~(1<<nb)))
742static void759static void
743USBReadInput (LocalDevicePtr local)760USBReadInput (LocalDevicePtr local)
744{761{
@@ -778,312 +795,289 @@
778 return;795 return;
779 } else {796 } else {
780 if (!avail) {797 if (!avail) {
781 // If the device wasn't available last time we checked 798 // If the device wasn't available last time we checked
782 xf86Msg(X_INFO, "%s: device %s is available again\n", local->name, xf86FindOptionValue(local->options, "Device"));799 xf86Msg(X_INFO, "%s: device %s is available again\n", local->name, xf86FindOptionValue(local->options, "Device"));
783 priv->flags |= AVAIL_FLAG;800 priv->flags |= AVAIL_FLAG;
784 }801 }
785 }802 }
786803
787 for (event = (struct input_event *)eventbuf;804 for (event = (struct input_event *)eventbuf;
788 event < (struct input_event *)(eventbuf+len); event++) 805 event < (struct input_event *)(eventbuf+len);
789 {806 event++)
790 switch (event->type) {807 {
791 case EV_SYN:// 2.6.x 808 switch (event->type) {
809 case EV_SYN:// 2.6.x
792 if (event->code != SYN_REPORT && event->code != 0)810 if (event->code != SYN_REPORT && event->code != 0)
793 xf86Msg(X_ERROR, "%s: unknown EV_SYN code %d\n", local->name, event->code);811 xf86Msg(X_ERROR, "%s: unknown EV_SYN code %d\n", local->name, event->code);
794 break;812 break;
795 case EV_REL:813 case EV_REL:
796 if(debugyn)814 if(debugyn)
797 xf86Msg(X_ERROR, "EV_REL! %s: event type/code/value %d/%d/%d\n", local->name, event->type, event->code, event->value);815 xf86Msg(X_ERROR, "EV_REL! %s: event type/code/value %d/%d/%d\n", local->name, event->type, event->code, event->value);
798 int xaccel, yaccel;816 int xaccel, yaccel;
799 817 switch (event->code) {
800 switch(event->code){818 case REL_X:
801 case REL_X:819 xaccel = 1;
802 xaccel = 1;820 if(mouseaccel) {
803 if(mouseaccel){821 if(abs(event->value) > 2) {
804 if(abs(event->value) > 2){822 xaccel = 2;
805 xaccel = 2;823 } else if(abs(event->value) > 4) {
806 }else if(abs(event->value) > 4){824 xaccel = 3;
807 xaccel = 3;825 } else if(abs(event->value) > 6) {
808 }else if(abs(event->value) > 6){826 xaccel = 4;
809 xaccel = 4;827 }
810 }828 }
811 }829 x = x + (xaccel * mousespeed * event->value);
812 x = x + (xaccel * mousespeed * event->value);830 if (x < priv->topX) {
813 if(x < priv->topX){831 x = 1 + priv->topX;
814 x = 1 + priv->topX;832 }
815 }833 if (x > priv->bottomX) {
816 if( x > priv->bottomX){834 x = priv->bottomX;
817 x = priv->bottomX;835 }
818 }836 break;
819 break;837 case REL_Y:
820 case REL_Y:838 yaccel = 1;
821 yaccel = 1;839 if(mouseaccel){
822 if(mouseaccel){840 if (abs(event->value) > 2) {
823 if(abs(event->value) > 2){841 yaccel = 2;
824 yaccel = 2;842 } else if(abs(event->value) > 4) {
825 }else if(abs(event->value) > 4){843 yaccel = 3;
826 yaccel = 3;844 } else if(abs(event->value) > 6) {
827 }else if(abs(event->value) > 6){845 yaccel = 4;
828 yaccel = 4;846 }
829 }847 }
830 }848 y = y + (yaccel * mousespeed * event->value);
831 y = y + (yaccel * mousespeed * event->value);849 if (y < priv->topY) {
832 if(y < priv->topY){850 y = 1 + priv->topY;
833 y = 1 + priv->topY;851 }
834 }852 if (y > priv->bottomY) {
835 if( y > priv->bottomY){853 y = priv->bottomY;
836 y = priv->bottomY;854 }
837 }855 break;
838 break;856 case REL_WHEEL:
839 case REL_WHEEL:857 if (event->value < 0) {
840 if (event->value < 0){858 buttons = set_bit(buttons,4,1);
841 buttons = set_bit(buttons,4,1);859 delta = buttons ^ priv->wizardpenOldButtons;
842 delta = buttons ^ priv->wizardpenOldButtons;860 while (delta) {
843 while (delta) {861 id = ffs(delta);
844 id = ffs(delta);862 delta &= ~(1 << (id-1));
845 delta &= ~(1 << (id-1));863 if(rotate90)
846 if(rotate90) 864 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_y, screenmaxx - report_x,report_z);
847 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_y, screenmaxx - report_x,report_z); 865 else
848 else866 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_x, report_y,report_z);
849 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_x, report_y,report_z); 867 }
850 }868 priv->wizardpenOldButtons = buttons;
851 priv->wizardpenOldButtons = buttons;869 buttons = set_bit(buttons,4,0);
852 buttons = set_bit(buttons,4,0);870 delta = buttons ^ priv->wizardpenOldButtons;
853 delta = buttons ^ priv->wizardpenOldButtons;871 while (delta)
854 while (delta)872 {
855 {873 id = ffs(delta);
856 id = ffs(delta);874 delta &= ~(1 << (id-1));
857 delta &= ~(1 << (id-1));875 if(rotate90)
858 if(rotate90) 876 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_y, screenmaxx - report_x,report_z);
859 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_y, screenmaxx - report_x,report_z); 877 else
860 else878 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_x, report_y,report_z);
861 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_x, report_y,report_z); 879 }
862 }880 }
863 }881 if (event->value > 0) {
864 if (event->value > 0){882 buttons = set_bit(buttons,3,1);
865 buttons = set_bit(buttons,3,1);883 delta = buttons ^ priv->wizardpenOldButtons;
866 delta = buttons ^ priv->wizardpenOldButtons;884 while (delta) {
867 while (delta) {885 id = ffs(delta);
868 id = ffs(delta);886 delta &= ~(1 << (id-1));
869 delta &= ~(1 << (id-1));887 if(rotate90)
870 if(rotate90)888 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_y, screenmaxx - report_x,report_z);
871 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_y, screenmaxx - report_x,report_z); 889 else
872 else890 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_x, report_y,report_z);
873 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_x, report_y,report_z); 891 }
874 }892 priv->wizardpenOldButtons = buttons;
875 priv->wizardpenOldButtons = buttons;893 buttons = set_bit(buttons,3,0);
876 buttons = set_bit(buttons,3,0);894 delta = buttons ^ priv->wizardpenOldButtons;
877 delta = buttons ^ priv->wizardpenOldButtons;895 while (delta)
878 while (delta)896 {
879 {897 id = ffs(delta);
880 id = ffs(delta);898 delta &= ~(1 << (id-1));
881 delta &= ~(1 << (id-1));899 if(rotate90)
882 if(rotate90)900 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_y, screenmaxx - report_x,report_z);
883 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_y, screenmaxx - report_x,report_z); 901 else
884 else902 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_x, report_y,report_z);
885 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_x, report_y,report_z); 903 }
886 }904 }
887 }905 break;
888 break;906 }
889 }907 break;
890 break;
891 case EV_ABS:908 case EV_ABS:
892 switch (event->code) {909 switch (event->code) {
893 case ABS_X:910 case ABS_X:
894 x = event->value;911 x = event->value;
895 if(debugyn)912 if(debugyn)
896 xf86Msg(X_CONFIG, "ABS_X x is %d\n", x);913 xf86Msg(X_CONFIG, "ABS_X x is %d\n", x);
897 break; 914 break;
898 case ABS_Z: 915 case ABS_Z:
899 x = event->value;916 x = event->value;
900 if(debugyn)917 if(debugyn)
901 xf86Msg(X_CONFIG, "ABS_Z x is %d\n", x);918 xf86Msg(X_CONFIG, "ABS_Z x is %d\n", x);
902 break;919 break;
903 case ABS_RX:920 case ABS_RX:
904 y = event->value;921 y = event->value;
905 if(debugyn)922 if(debugyn)
906 xf86Msg(X_CONFIG, "ABS_RX y is %d\n", y);923 xf86Msg(X_CONFIG, "ABS_RX y is %d\n", y);
907 break;924 break;
908 case ABS_Y:925 case ABS_Y:
909 y = event->value;926 y = event->value;
910 if(debugyn)927 if(debugyn)
911 xf86Msg(X_CONFIG, "ABS_Y y is %d\n", y);928 xf86Msg(X_CONFIG, "ABS_Y y is %d\n", y);
912 break;929 break;
913930
914 case ABS_PRESSURE:931 case ABS_PRESSURE:
915 /* mpa send button events if pressure 932 /* mpa send button events if pressure
916 crosses topZ threshold */933 crosses topZ threshold */
917 oldz = z;934 oldz = z;
918 z = event->value;935 z = event->value;
919 if ( z <= priv->topZ && oldz > priv->topZ){ 936 if (z <= priv->topZ && oldz > priv->topZ) {
920 buttons = set_bit(buttons,0,0);937 buttons = set_bit(buttons,0,0);
921 if(debugyn)938 if(debugyn)
922 xf86Msg(X_CONFIG, "setting PEN UP event\n");939 xf86Msg(X_CONFIG, "setting PEN UP event\n");
923 }940 }
924 if ( oldz <= priv->topZ && z > priv->topZ ){941 if ( oldz <= priv->topZ && z > priv->topZ ) {
925 buttons = set_bit(buttons,0,1);942 buttons = set_bit(buttons,0,1);
926 if(debugyn)943 if(debugyn)
927 xf86Msg(X_CONFIG, "setting PEN DOWN event\n");944 xf86Msg(X_CONFIG, "setting PEN DOWN event\n");
928 }945 }
929 if(debugyn)946 if(debugyn)
930 xf86Msg(X_CONFIG, "ABS_PRESSURE z is %d\n", z);947 xf86Msg(X_CONFIG, "ABS_PRESSURE z is %d\n", z);
931 break;948 break;
932949
933 case ABS_MISC:950 case ABS_MISC:
934 break;951 break;
935952
936 }953 }
937 break; // EV_ABS 954 break; // EV_ABS
938955
939 case EV_KEY:956 case EV_KEY:
940 switch (event->code) {957 switch (event->code) {
941 case BTN_TOOL_PEN:958 case BTN_TOOL_PEN:
942 prox = event->value;959 prox = event->value;
943 if(debugyn)960 if(debugyn)
944 xf86Msg(X_CONFIG, "BTN_TOOL_PEN prox is %d\n", prox);961 xf86Msg(X_CONFIG, "BTN_TOOL_PEN prox is %d\n", prox);
945 break;962 break;
946963
947 case BTN_LEFT:964 case BTN_LEFT:
948 buttons = set_bit(buttons,0,event->value);965 buttons = set_bit(buttons,0,event->value);
949 if(debugyn)966 if(debugyn)
950 xf86Msg(X_CONFIG, "NEW BTN_LEFT event is %d\n", event->value);967 xf86Msg(X_CONFIG, "NEW BTN_LEFT event is %d\n", event->value);
951 case BTN_SIDE:968 // NO BREAK
969 case BTN_SIDE:
952 /* mpa stop sending original pen up/down button970 /* mpa stop sending original pen up/down button
953 events in favor of button code above */971 events in favor of button code above */
954 /* buttons = set_bit(buttons,0,event->value);*/972 /* buttons = set_bit(buttons,0,event->value);*/
955 if(debugyn)973 if(debugyn)
956 xf86Msg(X_CONFIG, "ignored BTN_SIDE event is %d\n", event->value);974 xf86Msg(X_CONFIG, "ignored BTN_SIDE event is %d\n", event->value);
957 break;975 break;
958976
959 case BTN_EXTRA:977 case BTN_EXTRA:
960 if(debugyn)978 if(debugyn)
961 xf86Msg(X_CONFIG, "NEW BTN_EXTRA event is %d\n", event->value);979 xf86Msg(X_CONFIG, "NEW BTN_EXTRA event is %d\n", event->value);
962 case BTN_MIDDLE:980 // NO BREAK
981 case BTN_MIDDLE:
963 buttons = set_bit(buttons,1,event->value);982 buttons = set_bit(buttons,1,event->value);
964 if(debugyn)983 if(debugyn)
965 xf86Msg(X_CONFIG, "BTN_MIDDLE event is %d\n", event->value);984 xf86Msg(X_CONFIG, "BTN_MIDDLE event is %d\n", event->value);
966 break;985 break;
967986
968 case BTN_FORWARD:987 case BTN_FORWARD:
969 if(debugyn)988 if(debugyn)
970 xf86Msg(X_CONFIG, "BTN_FORWARD event is %d\n", event->value);989 xf86Msg(X_CONFIG, "BTN_FORWARD event is %d\n", event->value);
990 // NO BREAK
971 case BTN_RIGHT:991 case BTN_RIGHT:
972 buttons = set_bit(buttons,2,event->value);992 buttons = set_bit(buttons,2,event->value);
973 if(debugyn)993 if(debugyn)
974 xf86Msg(X_CONFIG, "BTN_RIGHT event is %d\n", event->value);994 xf86Msg(X_CONFIG, "BTN_RIGHT event is %d\n", event->value);
975 break;995 break;
976 }996 }
977 break; // EV_KEY 997 break; // EV_KEY
978 case EV_MSC:998 case EV_MSC:
979 break;999 break;
980 default:1000 default:
981 xf86Msg(X_ERROR, "%s: unknown event type/code/value %d/%d/%d\n", local->name, event->type, event->code, event->value);1001 xf86Msg(X_ERROR, "%s: unknown event type/code/value %d/%d/%d\n", local->name, event->type, event->code, event->value);
982 } /* switch event->type */1002 } /* switch event->type */
9831003
984 /* mpa If pressure is below threshold, set pressure and reported1004 /* mpa If pressure is below threshold, set pressure and reported
985 pressure to 0 */ 1005 pressure to 0 */
986 if (z <= priv->topZ){1006 if (z <= priv->topZ) {
987 report_z = 0;1007 report_z = 0;
988 /*z = 0;*/1008 } else if(z >= priv->bottomZ) {
989 }else if(z >= priv->bottomZ){1009 report_z = 1023;
990 /*z = priv->bottomZ;*/1010 } else { /* mpa Otherwise scale down by min pressure val */
991 /*report_z = priv->bottomZ - priv->topZ;*/1011 report_z = z - priv->topZ;
992 report_z = 1023;1012 rz = report_z;
993 }else{ /* mpa Otherwise scale down by min pressure val */1013 report_z = 1023.0 * (rz / (priv->bottomZ - priv->topZ));
994 report_z = z - priv->topZ;1014 }
995 rz = report_z;1015
996 report_z = 1023.0 * (rz / (priv->bottomZ - priv->topZ));1016 if (x>priv->topX && x<priv->bottomX)
997 } 1017 report_x = (x-priv->topX) * screenmaxx / (priv->bottomX-priv->topX);
998 /* mpa now scale back up so we again report a range of 0 to 1023 */ 1018 else{
999 /*merged with above if/then/else1019 if(x<priv->topX)
1000 if(report_z >= (priv->bottomZ - priv->topZ)){1020 report_x = 0;
1001 report_z = 1023;1021 else
1002 }else if (report_z){1022 report_x = screenmaxx;
1003 rz = report_z;1023 }
1004 report_z = 1023.0 * (rz / (priv->bottomZ - priv->topZ));1024 if (y>priv->topY && y<priv->bottomY)
1005 }1025 report_y = (y-priv->topY) * screenmaxy / (priv->bottomY-priv->topY);
1006 */1026 else {
10071027 if(y<priv->topY)
1028 report_y = 0;
1029 else
1030 report_y = screenmaxy;
1031 }
1032
1033 if (rotate90) {
1034 int tempval;
1035 if (report_y < 0)
1036 report_y = 0;
1037 if (report_x < 0)
1038 report_x = 0;
1039 tempval = report_x;
1040 report_x = (screenmaxy - report_y);
1041 if (report_x > 1278)
1042 report_x = 1278;
1043 report_y = tempval;
1044 }
1045
1046 // We ALWAYS send button events right after we notice them
1047 // The pen might get stuck in pressed down state otherwise
1048 if (priv->wizardpenOldButtons != buttons)
1049 {
1050 int delta = buttons ^ priv->wizardpenOldButtons;
1051 while (delta)
1052 {
1053 int id = ffs(delta);
1054 delta &= ~(1 << (id-1));
1055 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_x, report_y, report_z);
1056 }
1057 }
1058 priv->wizardpenOldButtons = buttons;
1059
1008 /* Linux Kernel 2.6.x sends EV_SYN/SYN_REPORT as an event terminator,1060 /* Linux Kernel 2.6.x sends EV_SYN/SYN_REPORT as an event terminator,
1009 * whereas 2.4.x sends EV_ABS/ABS_MISC. We have to support both.1061 * whereas 2.4.x sends EV_ABS/ABS_MISC. We have to support both.
1010 */1062 */
1011 if (!( (event->type == EV_SYN && event->code == SYN_REPORT) ||1063 if ((event->type == EV_SYN && event->code == SYN_REPORT) ||
1012 (event->type == EV_ABS && event->code == ABS_MISC)1064 (event->type == EV_ABS && event->code == ABS_MISC))
1013 )) {
1014 continue;
1015 }
1016 if(x>priv->topX && x<priv->bottomX)
1017 /*report_x = (x-priv->topX) * screenInfo.screens[0]->width / (priv->bottomX-priv->topX);*/
1018 report_x = (x-priv->topX) * screenmaxx / (priv->bottomX-priv->topX);
1019 else{
1020 if(x<priv->topX)
1021 report_x = 0;
1022 else
1023 report_x = screenmaxx; /*screenInfo.screens[0]->width;*/
1024 }
1025 if(y>priv->topY && y<priv->bottomY)
1026 /*report_y = (y-priv->topY) * screenInfo.screens[0]->height / (priv->bottomY-priv->topY);*/
1027 report_y = (y-priv->topY) * screenmaxy / (priv->bottomY-priv->topY);
1028 else{
1029 if(y<priv->topY)
1030 report_y = 0;
1031 else
1032 report_y = screenmaxy; /*screenInfo.screens[0]->height;*/
1033 }
1034 if(rotate90){
1035 int tempval;
1036 if (report_y < 0)
1037 report_y = 0;
1038 if (report_x < 0)
1039 report_x = 0;
1040 tempval = report_x;
1041 report_x = (screenmaxy - report_y);
1042 if (report_x > 1278)
1043 report_x = 1278;
1044 report_y = tempval;
1045 }
1046 if (1)
1047 {1065 {
1048 if (!(priv->wizardpenOldProximity))1066 if (!(priv->wizardpenOldProximity))
1049 if (!is_core_pointer)1067 if (!is_core_pointer)
1050 {1068 {
1051 /* mpa send value of report_z rather than z */1069 xf86PostProximityEvent(local->dev, 1, 0, 3 ,
1052 xf86PostProximityEvent(local->dev, 1, 0, 3 , 1070 report_x, report_y, report_z);
1053 report_x, report_y, report_z);
1054 }1071 }
10551072
1056
1057 /* mpa send value of report_z rather than z */
1058 xf86PostMotionEvent(local->dev, 1, 0, 3, report_x, report_y, report_z);1073 xf86PostMotionEvent(local->dev, 1, 0, 3, report_x, report_y, report_z);
1059 if (priv->wizardpenOldButtons != buttons)
1060 {
1061 int delta = buttons ^ priv->wizardpenOldButtons;
1062 while (delta)
1063 {
1064 int id = ffs(delta);
1065 delta &= ~(1 << (id-1));
1066 xf86PostButtonEvent(local->dev, 1, id, (buttons&(1<<(id-1))), 0, 3, report_x, report_y,report_z); /*mpa send report_z instead of z*/
1067 }
1068 }
1069 }
1070 else
1071 {
1072 if (!is_core_pointer)
1073 if (priv->wizardpenOldProximity)
1074 {
1075 xf86PostProximityEvent(local->dev, 0, 0, 3, report_x,report_y,report_z);
1076 }
1077 priv->wizardpenOldProximity = 0;
1078 }
10791074
1080 priv->wizardpenOldButtons = buttons;1075 priv->wizardpenOldX = x;
1081 priv->wizardpenOldX = x;1076 priv->wizardpenOldY = y;
1082 priv->wizardpenOldY = y;1077 priv->wizardpenOldZ = z;
1083 priv->wizardpenOldZ = z;1078 priv->wizardpenOldProximity = prox;
1084 priv->wizardpenOldProximity = prox;1079 }
1085 }1080 }
1086 /*xf86Msg(X_INFO, "ACECAD Tablet Sortie Read Input\n");*/
1087}1081}
1088#endif1082#endif
10891083
@@ -1102,24 +1096,24 @@
1102 int v0, int v1, int v2, int v3, int v4, int v5, int *x, int *y)1096 int v0, int v1, int v2, int v3, int v4, int v5, int *x, int *y)
1103{1097{
1104 WizardPenPrivatePtr priv = (WizardPenPrivatePtr)(local->private);1098 WizardPenPrivatePtr priv = (WizardPenPrivatePtr)(local->private);
1105 if(v0>priv->topX && v0<priv->bottomX)1099 if(v0>priv->topX && v0<priv->bottomX)
1106 /**x = (v0-priv->topX) * screenInfo.screens[0]->width / (priv->bottomX-priv->topX);*/1100 /**x = (v0-priv->topX) * screenInfo.screens[0]->width / (priv->bottomX-priv->topX);*/
1107 *x = (v0-priv->topX) * screenmaxx / (priv->bottomX-priv->topX);1101 *x = (v0-priv->topX) * screenmaxx / (priv->bottomX-priv->topX);
1108 else{1102 else{
1109 if(v0<priv->topX)1103 if(v0<priv->topX)
1110 *x = priv->topX;1104 *x = priv->topX;
1111 else1105 else
1112 *x = priv->bottomX;1106 *x = priv->bottomX;
1113 }1107 }
1114 if(v1>priv->topY && v1<priv->bottomY)1108 if(v1>priv->topY && v1<priv->bottomY)
1115 /**y = (v1-priv->topY) * screenInfo.screens[0]->width / (priv->bottomY-priv->topY);*/1109 /**y = (v1-priv->topY) * screenInfo.screens[0]->width / (priv->bottomY-priv->topY);*/
1116 *y = (v1-priv->topY) * screenmaxy / (priv->bottomY-priv->topY);1110 *y = (v1-priv->topY) * screenmaxy / (priv->bottomY-priv->topY);
1117 else{1111 else{
1118 if(v1<priv->topY)1112 if(v1<priv->topY)
1119 *y = priv->topY;1113 *y = priv->topY;
1120 else1114 else
1121 *y = priv->bottomY;1115 *y = priv->bottomY;
1122 }1116 }
1123 return TRUE;1117 return TRUE;
1124}1118}
11251119
@@ -1185,7 +1179,7 @@
11851179
1186#define BITS_PER_LONG (sizeof(long) * 8)1180#define BITS_PER_LONG (sizeof(long) * 8)
1187#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)1181#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
1188#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)1182#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)
1189#define OFF(x) ((x)%BITS_PER_LONG)1183#define OFF(x) ((x)%BITS_PER_LONG)
1190#define LONG(x) ((x)/BITS_PER_LONG)1184#define LONG(x) ((x)/BITS_PER_LONG)
11911185
@@ -1193,11 +1187,11 @@
1193static Bool1187static Bool
1194USBQueryHardware (LocalDevicePtr local)1188USBQueryHardware (LocalDevicePtr local)
1195{1189{
1196 WizardPenPrivatePtr priv = (WizardPenPrivatePtr) local->private;1190 WizardPenPrivatePtr priv = (WizardPenPrivatePtr) local->private;
1197 unsigned long bit[EV_MAX][NBITS(KEY_MAX)];1191 unsigned long bit[EV_MAX][NBITS(KEY_MAX)];
1198 int i, j;1192 int i, j;
1199 int abs[5];1193 int abs[5];
1200 char name[256] = "Unknown";1194 char name[256] = "Unknown";
12011195
1202 ioctl(local->fd, EVIOCGNAME(sizeof(name)), name);1196 ioctl(local->fd, EVIOCGNAME(sizeof(name)), name);
1203 xf86MsgVerb(X_PROBED, 4, "Kernel Input device name: \"%s\"\n", name);1197 xf86MsgVerb(X_PROBED, 4, "Kernel Input device name: \"%s\"\n", name);
@@ -1215,17 +1209,17 @@
1215 switch (j) {1209 switch (j) {
1216 case ABS_X:1210 case ABS_X:
1217 if(!priv->bottomX)1211 if(!priv->bottomX)
1218 priv->bottomX = abs[2];1212 priv->bottomX = abs[2];
1219 break;1213 break;
12201214
1221 case ABS_Y:1215 case ABS_Y:
1222 if(!priv->bottomY)1216 if(!priv->bottomY)
1223 priv->bottomY = abs[2];1217 priv->bottomY = abs[2];
1224 break;1218 break;
12251219
1226 case ABS_PRESSURE:1220 case ABS_PRESSURE:
1227 if(!priv->bottomZ)1221 if(!priv->bottomZ)
1228 priv->bottomZ = abs[2];1222 priv->bottomZ = abs[2];
1229 break;1223 break;
1230 }1224 }
1231 }1225 }
12321226
=== modified file 'src/wizardpen.h'
--- src/wizardpen.h 2009-06-24 19:51:16 +0000
+++ src/wizardpen.h 2010-03-20 19:15:26 +0000
@@ -1,8 +1,8 @@
1/* 1/*
2 * Copyright (c) 2001 Edouard TISSERANT <tissered@esstin.u-nancy.fr>2 * Copyright (c) 2001 Edouard TISSERANT <tissered@esstin.u-nancy.fr>
3 * Parts inspired from Shane Watts <shane@bofh.asn.au> Xfree 3 Acecad Driver3 * Parts inspired from Shane Watts <shane@bofh.asn.au> Xfree 3 Acecad Driver
4 * Thanks to Emily, from AceCad, For giving me documents.4 * Thanks to Emily, from AceCad, For giving me documents.
5 * 5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation8 * to deal in the Software without restriction, including without limitation
@@ -29,37 +29,37 @@
29#define _WIZARDPEN_H_29#define _WIZARDPEN_H_
3030
31/******************************************************************************31/******************************************************************************
32 * Definitions32 * Definitions
33 * structs, typedefs, #defines, enums33 * structs, typedefs, #defines, enums
34 *****************************************************************************/34 *****************************************************************************/
35#define WIZARDPEN_PACKET_SIZE 735#define WIZARDPEN_PACKET_SIZE 7
3636
37#define WIZARDPEN_CONFIG "a" /* Send configuration (max coords) */37#define WIZARDPEN_CONFIG "a" /* Send configuration (max coords) */
3838
39#define WIZARDPEN_ABSOLUTE 'F' /* Absolute mode */39#define WIZARDPEN_ABSOLUTE 'F' /* Absolute mode */
40#define WIZARDPEN_RELATIVE 'E' /* Relative mode */40#define WIZARDPEN_RELATIVE 'E' /* Relative mode */
4141
42#define WIZARDPEN_UPPER_ORIGIN "b" /* Origin upper left */42#define WIZARDPEN_UPPER_ORIGIN "b" /* Origin upper left */
4343
44#define WIZARDPEN_PROMPT_MODE "B" /* Prompt mode */44#define WIZARDPEN_PROMPT_MODE "B" /* Prompt mode */
45#define WIZARDPEN_STREAM_MODE "@" /* Stream mode */45#define WIZARDPEN_STREAM_MODE "@" /* Stream mode */
46#define WIZARDPEN_INCREMENT 'I' /* Set increment */46#define WIZARDPEN_INCREMENT 'I' /* Set increment */
47#define WIZARDPEN_BINARY_FMT "zb" /* Binary reporting */47#define WIZARDPEN_BINARY_FMT "zb" /* Binary reporting */
4848
49#define WIZARDPEN_PROMPT "P" /* Prompt for current position */49#define WIZARDPEN_PROMPT "P" /* Prompt for current position */
5050
51#define PHASING_BIT 0x8051#define PHASING_BIT 0x80
52#define PROXIMITY_BIT 0x4052#define PROXIMITY_BIT 0x40
53#define TABID_BIT 0x2053#define TABID_BIT 0x20
54#define XSIGN_BIT 0x1054#define XSIGN_BIT 0x10
55#define YSIGN_BIT 0x0855#define YSIGN_BIT 0x08
56#define BUTTON_BITS 0x0756#define BUTTON_BITS 0x07
57#define COORD_BITS 0x7f57#define COORD_BITS 0x7f
5858
59#define ABSOLUTE_FLAG 159#define ABSOLUTE_FLAG 1
60#define USB_FLAG 260#define USB_FLAG 2
61#define AUTODEV_FLAG 461#define AUTODEV_FLAG 4
62#define AVAIL_FLAG 862#define AVAIL_FLAG 8
6363
64#define NOTAVAIL ((errno == ENODEV) || (errno == ENXIO) || (errno == ENOENT))64#define NOTAVAIL ((errno == ENODEV) || (errno == ENXIO) || (errno == ENOENT))
6565
@@ -69,34 +69,34 @@
6969
70static const char * wizardpen_initstr = WIZARDPEN_BINARY_FMT WIZARDPEN_STREAM_MODE;70static const char * wizardpen_initstr = WIZARDPEN_BINARY_FMT WIZARDPEN_STREAM_MODE;
7171
72typedef struct 72typedef struct
73{73{
74 XISBuffer *buffer;74 XISBuffer *buffer;
75 int wizardpenInc; /* increment between transmits */75 int wizardpenInc; /* increment between transmits */
76 int wizardpenOldX; /* previous X position */76 int wizardpenOldX; /* previous X position */
77 int wizardpenOldY; /* previous Y position */77 int wizardpenOldY; /* previous Y position */
78 int wizardpenOldZ; /* previous Z position */78 int wizardpenOldZ; /* previous Z position */
79 int wizardpenOldProximity; /* previous proximity */79 int wizardpenOldProximity; /* previous proximity */
80 int wizardpenOldButtons; /* previous buttons state */80 int wizardpenOldButtons; /* previous buttons state */
81 int wizardpenMaxX; /* max X value */81 int wizardpenMaxX; /* max X value */
82 int wizardpenMaxY; /* max Y value */82 int wizardpenMaxY; /* max Y value */
83 int wizardpenMaxZ; /* max Y value */83 int wizardpenMaxZ; /* max Y value */
84 char wizardpenReportSpeed; /* report speed */84 char wizardpenReportSpeed; /* report speed */
85 int flags; /* various flags */85 int flags; /* various flags */
86 int packeti; /* number of bytes read */86 int packeti; /* number of bytes read */
87 int PacketSize; /* number of bytes read */87 int PacketSize; /* number of bytes read */
88 unsigned char packet[WIZARDPEN_PACKET_SIZE]; /* data read on the device */88 unsigned char packet[WIZARDPEN_PACKET_SIZE]; /* data read on the device */
89 int topZ;89 int topZ;
90 int bottomZ;90 int bottomZ;
91 int topX;91 int topX;
92 int topY;92 int topY;
93 int bottomX;93 int bottomX;
94 int bottomY;94 int bottomY;
95} WizardPenPrivateRec, *WizardPenPrivatePtr;95} WizardPenPrivateRec, *WizardPenPrivatePtr;
9696
9797
98/******************************************************************************98/******************************************************************************
99 * Declarations99 * Declarations
100 *****************************************************************************/100 *****************************************************************************/
101#ifdef XFree86LOADER101#ifdef XFree86LOADER
102static MODULESETUPPROTO( SetupProc );102static MODULESETUPPROTO( SetupProc );

Subscribers

People subscribed via source and target branches