From 0c5fe95925d19d1a835348196a120b10f2892368 Mon Sep 17 00:00:00 2001 From: Douglas Lowder Date: Mon, 1 Jul 2002 23:02:58 -0700 Subject: [PATCH] Fixes to tests/fbutils.c: see ChangeLog --- ChangeLog | 10 ++++++++ Makefile.in | 2 +- etc/Makefile.in | 2 +- mkinstalldirs | 2 +- plugins/Makefile.in | 2 +- plugins/linear.c | 11 +++++---- src/Makefile.am | 10 ++++++-- src/Makefile.in | 26 ++++++++++++++++---- src/ts_config.c | 10 +++++--- src/ts_load_module.c | 14 +++++++---- tests/Makefile.in | 2 +- tests/fbutils.c | 67 ++++++++++++++++++++++++++++++++-------------------- tests/ts_calibrate.c | 23 +++++++++++++----- tests/ts_print.c | 9 +++++-- tests/ts_test.c | 14 +++++++---- 15 files changed, 144 insertions(+), 60 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3b69be4..4c7c700 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2002-07-01 Douglas Lowder + +- Fixes to make this code work better on targets with framebuffers that have + more than 8 bits per pixel (changes to tests/fbutils.c): + * Removed the code that attempts to change colormap + * Temporarily commented out the code that opens /dev/tty1 (does not work on all targets) + +- Fixed the test program so that the crosshair is drawn XORed with the text on the screen, + so the text is not corrupted when the crosshair moves over it. (tests/fbutils.c) + 2002-06-19 Douglas Lowder - Fixed a problem that caused tslib_parse_vars() (src/ts_parse_vars.c) to not diff --git a/Makefile.in b/Makefile.in index d41f5e9..fc516d8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -18,7 +18,7 @@ # This file is placed under the LGPL. Please see the file # COPYING for more details. # -# $Id: Makefile.in,v 1.1 2002/06/19 19:05:35 dlowder Exp $ +# $Id: Makefile.in,v 1.2 2002/07/01 23:02:57 dlowder Exp $ # diff --git a/etc/Makefile.in b/etc/Makefile.in index 88a4f9e..9f13a88 100644 --- a/etc/Makefile.in +++ b/etc/Makefile.in @@ -18,7 +18,7 @@ # This file is placed under the LGPL. Please see the file # COPYING for more details. # -# $Id: Makefile.in,v 1.1 2002/06/19 19:05:36 dlowder Exp $ +# $Id: Makefile.in,v 1.2 2002/07/01 23:02:57 dlowder Exp $ # diff --git a/mkinstalldirs b/mkinstalldirs index 0cadaea..c74018d 100755 --- a/mkinstalldirs +++ b/mkinstalldirs @@ -4,7 +4,7 @@ # Created: 1993-05-16 # Public domain -# $Id: mkinstalldirs,v 1.1 2002/06/19 19:05:36 dlowder Exp $ +# $Id: mkinstalldirs,v 1.2 2002/07/01 23:02:57 dlowder Exp $ errstatus=0 diff --git a/plugins/Makefile.in b/plugins/Makefile.in index 6ac38d9..1234fc6 100644 --- a/plugins/Makefile.in +++ b/plugins/Makefile.in @@ -18,7 +18,7 @@ # This file is placed under the LGPL. Please see the file # COPYING for more details. # -# $Id: Makefile.in,v 1.1 2002/06/19 19:05:36 dlowder Exp $ +# $Id: Makefile.in,v 1.2 2002/07/01 23:02:57 dlowder Exp $ # diff --git a/plugins/linear.c b/plugins/linear.c index 35c4f71..510c4f3 100644 --- a/plugins/linear.c +++ b/plugins/linear.c @@ -6,7 +6,7 @@ * This file is placed under the LGPL. Please see the file * COPYING for more details. * - * $Id: linear.c,v 1.3 2002/06/17 17:21:42 dlowder Exp $ + * $Id: linear.c,v 1.4 2002/07/01 23:02:57 dlowder Exp $ * * Linearly scale touchscreen values */ @@ -106,6 +106,8 @@ struct tslib_module_info *mod_init(struct tsdev *dev, const char *params) char pcalbuf[200]; int index; char *tokptr; + char *calfile=NULL; + char *defaultcalfile = "/etc/pointercal"; lin = malloc(sizeof(struct tslib_linear)); if (lin == NULL) @@ -126,10 +128,11 @@ struct tslib_module_info *mod_init(struct tsdev *dev, const char *params) lin->p_div = 1; /* - * Check /etc/pointercal + * Check calibration file */ - if(stat("/etc/pointercal",&sbuf)==0) { - pcal_fd = open("/etc/pointercal",O_RDONLY); + if( (calfile = getenv("TSLIB_CALIBFILE")) == NULL) calfile = defaultcalfile; + if(stat(calfile,&sbuf)==0) { + pcal_fd = open(calfile,O_RDONLY); read(pcal_fd,pcalbuf,200); lin->a[0] = atoi(strtok(pcalbuf," ")); index=1; diff --git a/src/Makefile.am b/src/Makefile.am index be51a2f..b825768 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,7 +6,7 @@ # This file is placed under the LGPL. Please see the file # COPYING for more details. # -# $Id: Makefile.am,v 1.3 2002/06/17 17:21:43 dlowder Exp $ +# $Id: Makefile.am,v 1.4 2002/07/01 23:02:57 dlowder Exp $ # CFLAGS := $(CFLAGS) -DPLUGIN_DIR=\"@PLUGIN_DIR@\" -DTS_CONF=\"@TS_CONF@\" $(DEBUGFLAGS) $(INPUTAPIFLAG) @@ -14,10 +14,16 @@ CFLAGS := $(CFLAGS) -DPLUGIN_DIR=\"@PLUGIN_DIR@\" -DTS_CONF=\"@TS_CONF@\" $(DEB noinst_HEADERS = tslib-private.h tslib-filter.h include_HEADERS = tslib.h -lib_LTLIBRARIES = libts.la +lib_LTLIBRARIES = libts.la libtsipaq.la libts_la_SOURCES = ts_attach.c ts_close.c ts_config.c ts_error.c \ ts_fd.c ts_load_module.c ts_open.c ts_parse_vars.c \ ts_read.c ts_read_raw.c libts_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -release $(LT_RELEASE) -export-dynamic libts_la_LIBADD = -ldl +libtsipaq_la_SOURCES = ts_attach.c ts_close.c ts_config.c ts_error.c \ + ts_fd.c ts_load_module.c ts_open.c ts_parse_vars.c \ + ts_read.c ts_read_raw_ipaq.c +libtsipaq_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ + -release $(LT_RELEASE) -export-dynamic +libtsipaq_la_LIBADD = -ldl diff --git a/src/Makefile.in b/src/Makefile.in index af6acdd..1160c66 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -18,7 +18,7 @@ # This file is placed under the LGPL. Please see the file # COPYING for more details. # -# $Id: Makefile.in,v 1.1 2002/06/19 19:05:36 dlowder Exp $ +# $Id: Makefile.in,v 1.2 2002/07/01 23:02:57 dlowder Exp $ # @@ -99,7 +99,7 @@ CFLAGS := $(CFLAGS) -DPLUGIN_DIR=\"@PLUGIN_DIR@\" -DTS_CONF=\"@TS_CONF@\" $(DEBU noinst_HEADERS = tslib-private.h tslib-filter.h include_HEADERS = tslib.h -lib_LTLIBRARIES = libts.la +lib_LTLIBRARIES = libts.la libtsipaq.la libts_la_SOURCES = ts_attach.c ts_close.c ts_config.c ts_error.c \ ts_fd.c ts_load_module.c ts_open.c ts_parse_vars.c \ ts_read.c ts_read_raw.c @@ -108,6 +108,14 @@ libts_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -release $(LT_RELEASE) -export-dynamic libts_la_LIBADD = -ldl +libtsipaq_la_SOURCES = ts_attach.c ts_close.c ts_config.c ts_error.c \ + ts_fd.c ts_load_module.c ts_open.c ts_parse_vars.c \ + ts_read.c ts_read_raw_ipaq.c + +libtsipaq_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ + -release $(LT_RELEASE) -export-dynamic + +libtsipaq_la_LIBADD = -ldl mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = @@ -122,6 +130,10 @@ libts_la_DEPENDENCIES = libts_la_OBJECTS = ts_attach.lo ts_close.lo ts_config.lo ts_error.lo \ ts_fd.lo ts_load_module.lo ts_open.lo ts_parse_vars.lo ts_read.lo \ ts_read_raw.lo +libtsipaq_la_DEPENDENCIES = +libtsipaq_la_OBJECTS = ts_attach.lo ts_close.lo ts_config.lo \ +ts_error.lo ts_fd.lo ts_load_module.lo ts_open.lo ts_parse_vars.lo \ +ts_read.lo ts_read_raw_ipaq.lo COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) @@ -137,9 +149,10 @@ TAR = gtar GZIP_ENV = --best DEP_FILES = .deps/ts_attach.P .deps/ts_close.P .deps/ts_config.P \ .deps/ts_error.P .deps/ts_fd.P .deps/ts_load_module.P .deps/ts_open.P \ -.deps/ts_parse_vars.P .deps/ts_read.P .deps/ts_read_raw.P -SOURCES = $(libts_la_SOURCES) -OBJECTS = $(libts_la_OBJECTS) +.deps/ts_parse_vars.P .deps/ts_read.P .deps/ts_read_raw.P \ +.deps/ts_read_raw_ipaq.P +SOURCES = $(libts_la_SOURCES) $(libtsipaq_la_SOURCES) +OBJECTS = $(libts_la_OBJECTS) $(libtsipaq_la_OBJECTS) all: all-redirect .SUFFIXES: @@ -218,6 +231,9 @@ maintainer-clean-libtool: libts.la: $(libts_la_OBJECTS) $(libts_la_DEPENDENCIES) $(LINK) -rpath $(libdir) $(libts_la_LDFLAGS) $(libts_la_OBJECTS) $(libts_la_LIBADD) $(LIBS) +libtsipaq.la: $(libtsipaq_la_OBJECTS) $(libtsipaq_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libtsipaq_la_LDFLAGS) $(libtsipaq_la_OBJECTS) $(libtsipaq_la_LIBADD) $(LIBS) + install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(includedir) diff --git a/src/ts_config.c b/src/ts_config.c index a8a28c5..3c9800f 100644 --- a/src/ts_config.c +++ b/src/ts_config.c @@ -6,7 +6,7 @@ * This file is placed under the LGPL. Please see the file * COPYING for more details. * - * $Id: ts_config.c,v 1.2 2002/06/17 17:21:43 dlowder Exp $ + * $Id: ts_config.c,v 1.3 2002/07/01 23:02:57 dlowder Exp $ * * Read the configuration and load the appropriate drivers. */ @@ -40,9 +40,13 @@ int ts_config(struct tsdev *ts) FILE *f; int line = 0, ret = 0; - char conffile[80]; + char *conffile; - f = fopen(TS_CONF, "r"); + if( (conffile = getenv("TSLIB_CONFFILE")) != NULL) { + f = fopen(conffile,"r"); + } else { + f = fopen(TS_CONF, "r"); + } if (!f) return -1; diff --git a/src/ts_load_module.c b/src/ts_load_module.c index edd1947..4138eff 100644 --- a/src/ts_load_module.c +++ b/src/ts_load_module.c @@ -6,7 +6,7 @@ * This file is placed under the LGPL. Please see the file * COPYING for more details. * - * $Id: ts_load_module.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $ + * $Id: ts_load_module.c,v 1.2 2002/07/01 23:02:57 dlowder Exp $ * * Close a touchscreen device. */ @@ -25,13 +25,19 @@ int ts_load_module(struct tsdev *ts, const char *module, const char *params) { struct tslib_module_info * (*init)(struct tsdev *, const char *); struct tslib_module_info *info; - char *fn; + char fn[1024]; void *handle; int ret; + char *plugin_directory=NULL; - fn = alloca(sizeof(PLUGIN_DIR) + strlen(module) + 4); + if( (plugin_directory = getenv("TSLIB_PLUGINDIR")) != NULL ) { + //fn = alloca(sizeof(plugin_directory) + strlen(module) + 4); + strcpy(fn,plugin_directory); + } else { + //fn = alloca(sizeof(PLUGIN_DIR) + strlen(module) + 4); + strcpy(fn, PLUGIN_DIR); + } - strcpy(fn, PLUGIN_DIR); strcat(fn, "/"); strcat(fn, module); strcat(fn, ".so"); diff --git a/tests/Makefile.in b/tests/Makefile.in index 4415a4e..2933261 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -18,7 +18,7 @@ # This file is placed under the LGPL. Please see the file # COPYING for more details. # -# $Id: Makefile.in,v 1.1 2002/06/19 19:05:36 dlowder Exp $ +# $Id: Makefile.in,v 1.2 2002/07/01 23:02:58 dlowder Exp $ # diff --git a/tests/fbutils.c b/tests/fbutils.c index f5ae43f..9cc4ebf 100644 --- a/tests/fbutils.c +++ b/tests/fbutils.c @@ -39,6 +39,7 @@ int open_framebuffer(void) int fd, nr; unsigned short col[2]; +/* fd = open("/dev/tty1", O_WRONLY); if (fd < 0) { perror("open /dev/tty1"); @@ -80,7 +81,7 @@ int open_framebuffer(void) return -1; } - +*/ fb_fd = open("/dev/fb0", O_RDWR); if (fb_fd == -1) { perror("open /dev/fb"); @@ -108,13 +109,15 @@ int open_framebuffer(void) cmap.blue = col; cmap.transp = NULL; - col[0] = 0xffff; - col[1] = 0; + col[0] = 0; + col[1] = 0xffff; - if (ioctl(fb_fd, FBIOPUTCMAP, &cmap) < 0) { - perror("ioctl FBIOPUTCMAP"); - close(fb_fd); - return -1; + if(var.bits_per_pixel==8) { + if (ioctl(fb_fd, FBIOPUTCMAP, &cmap) < 0) { + perror("ioctl FBIOPUTCMAP"); + close(fb_fd); + return -1; + } } fbuffer = mmap(NULL, fix.smem_len, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fb_fd, 0); @@ -133,6 +136,7 @@ void close_framebuffer(void) munmap(fbuffer, fix.smem_len); close(fb_fd); +/* if (ioctl(con_fd, KDSETMODE, KD_TEXT) < 0) perror("KDSETMODE"); @@ -141,7 +145,7 @@ void close_framebuffer(void) perror("VT_ACTIVATE"); close(con_fd); - +*/ } void put_cross(int x, int y, int c) @@ -163,14 +167,15 @@ void put_cross(int x, int y, int c) switch(var.bits_per_pixel) { case 8: default: - fbuffer[loc] = c; + //fbuffer[loc] = c; + fbuffer[loc] = fbuffer[loc] ? 0 : 1; break; case 16: - *((unsigned short *)(fbuffer + loc)) = c; + *((unsigned short *)(fbuffer + loc)) = *((unsigned short *)(fbuffer + loc)) ? 0 : 0xffff; break; case 24: case 32: - *((unsigned int *)(fbuffer + loc)) = c; + *((unsigned int *)(fbuffer + loc)) = *((unsigned int *)(fbuffer + loc)) ? 0 : 0xffffffff; break; } } @@ -184,14 +189,15 @@ void put_cross(int x, int y, int c) switch(var.bits_per_pixel) { case 8: default: - fbuffer[loc] = c; + //fbuffer[loc] = c; + fbuffer[loc] = fbuffer[loc] ? 0 : 1; break; case 16: - *((unsigned short *)(fbuffer + loc)) = c; + *((unsigned short *)(fbuffer + loc)) = *((unsigned short *)(fbuffer + loc)) ? 0 : 0xffff; break; case 24: case 32: - *((unsigned int *)(fbuffer + loc)) = c; + *((unsigned int *)(fbuffer + loc)) = *((unsigned int *)(fbuffer + loc)) ? 0 : 0xffffffff; break; } } @@ -202,8 +208,8 @@ void put_char(int x, int y, int c, int color) { int i,j,bits,loc; - for(i=0;i> 16) & 0xff ) << 8; @@ -253,11 +268,13 @@ void setcolors(int bgcolor, int fgcolor) { cmap.blue = blue; cmap.transp = NULL; - if (ioctl(fb_fd, FBIOPUTCMAP, &cmap) < 0) { - perror("ioctl FBIOPUTCMAP"); - close(fb_fd); - return -1; + if(var.bits_per_pixel==8) { + if (ioctl(fb_fd, FBIOPUTCMAP, &cmap) < 0) { + perror("ioctl FBIOPUTCMAP"); + close(fb_fd); + } } +*/ } diff --git a/tests/ts_calibrate.c b/tests/ts_calibrate.c index 9d187b9..95eea15 100644 --- a/tests/ts_calibrate.c +++ b/tests/ts_calibrate.c @@ -6,7 +6,7 @@ * This file is placed under the GPL. Please see the file * COPYING for more details. * - * $Id: ts_calibrate.c,v 1.3 2002/06/17 17:21:43 dlowder Exp $ + * $Id: ts_calibrate.c,v 1.4 2002/07/01 23:02:58 dlowder Exp $ * * Basic test program for touchscreen library. */ @@ -53,7 +53,7 @@ static int getxy(struct tsdev *ts, int *x, int *y) close_framebuffer(); exit(1); } - } while (samp.pressure > 100); + } while (samp.pressure > 0); if (x && y) { *x = sa.x; @@ -148,18 +148,23 @@ int main() calibration cal; int cal_fd; char cal_buffer[256]; - + char *tsdevice = NULL; + char *calfile = NULL; int i; signal(SIGSEGV, sig); signal(SIGINT, sig); signal(SIGTERM, sig); + if( (tsdevice = getenv("TSLIB_TSDEVICE")) != NULL ) { + ts = ts_open(tsdevice,0); + } else { #ifdef USE_INPUT_API - ts = ts_open("/dev/input/event0", 0); + ts = ts_open("/dev/input/event0", 0); #else - ts = ts_open("/dev/touchscreen/ucb1x00", 0); + ts = ts_open("/dev/touchscreen/ucb1x00", 0); #endif /* USE_INPUT_API */ + } if (!ts) { perror("ts_open"); @@ -181,6 +186,8 @@ int main() put_string(xres/2,yres/4,"TSLIB calibration utility",1); put_string(xres/2,yres/4 + 20,"Touch crosshair to calibrate",1); + printf("xres = %d, yres = %d\n",xres,yres); + // Read a touchscreen event to clear the buffer getxy(ts, 0, 0); @@ -235,7 +242,11 @@ int main() printf("Calibration constants: "); for(i=0;i<7;i++) printf("%d ",cal.a[i]); printf("\n"); - cal_fd = open("/etc/pointercal",O_CREAT|O_RDWR); + if( (calfile = getenv("TSLIB_CALIBFILE")) != NULL) { + cal_fd = open(calfile,O_CREAT|O_RDWR); + } else { + cal_fd = open("/etc/pointercal",O_CREAT|O_RDWR); + } sprintf(cal_buffer,"%d %d %d %d %d %d %d",cal.a[1],cal.a[2],cal.a[0],cal.a[4],cal.a[5],cal.a[3],cal.a[6]); write(cal_fd,cal_buffer,strlen(cal_buffer)+1); close(cal_fd); diff --git a/tests/ts_print.c b/tests/ts_print.c index a541d6c..7aa2708 100644 --- a/tests/ts_print.c +++ b/tests/ts_print.c @@ -24,12 +24,17 @@ int main() { struct tsdev *ts; int x, y; + char *tsdevice=NULL; + if( (tsdevice = getenv("TSLIB_TSDEVICE")) != NULL ) { + ts = ts_open(tsdevice,0); + } else { #ifdef USE_INPUT_API - ts = ts_open("/dev/input/event0", 0); + ts = ts_open("/dev/input/event0", 0); #else - ts = ts_open("/dev/touchscreen/ucb1x00", 0); + ts = ts_open("/dev/touchscreen/ucb1x00", 0); #endif /* USE_INPUT_API */ + } if (!ts) { perror("ts_open"); diff --git a/tests/ts_test.c b/tests/ts_test.c index e168292..ecb536c 100644 --- a/tests/ts_test.c +++ b/tests/ts_test.c @@ -6,7 +6,7 @@ * This file is placed under the GPL. Please see the file * COPYING for more details. * - * $Id: ts_test.c,v 1.3 2002/06/17 17:21:43 dlowder Exp $ + * $Id: ts_test.c,v 1.4 2002/07/01 23:02:58 dlowder Exp $ * * Basic test program for touchscreen library. */ @@ -40,15 +40,21 @@ int main() struct tsdev *ts; int x, y; + char *tsdevice=NULL; + signal(SIGSEGV, sig); signal(SIGINT, sig); signal(SIGTERM, sig); + if( (tsdevice = getenv("TSLIB_TSDEVICE")) != NULL ) { + ts = ts_open(tsdevice,0); + } else { #ifdef USE_INPUT_API - ts = ts_open("/dev/input/event0", 0); + ts = ts_open("/dev/input/event0", 0); #else - ts = ts_open("/dev/touchscreen/ucb1x00", 0); + ts = ts_open("/dev/touchscreen/ucb1x00", 0); #endif /* USE_INPUT_API */ + } if (!ts) { perror("ts_open"); @@ -98,7 +104,7 @@ int main() printf("%ld.%06ld: %6d %6d %6d\n", samp.tv.tv_sec, samp.tv.tv_usec, samp.x, samp.y, samp.pressure); - if (samp.pressure > 100) { + if (samp.pressure > 0) { put_cross(x, y, 0); x = samp.x; y = samp.y; -- 2.11.0