77 lines
2.0 KiB
Plaintext
77 lines
2.0 KiB
Plaintext
|
Index: adc7843.c
|
||
|
===================================================================
|
||
|
RCS file: /cvsroot/pgui/pgserver/input/adc7843.c,v
|
||
|
retrieving revision 1.6
|
||
|
diff -u -r1.6 adc7843.c
|
||
|
--- adc7843.c 3 Jul 2002 22:03:29 -0000 1.6
|
||
|
+++ adc7843.c 6 Nov 2002 00:25:45 -0000
|
||
|
@@ -60,16 +60,16 @@
|
||
|
|
||
|
int adc7843_fd;
|
||
|
|
||
|
-struct tpanel_sample {
|
||
|
- u16 state;
|
||
|
- u16 x;
|
||
|
- u16 y;
|
||
|
-};
|
||
|
-
|
||
|
/******************************************** Implementations */
|
||
|
|
||
|
g_error adc7843_init(void) {
|
||
|
adc7843_fd = open("/dev/tpanel",O_NONBLOCK);
|
||
|
+
|
||
|
+ /* devfs name */
|
||
|
+
|
||
|
+ if (adc7843_fd <= 0)
|
||
|
+ adc7843_fd = open("/dev/misc/adc7843", O_NONBLOCK);
|
||
|
+
|
||
|
if (adc7843_fd <= 0)
|
||
|
return mkerror(PG_ERRT_IO, 74);
|
||
|
|
||
|
@@ -87,9 +87,10 @@
|
||
|
}
|
||
|
|
||
|
int adc7843_fd_activate(int fd) {
|
||
|
- struct tpanel_sample ts;
|
||
|
+ int state;
|
||
|
char buffer[6];
|
||
|
- int trigger, x, y;
|
||
|
+ int trigger;
|
||
|
+ static int x=0, y=0;
|
||
|
|
||
|
if (!cal) {
|
||
|
if (!vid)
|
||
|
@@ -107,17 +108,22 @@
|
||
|
return 1;
|
||
|
|
||
|
/* Convert the bytes to unsigned integers... */
|
||
|
- ts.state = ( ( (buffer[0]) << 8 ) + buffer[1] );
|
||
|
- ts.x = ( ( (buffer[2]) << 8 ) + buffer[3] );
|
||
|
- ts.y = ( ( (buffer[4]) << 8 ) + buffer[5] );
|
||
|
- x = ts.x;
|
||
|
- y = ts.y;
|
||
|
-
|
||
|
- /* Converte to screen coordinates... */
|
||
|
- x = ( ( ts.x - cal->min_x ) * cal->x_res / ( cal->max_x - cal->min_x ) );
|
||
|
- y = ( ( ts.y - cal->min_y ) * cal->y_res / ( cal->max_y - cal->min_y ) );
|
||
|
+ state = ( ( (buffer[0]) << 8 ) + buffer[1] );
|
||
|
+
|
||
|
+ /* save x,y in static variables. when pen up, send the last known
|
||
|
+ coordinates */
|
||
|
+
|
||
|
+ if (state) {
|
||
|
+ x = ( ( (buffer[2]) << 8 ) + buffer[3] );
|
||
|
+ y = ( ( (buffer[4]) << 8 ) + buffer[5] );
|
||
|
+
|
||
|
+ /* Convert to screen coordinates... */
|
||
|
+ x = ( ( x - cal->min_x ) * cal->x_res / ( cal->max_x - cal->min_x ) );
|
||
|
+ y = ( ( y - cal->min_y ) * cal->y_res / ( cal->max_y - cal->min_y ) );
|
||
|
+ }
|
||
|
|
||
|
- infilter_send_pointing(PG_TRIGGER_PNTR_STATUS,x,y,ts.state,NULL);
|
||
|
+ infilter_send_pointing(PG_TRIGGER_PNTR_STATUS,x,y,state,NULL);
|
||
|
+
|
||
|
return 1;
|
||
|
}
|
||
|
|