diff -urN microwindows-0.90-atual/src/Configs/config.innovator microwindows-0.90-old2/src/Configs/config.innovator --- microwindows-0.90-atual/src/Configs/config.innovator 2003-05-15 03:38:24.000000000 +0300 +++ microwindows-0.90-old2/src/Configs/config.innovator 2004-04-29 00:00:20.000000000 +0300 @@ -326,13 +326,17 @@ YOPYMOUSE = N HARRIERMOUSE = N +# support to tune the touchscreen driver +TUNE_TOUCHSCREEN = Y + # keyboard or null kbd driver TTYKBD = N +INNKBD = Y SCANKBD = N PIPEKBD = N IPAQKBD = N LIRCKBD = N -NOKBD = Y +NOKBD = N endif diff -urN microwindows-0.90-atual/src/demos/nanox/Makefile microwindows-0.90-old2/src/demos/nanox/Makefile --- microwindows-0.90-atual/src/demos/nanox/Makefile 2003-05-11 20:01:57.000000000 +0300 +++ microwindows-0.90-old2/src/demos/nanox/Makefile 2004-04-28 22:09:13.000000000 +0300 @@ -14,7 +14,7 @@ ######################## Additional Flags section ############################ # Directories list for header files -INCLUDEDIRS += +INCLUDEDIRS += -I$(TOP)/drivers # Defines for preprocessor DEFINES += @@ -34,6 +34,26 @@ # If you want to create a library with the objects files, define the name here LIBNAME = +ifeq ($(ADSMOUSE), Y) +CFLAGS += -DTOUCHSCREEN_ADS=1 +endif + +ifeq ($(ADS7846MOUSE), Y) +CFLAGS += -DTOUCHSCREEN_ADS7846=1 +endif + +ifeq ($(IPAQMOUSE), Y) +CFLAGS += -DTOUCHSCREEN_IPAQ=1 +endif + +ifeq ($(TUXSCREENMOUSE), Y) +CFLAGS += -DTOUCHSCREEN_TUXSCREEN=1 +endif + +ifeq ($(ZAURUSMOUSE), Y) +CFLAGS += -DTOUCHSCREEN_ZAURUS=1 +endif + # List of objects to compile ifeq ($(ARCH), ECOS) OBJS = landmine.o netris.o world.o @@ -77,7 +97,8 @@ nxeyes.o \ tux.o \ nxcal.o \ - grabdemo.o + grabdemo.o \ + tuntouch.o TARGETS = \ $(TOP)/bin/demo $(TOP)/bin/move $(TOP)/bin/landmine \ @@ -95,7 +116,8 @@ $(TOP)/bin/convpbm \ $(TOP)/bin/nsaver \ $(TOP)/bin/nxcal \ - $(TOP)/bin/grabdemo + $(TOP)/bin/grabdemo \ + $(TOP)/bin/tuntouch ifneq ($(ARCH),CYGWIN) TARGETS += \ @@ -334,6 +356,10 @@ @echo "Linking $@ ..." $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LD_NANOXCLIENTLIBS) $(LIBM) +$(TOP)/bin/tuntouch: tuntouch.o $(NANOXCLIENTLIBS) $(TOP)/config + @echo "Linking $@ ..." + $(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDEDIRS) $< -o $@ $(LD_NANOXCLIENTLIBS) $(LIBM) + ifeq ($(ARCH), ECOS) # Special build rules for linked in applications $(TOP)/bin/landmine.o: landmine.o diff -urN microwindows-0.90-atual/src/demos/nanox/tuntouch.c microwindows-0.90-old2/src/demos/nanox/tuntouch.c --- microwindows-0.90-atual/src/demos/nanox/tuntouch.c 1970-01-01 03:00:00.000000000 +0300 +++ microwindows-0.90-old2/src/demos/nanox/tuntouch.c 2004-04-28 23:08:23.000000000 +0300 @@ -0,0 +1,154 @@ +/* + * Generic touchscreen tuning + * + * Copyright (c) 2004, 10LE Team/INdT. + * Written by David Cohen + * Based on touchsreen driver, by Jordan Crouse + */ + +/* The following devices are supported by this driver: + TOUCHSCREEN_ZAURUS - Sharp Zaurus S5500 + TOUCHSCREEN_IPAQ - Compaq Ipaq 3x00 + TOUCHSCREEN_TUXSCREEN - Shannon IS2630 + TOUCHSCREEN_ADS - Applied Data Systems Graphics Client+ devices + TOUCHSCREEN_ADS7846 - TI ADS6847 (PSI OMAP Innovator) +*/ + +#include +#include +#include +#include "device.h" + +#ifdef TOUCHSCREEN_ZAURUS +#include +#endif + +#ifdef TOUCHSCREEN_IPAQ +#include +#endif + +#ifdef TOUCHSCREEN_ADS +#include +#endif + +#ifdef TOUCHSCREEN_ADS7846 +#include +#endif + +#ifdef TOUCHSCREEN_TUXSCREEN +#include +#endif + +#ifndef TS_DEVICE +#error "You didn't define a device for the generic touchscreen driver!" +#endif + +#define MOVE_MAX 400 +#define TT_FILE "tuntouch.conf" + +int touch_dev = -1; + +int PD_Open(void) +{ + if((touch_dev = open(TS_DEVICE_FILE, O_NONBLOCK)) < 0) { + EPRINTF("Error %d opening %s touchscreen device [%s]\n", + errno, TS_DEVICE, TS_DEVICE_FILE); + return -1; + } + + return touch_dev; +} + +void PD_Close(void) +{ + /* Closing the touchscreen device. */ + if(touch_dev >= 0) + close(touch_dev); +} + +int PD_Read(MWCOORD *px, MWCOORD *py, MWCOORD *pz, int *pb, int mode) +{ + struct ts_event event; + int bytes_read; + + /* read a data point */ + bytes_read = read(touch_dev, &event, sizeof(event)); + + if(bytes_read != sizeof(event)) { + if(bytes_read == -1) { + if(errno == EINTR || errno == EAGAIN) return 0; + EPRINTF("[%s] Error %d reading from touch panel\n", TS_DEVICE, errno); + return -1; + } + + EPRINTF("[%s] Wrong number of bytes %d read from touch panel " + "(expected %d)\n", TS_DEVICE, bytes_read, sizeof(event)); + return 0; + } + *px = event.x; + *py = event.y; + + return 2; +} + +int main(void) +{ + FILE* f_tt; + + MWCOORD px, old_px, py, old_py, pz; + MWCOORD px_min, px_max, py_min, py_max; + int pb, mode; + int mmax; + + mmax = 0; + px = py = -1; + px_min = px_max = py_min = py_max = -1; + + if (PD_Open() < 0) + return -1; + + EPRINTF("This program captures %d events from touchscreen. Just move the pen from center towards left, right, up and down side of the touchscreen and it will get the max and min values of the x and y coodinates. If the program hasn't finished yet, just make any move with the pen on the touchscreen. Then, a file %s will be created with value min_x, max_x, min_y, max_y. The nano-X with support a TUNE_TOUCHSCREEN will read this file to fix the values sent by touchscreen and it will have the same resolution of the screen.\n:-)\n", MOVE_MAX, TT_FILE); + + /* Loop to read data from touchscreen */ + while (mmax < MOVE_MAX) + { + PD_Read(&px, &py, &pz, &pb, &mode); + + if ((old_px != px) || (old_py != py)) //if values changed + { + if (px_min < 0) + px_min = px; + else if ((px < px_min) && (px > 0)) + px_min = px; + else if (px > px_max) + px_max = px; + + if (py_min < 0) + py_min = py; + else if ((py < py_min) && (py > 0)) + py_min=py; + else if (py > py_max) + py_max = py; + + old_px = px; + old_py = py; + mmax++; + } + } + EPRINTF("The %s was created with values below:\nMin_X = %d\nMax_X = %d\nMin_Y = %d\nMax_Y = %d\n",TT_FILE,px_min,px_max,py_min,py_max); + PD_Close(); + + f_tt = fopen(TT_FILE, "w"); + if (f_tt == NULL) + { + EPRINTF("Error: Cannot open %s touchscreen tune file!\n", TT_FILE); + return -1; + } + + /* Writing data to the tune touchscreen's file */ + fprintf(f_tt, "%d\n%d\n%d\n%d", px_min, px_max, py_min, py_max); + + close(f_tt); + + return 0; +} diff -urN microwindows-0.90-atual/src/drivers/Makefile microwindows-0.90-old2/src/drivers/Makefile --- microwindows-0.90-atual/src/drivers/Makefile 2003-05-15 03:38:24.000000000 +0300 +++ microwindows-0.90-old2/src/drivers/Makefile 2004-04-28 22:23:39.000000000 +0300 @@ -143,6 +143,11 @@ OBJS += mou_touchscreen.o endif +### Tune touchscreen +ifeq ($(TUNE_TOUCHSCREEN), Y) +CFLAGS += -DTUNE_TOUCHSCREEN +endif + ### Embedded Planet touchscreen ifeq ($(EPMOUSE), Y) CFLAGS += -DTOUCHSCREEN_EPLANET @@ -196,6 +201,10 @@ OBJS += kbd_tty.o endif +ifeq ($(INNKBD), Y) +OBJS += kbd_inn.o +endif + ifeq ($(IPAQKBD), Y) OBJS += kbd_ipaq.o endif diff -urN microwindows-0.90-atual/src/drivers/kbd_inn.c microwindows-0.90-old2/src/drivers/kbd_inn.c --- microwindows-0.90-atual/src/drivers/kbd_inn.c 1970-01-01 03:00:00.000000000 +0300 +++ microwindows-0.90-old2/src/drivers/kbd_inn.c 2004-04-28 23:10:06.000000000 +0300 @@ -0,0 +1,144 @@ +/* + * Copyright (c) 1999 Greg Haerr + * Copyright (c) 1991 David I. Bell + * Permission is granted to use, distribute, or modify this source, + * provided that this copyright notice remains intact. + * + * Modified by David Cohen from tty kbd driver to + * support omap 1510 keypad. + * + * /dev/tty1 TTY Keyboard Driver + */ +#include +#include +#include +#include +#include +#include +#include "device.h" + +#define KEYBOARD "/dev/tty1" /* keyboard associated with screen*/ + +extern int escape_quits; + +static int TTY_Open(KBDDEVICE *pkd); +static void TTY_Close(void); +static void TTY_GetModifierInfo(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers); +static int TTY_Read(MWKEY *kbuf, MWKEYMOD *modifiers, MWSCANCODE *scancode); +static int TTY_Poll(void); + +KBDDEVICE kbddev = { + TTY_Open, + TTY_Close, + TTY_GetModifierInfo, + TTY_Read, +#if _MINIX + TTY_Poll +#else + NULL +#endif +}; + +static int fd; /* file descriptor for keyboard */ +static struct termios old; /* original terminal modes */ + +/* + * Open the keyboard. + * This is real simple, we just use a special file handle + * that allows non-blocking I/O, and put the terminal into + * character mode. + */ +static int +TTY_Open(KBDDEVICE *pkd) +{ + int i; + int ledstate = 0; + char * kbd; + struct termios new; + + /* Open "CONSOLE" or /dev/tty device*/ + if (!(kbd = getenv("CONSOLE"))) + kbd = KEYBOARD; + fd = open(kbd, O_NONBLOCK); + if (fd < 0) + return -1; + + if (tcgetattr(fd, &old) < 0) + goto err; + + new = old; + /* If you uncomment ISIG and BRKINT below, then ^C will be ignored.*/ + new.c_lflag &= ~(ECHO | ICANON | IEXTEN /*| ISIG*/); + new.c_iflag &= ~(ICRNL | INPCK | ISTRIP | IXON /*| BRKINT*/); + new.c_cflag &= ~(CSIZE | PARENB); + new.c_cflag |= CS8; + new.c_cc[VMIN] = 0; + new.c_cc[VTIME] = 0; + + if(tcsetattr(fd, TCSAFLUSH, &new) < 0) + goto err; + return fd; + +err: + close(fd); + fd = 0; + return -1; +} + +/* + * Close the keyboard. + * This resets the terminal modes. + */ +static void +TTY_Close(void) +{ + tcsetattr(fd, TCSANOW, &old); + close(fd); + fd = 0; +} + +/* + * Return the possible modifiers for the keyboard. + */ +static void +TTY_GetModifierInfo(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers) +{ + if (modifiers) + *modifiers = 0; /* no modifiers available */ + if (curmodifiers) + *curmodifiers = 0; +} + +/* + * This reads one keystroke from the keyboard, and the current state of + * the modifier keys (ALT, SHIFT, etc). Returns -1 on error, 0 if no data + * is ready, 1 on a keypress, and 2 on keyrelease. + * This is a non-blocking call. + */ +static int +TTY_Read(MWKEY *kbuf, MWKEYMOD *modifiers, MWSCANCODE *scancode) +{ + int cc; /* characters read */ + MWKEY mwkey; + unsigned char buf[1]; + + cc = read(fd, buf, 1); + if (cc > 0) { + mwkey = buf[0]; + *kbuf = mwkey; /* no translation*/ + *modifiers = 0; /* no modifiers*/ + *scancode = 0; /* no scancode*/ + return 1; /* keypress*/ + } + if ((cc < 0) && (errno != EINTR) && (errno != EAGAIN)) { + return -1; + } + EPRINTF("A tecla eh: %c\n", mwkey); + return 0; +} + +static int +TTY_Poll(void) +{ + return 1; /* used by _MINIX only*/ +} diff -urN microwindows-0.90-atual/src/drivers/mou_touchscreen.c microwindows-0.90-old2/src/drivers/mou_touchscreen.c --- microwindows-0.90-atual/src/drivers/mou_touchscreen.c 2003-05-15 03:38:24.000000000 +0300 +++ microwindows-0.90-old2/src/drivers/mou_touchscreen.c 2004-04-28 23:44:30.000000000 +0300 @@ -3,6 +3,7 @@ * * Copyright (c) 2003, Century Software, Inc. * Written by Jordan Crouse + * Modified by David Cohen */ /* The following devices are supported by this driver: @@ -19,11 +20,16 @@ add a new header file to drivers (touchscreen_zzz.h for example) */ +/* Modified by David Cohen to add suport to tunning the touchscreen, + when its resolution is not equal to the screen resolution. +*/ + #include #include #include #include #include "device.h" +#include "nano-X.h" #ifdef TOUCHSCREEN_ZAURUS #include "touchscreen_zaurus.h" @@ -50,7 +56,19 @@ #error "You didn't define a device for the generic touchscreen driver!" #endif +#ifdef TUNE_TOUCHSCREEN +#define TT_FILE "tuntouch.conf" +#endif + static int pd_fd = -1; + +#if defined(TUNE_TOUCHSCREEN) +static int min_x, min_y, max_x, max_y; +static float prop_x, prop_y; +char cmin_x[20], cmin_y[20], cmax_x[20], cmax_y[20]; +FILE* f_tt; +#endif + extern SCREENDEVICE scrdev; static int PD_Open(MOUSEDEVICE *pmd) @@ -60,7 +78,22 @@ errno, TS_DEVICE, TS_DEVICE_FILE); return -1; } +#if defined(TUNE_TOUCHSCREEN) + if((f_tt = fopen(TT_FILE, "r")) == NULL ) { + EPRINTF("Error. Can't open %s touchscreen tune file\n", + TT_FILE); + return -1; + } + fscanf(f_tt,"%s%s%s%s", cmin_x, cmax_x, cmin_y, cmax_y); + min_x = atoi(cmin_x); + max_x = atoi(cmax_x); + min_y = atoi(cmin_y); + max_y = atoi(cmax_y); + close(f_tt); + prop_x = ((float)(max_x - min_x)/(float) scrdev.xres); + prop_y = ((float)(max_y - min_y)/(float) scrdev.yres); +#endif GdHideCursor(&scrdev); return pd_fd; } @@ -106,9 +139,13 @@ "(expected %d)\n", TS_DEVICE, bytes_read, sizeof(event)); return 0; } - +#if defined(TUNE_TOUCHSCREEN) + *px = (short) (((float)event.x-min_x)/prop_x); + *py = (short) (((float)event.y-min_y)/prop_y); +#else *px = event.x; *py = event.y; +#endif #if defined(TOUCHSCREEN_IPAQ) || defined(TOUCHSCREEN_ADS7846) *pb = (event.pressure) ? MWBUTTON_L : 0;