Commit 9855645e authored by Sam Lantinga's avatar Sam Lantinga

Date: Thu, 26 Apr 2001 10:46:23 +0200

From: Alexander Pipelka <pipelka@bms-austria.com>
Subject: SDL ELO driver bugfix

Hi Sam!

We noticed that the ELO serial touchscreen controller is quite sensitive
in terms of correct protocol handling.
The current implementation cause some controllers to hangup after some
time (> 24h).

I think the attached patch should fix this (I ran my device more than 3
days without any hangups).

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%405
parent 20e13660
...@@ -421,3 +421,26 @@ int eloInitController(int fd) { ...@@ -421,3 +421,26 @@ int eloInitController(int fd) {
return 1; return 1;
} }
int eloReadPosition(_THIS, int fd, int* x, int* y, int* button_state, int* realx, int* realy) {
unsigned char buffer[ELO_PACKET_SIZE];
int pointer = 0;
int checksum = ELO_INIT_CHECKSUM;
while(pointer < ELO_PACKET_SIZE) {
if(eloGetPacket(buffer, &pointer, &checksum, fd)) {
break;
}
}
if(!eloParsePacket(buffer, realx, realy, button_state)) {
return 0;
}
*x = *realx;
*y = *realy;
eloConvertXY(this, x, y);
return 1;
}
...@@ -52,4 +52,10 @@ int eloInitController(int fd); ...@@ -52,4 +52,10 @@ int eloInitController(int fd);
*/ */
int eloParsePacket(unsigned char* mousebuf, int* dx, int* dy, int* button_state); int eloParsePacket(unsigned char* mousebuf, int* dx, int* dy, int* button_state);
/* eloReadPosition
read a packet and get the cursor position
*/
int eloReadPosition(_THIS, int fd, int* x, int* y, int* button_state, int* realx, int* realy);
#endif /* SDL_fbelo_h */ #endif /* SDL_fbelo_h */
...@@ -619,7 +619,8 @@ static void handle_mouse(_THIS) ...@@ -619,7 +619,8 @@ static void handle_mouse(_THIS)
int button = 0; int button = 0;
int dx = 0, dy = 0; int dx = 0, dy = 0;
int packetsize = 0; int packetsize = 0;
int realx, realy;
/* Figure out the mouse packet size */ /* Figure out the mouse packet size */
switch (mouse_drv) { switch (mouse_drv) {
case MOUSE_NONE: case MOUSE_NONE:
...@@ -647,6 +648,18 @@ static void handle_mouse(_THIS) ...@@ -647,6 +648,18 @@ static void handle_mouse(_THIS)
break; break;
} }
/* Special handling for the quite sensitive ELO controller */
if (mouse_drv == MOUSE_ELO) {
/* try to read the next packet */
if(eloReadPosition(this, mouse_fd, &dx, &dy, &button, &realx, &realy)) {
button = (button & 0x01) << 2;
FB_vgamousecallback(button, relative, dx, dy);
}
return;
}
/* Read as many packets as possible */ /* Read as many packets as possible */
nread = read(mouse_fd, &mousebuf[start], BUFSIZ-start); nread = read(mouse_fd, &mousebuf[start], BUFSIZ-start);
if ( nread < 0 ) { if ( nread < 0 ) {
...@@ -740,25 +753,25 @@ static void handle_mouse(_THIS) ...@@ -740,25 +753,25 @@ static void handle_mouse(_THIS)
dx = (signed char)mousebuf[i+1]; dx = (signed char)mousebuf[i+1];
dy = -(signed char)mousebuf[i+2]; dy = -(signed char)mousebuf[i+2];
break; break;
/*
case MOUSE_ELO: case MOUSE_ELO:
/* ELO protocol has ELO_START_BYTE as first byte */
if ( mousebuf[i] != ELO_START_BYTE ) { if ( mousebuf[i] != ELO_START_BYTE ) {
/* Go to next byte */
i -= (packetsize-1); i -= (packetsize-1);
continue; continue;
} }
/* parse the packet */
if(!eloParsePacket(&(mousebuf[i]), &dx, &dy, &button)) { if(!eloParsePacket(&(mousebuf[i]), &dx, &dy, &button)) {
break; i -= (packetsize-1);
continue;
} }
button = (button & 0x01) << 2; button = (button & 0x01) << 2;
/* convert to screen coordinates */
eloConvertXY(this, &dx, &dy); eloConvertXY(this, &dx, &dy);
break; break;
*/
case MOUSE_ELO:
case NUM_MOUSE_DRVS: case NUM_MOUSE_DRVS:
/* Uh oh.. */ /* Uh oh.. */
dx = 0; dx = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment