X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fgp2x.c;h=56fbf5cde9a2343da28504fd8ef32a5aa2ac906b;hb=f7c40368a7700e5f18993c71a7d77bfe768c4900;hp=78e8561f857034c6a6bf16d7876238bfd3e4d2d9;hpb=3f2aaff20c940e90e970c008e56f5253d494a92c;p=libpicofe.git diff --git a/gp2x/gp2x.c b/gp2x/gp2x.c index 78e8561..56fbf5c 100644 --- a/gp2x/gp2x.c +++ b/gp2x/gp2x.c @@ -231,21 +231,24 @@ typedef struct ucb1x00_ts_event int gp2x_touchpad_read(int *x, int *y) { UCB1X00_TS_EVENT event; + static int zero_seen = 0; int retval; if (touchdev < 0) return -1; retval = read(touchdev, &event, sizeof(event)); - if (retval < 0) { + if (retval <= 0) { printf("touch read failed %i %i\n", retval, errno); return -1; } + // this is to ignore the messed-up 4.1.x driver + if (event.pressure == 0) zero_seen = 1; if (x) *x = (event.x * touchcal[0] + touchcal[2]) >> 16; if (y) *y = (event.y * touchcal[4] + touchcal[5]) >> 16; // printf("read %i %i %i\n", event.pressure, *x, *y); - return event.pressure; + return zero_seen ? event.pressure : 0; }