Subject:
Re: [nanogui] Touchscreen
From:
"ing. Davide Rizzo" ####@####.####
Date:
27 Mar 2008 14:43:26 -0000
Message-Id: <47EBB28E.6050603@elpa.it>
Hi Greg,
I appreciate very much nano-X and nxlib. Currently I'm using them with
fltk 1.1.7.
Until now I used it on my Linux-ARM embedded system, with h3600-tsraw
touchscreen driver.
Unfortunately from linux kernel 2.6.24 that driver disappeared.
I added one driver to microwindows to use /dev/input/event0 standard
interface. I tested also with nxcal, it seems to work.
This should enable nano-X to work with various standard touchscreen drivers.
I enclose my patch to add that driver, plus some minor bug corrections
(I think).
I enclose also a very small nxlib patch that corrects an obsoleted
include and disables an annoying debug print (never used a FLTK clock
widget ?)
These patches have been generated with diff related to your actual cvs
version.
Please let me know if they can be useful.
Note: if you cannot reach the included patches, you can download them
from: http://www.elpa.it/eng/rd129.html
Question: Is it possible to use Fltk+Nxlib+NanoX with
linked-app-into-server option ? I tried, but without success.
Regards
Davide Rizzo - ELPA sas
diff -urN microwindows-080127/src/config microwindows-080127.elpa/src/config
--- microwindows-080127/src/config 2008-01-07 00:15:02.000000000 +0100
+++ microwindows-080127.elpa/src/config 2008-02-06 16:10:40.000000000 +0100
@@ -310,6 +310,7 @@
# NOMOUSE no mouse driver
#
# Touchscreen drivers
+# EVENTMOUSE Standard event interface (/dev/input/event0)
# IPAQMOUSE Compaq iPAQ, Intel Assabet (/dev/h3600_tsraw)
# ZAURUSMOUSE Sharp Zaurus (/dev/sharp_ts)
# TUXMOUSE TuxScreen (/dev/ucb1x00-ts)
@@ -323,9 +324,10 @@
# HARRIERMOUSE NEC Harrier (/dev/tpanel)
####################################################################
GPMMOUSE = N
-SERMOUSE = Y
+SERMOUSE = N
SUNMOUSE = N
NOMOUSE = N
+EVENTMOUSE = Y
IPAQMOUSE = N
ZAURUSMOUSE = N
TUXMOUSE = N
diff -urN microwindows-080127/src/demos/mwin/mine.c microwindows-080127.elpa/src/demos/mwin/mine.c
--- microwindows-080127/src/demos/mwin/mine.c 2005-06-17 01:42:11.000000000 +0200
+++ microwindows-080127.elpa/src/demos/mwin/mine.c 2008-02-04 14:01:23.000000000 +0100
@@ -16,6 +16,7 @@
#define MWINCLUDECOLORS
#include "windows.h"
#include "wintools.h"
+#include "wintern.h"
typedef struct {
int flag;
@@ -1049,6 +1050,7 @@
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nShowCmd)
{
+ MwSetTextCoding ( MWTF_ASCII );
TestMyWindow (NULL);
return 0;
}
diff -urN microwindows-080127/src/demos/nxroach/Makefile microwindows-080127.elpa/src/demos/nxroach/Makefile
--- microwindows-080127/src/demos/nxroach/Makefile 2003-09-25 04:15:01.000000000 +0200
+++ microwindows-080127.elpa/src/demos/nxroach/Makefile 2008-02-04 14:01:23.000000000 +0100
@@ -49,9 +49,9 @@
ifeq ($(SHAREDLIBS), Y)
$(MW_DIR_BIN)/nxroach: $(OBJS) $(NANOXCLIENTLIBS) $(CONFIG)
@echo "Linking $(patsubst $(MW_DIR_BIN)/%,%,$@) ..."
- $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(CCNANOXCLIENTLIBS)
+ $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $@ $(CCNANOXCLIENTLIBS)
else
$(MW_DIR_BIN)/nxroach: $(OBJS) $(NANOXCLIENTLIBS) $(CONFIG)
@echo "Linking $(patsubst $(MW_DIR_BIN)/%,%,$@) ..."
- $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(NANOXCLIENTLIBS)
+ $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $@ $(NANOXCLIENTLIBS)
endif
diff -urN microwindows-080127/src/drivers/mou_event.c microwindows-080127.elpa/src/drivers/mou_event.c
--- microwindows-080127/src/drivers/mou_event.c 1970-01-01 01:00:00.000000000 +0100
+++ microwindows-080127.elpa/src/drivers/mou_event.c 2008-02-06 16:04:59.000000000 +0100
@@ -0,0 +1,110 @@
+/*
+ * Generic event touchscreen driver
+ *
+ * Copyright (c) 2008, ELPA sas
+ * Written by Davide Rizzo ####@####.####
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include "device.h"
+
+#define TS_DEVICE "/dev/input/event0"
+
+extern SCREENDEVICE scrdev;
+static int pd_fd = -1;
+
+static int PD_Open(MOUSEDEVICE *pmd)
+{
+ if((pd_fd = open(TS_DEVICE, O_NONBLOCK)) < 0)
+ {
+ EPRINTF("[%s] Error %d opening %s\n", TS_DEVICE, errno, TS_DEVICE);
+ return -1;
+ }
+ GdHideCursor(&scrdev);
+ return pd_fd;
+}
+
+static void PD_Close(void)
+{
+ if(pd_fd < 0)
+ return;
+ close(pd_fd);
+ pd_fd = -1;
+}
+
+static int PD_GetButtonInfo(void)
+{
+ /* get "mouse" buttons supported */
+ return MWBUTTON_L;
+}
+
+static void PD_GetDefaultAccel(int *pscale,int *pthresh)
+{
+ *pscale = 3;
+ *pthresh = 5;
+}
+
+static int PD_Read(MWCOORD *px, MWCOORD *py, MWCOORD *pz, int *pb)
+{
+ struct input_event event;
+ int bytes_read;
+ static int x,y,z;
+ /* read a data point */
+ while( (bytes_read = read(pd_fd, &event, sizeof(event))) == sizeof(event) )
+ {
+ switch(event.type)
+ {
+ case EV_ABS:
+ switch(event.code)
+ {
+ case ABS_X:
+ x=event.value;
+ break;
+ case ABS_Y:
+ y=event.value;
+ break;
+ }
+ break;
+ case EV_KEY:
+ if(event.code==BTN_TOUCH)
+ z=event.value;
+ break;
+ case EV_SYN:
+ *px=x;
+ *py=y;
+ *pb = z ? MWBUTTON_L : 0;
+ *pz = z;
+ if(!*pb)
+ return 3;
+ return 2;
+ break;
+ }
+ }
+ 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;
+ }
+ if(bytes_read != 0)
+ {
+ EPRINTF("[%s] Wrong number of bytes %d read from touch panel "
+ "(expected %d)\n", TS_DEVICE, bytes_read, sizeof(event));
+ return -1;
+ }
+ return 0;
+}
+
+MOUSEDEVICE mousedev = {
+ PD_Open,
+ PD_Close,
+ PD_GetButtonInfo,
+ PD_GetDefaultAccel,
+ PD_Read,
+ NULL,
+ MOUSE_TRANSFORM /* Input filter flags */
+};
diff -urN microwindows-080127/src/drivers/Objects.rules microwindows-080127.elpa/src/drivers/Objects.rules
--- microwindows-080127/src/drivers/Objects.rules 2005-06-15 18:38:19.000000000 +0200
+++ microwindows-080127.elpa/src/drivers/Objects.rules 2008-02-04 15:23:09.000000000 +0100
@@ -170,6 +170,11 @@
MW_CORE_OBJS += $(MW_DIR_OBJ)/drivers/mou_touchscreen.o
endif
+ifeq ($(EVENTMOUSE), Y)
+CFLAGS += -DTOUCHSCREEN_EVENT=1
+MW_CORE_OBJS += $(MW_DIR_OBJ)/drivers/mou_event.o
+endif
+
ifeq ($(IPAQMOUSE), Y)
CFLAGS += -DTOUCHSCREEN_IPAQ=1
MW_CORE_OBJS += $(MW_DIR_OBJ)/drivers/mou_touchscreen.o
diff -urN microwindows-080127/src/engine/devmouse.c microwindows-080127.elpa/src/engine/devmouse.c
--- microwindows-080127/src/engine/devmouse.c 2005-06-23 07:00:00.000000000 +0200
+++ microwindows-080127.elpa/src/engine/devmouse.c 2008-02-06 16:40:36.000000000 +0100
@@ -636,7 +636,7 @@
break;
case MWPORTRAIT_DOWN:
- *xpos = x;
+ *xpos = scrdev.xres - x - 1;
*ypos = scrdev.yres - y - 1;
break;
diff -urN microwindows-080127/src/mwin/winevent.c microwindows-080127.elpa/src/mwin/winevent.c
--- microwindows-080127/src/mwin/winevent.c 2005-06-23 07:00:00.000000000 +0200
+++ microwindows-080127.elpa/src/mwin/winevent.c 2008-02-04 14:01:23.000000000 +0100
@@ -19,7 +19,7 @@
static LPFN_KEYBTRANSLATE mwPtrKeyboardTranslator = NULL;
-#if !(DOS_TURBOC | DOS_QUICKC | _MINIX | VXWORKS)
+#if !(DOS_TURBOC | DOS_QUICKC | _MINIX | VXWORKS | LINUX)
static int
abs(int n)
{
diff -urN nxlib-071231/FillPolygon.c nxlib-071231.elpa/FillPolygon.c
--- nxlib-071231/FillPolygon.c 2002-08-14 03:37:47.000000000 +0200
+++ nxlib-071231.elpa/FillPolygon.c 2007-12-31 14:58:59.000000000 +0100
@@ -27,8 +27,8 @@
}
}
- if (shape == Complex || shape == Convex)
- printf("XFillPolygon: Complex/Convex\n");
+// if (shape == Complex || shape == Convex)
+// printf("XFillPolygon: Complex/Convex\n");
GrFillPoly(d, gc->gid, npoints, gr_points);
diff -urN nxlib-071231/Xlcint.h nxlib-071231.elpa/Xlcint.h
--- nxlib-071231/Xlcint.h 2003-08-11 22:17:56.000000000 +0200
+++ nxlib-071231.elpa/Xlcint.h 2007-12-31 15:26:51.000000000 +0100
@@ -71,7 +71,7 @@
#include "Xresource.h"
#include "Xutil.h"
/*#include "Xvarargs.h"*/
-#include "varargs.h"
+#include "stdarg.h"
typedef Bool (*XFilterEventProc)(
#if NeedFunctionPrototypes