nanogui: ts on ipaq and nxlib


Previous by date: 25 Aug 2004 15:21:47 +0100 Re: CVS finally back up, Steven Scholz
Next by date: 25 Aug 2004 15:21:47 +0100 Re: Rotated fonts on microwindows?, Steven Scholz
Previous in thread: 25 Aug 2004 15:21:47 +0100 Re: ts on ipaq and nxlib, Greg Haerr
Next in thread:

Subject: Re: [nanogui] ts on ipaq and nxlib
From: Hinko Kocevar ####@####.####
Date: 25 Aug 2004 15:21:47 +0100
Message-Id: <412CA078.40403@iskramedical.si>

Greg Haerr wrote:
...
> get brought into the server...  In any case, submit a patch that allows
> a nano-X server startup option to read a .dat file.  If the .dat file
> doesn't exist, the error will be ignored.  This still means that your
> system may have to have a shell script to determine whether
> to run nxcal or not...
> 

OK, here are two patches. Both add new command line option and call 
corresponding xxLoadTransformData() to get transform from the file. I 
also took liberty and added more comprehensive usage() at this point.

First patch (calib.diff) links nxtransform.o with nano-X server binary 
and uses GrLoadTransformData() to obtain transform.

Second patch (calib2.diff) provides srvutil.c with GsLoadTransformData() 
function (copy-paste of GrLoadTransformData() from nxtransform.c).

Only one patch is needed for desired functionality.

I prefer second one since we don't need to link whole nxtransform object 
file into the server, only needed function, but it kind-of duplicates 
code of that particular function.

Feel free to decide for yourself.

PS: now my touchscreen works in nano-X apps as well as in fltk app I 
fast-coded :)

regards,
h

-- 
hinko <dot> kocevar <at> iskramedical <dot> si
Hinko Kocevar, developer
Iskra Medical d.o.o., Stegne 23, 1k LJ, SLO-EU

	"Aì rén"	|	[Analects XII:22]

--- microwin/src/nanox/Makefile	2003-09-10 05:15:53.000000000 +0200
+++ ipaq-microwin/src/nanox/Makefile	2004-08-25 12:56:50.000000000 +0200
@@ -32,6 +32,7 @@
 	$(MW_DIR_OBJ)/nanox/srvfunc.o \
 	$(MW_DIR_OBJ)/nanox/srvutil.o \
 	$(MW_DIR_OBJ)/nanox/srvevent.o \
+	$(MW_DIR_OBJ)/nanox/nxtransform.o \
 	$(MW_DIR_OBJ)/nanox/srvclip.o
 
 # Nano-X client files
--- microwin/src/nanox/srvmain.c	2003-08-11 22:38:38.000000000 +0200
+++ ipaq-microwin/src/nanox/srvmain.c	2004-08-25 13:38:30.000000000 +0200
@@ -93,6 +93,7 @@
 int		autoportrait = FALSE;	/* auto portrait mode switching*/
 MWCOORD		nxres;			/* requested server x resolution*/
 MWCOORD		nyres;			/* requested server y resolution*/
+GR_TRANSFORM	trans;			/* mouse transform for ts pointer */
 
 #if MW_FEATURE_TIMERS
 GR_TIMEOUT	screensaver_delay;	/* time before screensaver activates */
@@ -113,8 +114,21 @@
 static void
 usage(void)
 {
-	printf("Usage: %s [-e] [-p] [-A] [-NLRD] [-x#] [-y#] [-c <fontconfig-file> ...]\n",
-		progname);
+	printf("Usage: %s [OPTIONS]...\n\n", progname);
+
+	printf("OPTIONS are:\n");
+	printf("\t-e\t\t\thitting ESC terminates nano server\n");
+	printf("\t-p\t\t\tdo not terminate nano server when last client exits\n");
+	printf("\t-A\t\t\tauto portrait mode switching\n");
+	printf("\t-N\t\t\tset screen portrait mode to NONE\n");
+	printf("\t-L\t\t\tset screen portrait mode to LEFT\n");
+	printf("\t-R\t\t\tset screen portrait mode to RIGHT\n");
+	printf("\t-D\t\t\tset screen portrait mode to DOWN\n");
+	printf("\t-x #\t\t\trequest server x resolution\n");
+	printf("\t-y #\t\t\trequest server y resolution\n");
+	printf("\t-C <fontconfig-file>\tfont configuration file\n");
+	printf("\t-d <calibration-file>\ttouchscreen calibration data file\n");
+
 	exit(1);
 }
 
@@ -180,6 +194,15 @@
 			++t;
 			continue;
 		}
+		if ( !strcmp("-d",argv[t]) ) {
+			if (++t >= argc)
+				usage();
+			int ret = GrLoadTransformData(argv[t], &trans);
+			if (!ret)
+				GrSetTransform(&trans);
+			++t;
+			continue;
+		}
 #if FONTMAPPER
 		if ( !strcmp("-c",argv[t]) ) {
 			int read_configfile(char *file);

--- microwin/src/nanox/srvutil.c	2003-05-11 19:14:54.000000000 +0200
+++ ipaq-microwin/src/nanox/srvutil.c	2004-08-25 12:17:00.000000000 +0200
@@ -9,6 +9,7 @@
  */
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #ifndef __PACIFIC__
 #include <fcntl.h>
@@ -1340,3 +1341,43 @@
 		GdMoveMouse(scrdev.xvirtres-5, rooty);
 	}
 }
+
+/*
+ * Get calibration data from file provided and store to
+ * glabal transform struct
+ */
+int
+GsLoadTransformData(char *filename, GR_TRANSFORM * trans)
+{
+	int ret = 0;
+	FILE *in = 0;
+
+	if (!trans)
+		return -1;
+	memset(trans, '\0', sizeof(GR_TRANSFORM));
+
+	in = fopen(filename, "r");
+	if (!in)
+		return -1;
+
+	while (!feof(in) && !ferror(in)) {
+		char buffer[128];
+		if (!fgets(buffer, sizeof(buffer) - 1, in))
+			continue;
+
+		if (buffer[0] == '#')
+			continue;
+
+		if (sscanf(buffer, "%d %d %d %d %d %d %d",
+			&trans->a, &trans->b, &trans->c,
+			&trans->d, &trans->e, &trans->f, &trans->s) == 7)
+			goto exit_load;
+	}
+
+	ret = -1;
+exit_load:
+
+	fclose(in);
+	return ret;
+}
+
--- microwin/src/nanox/srvmain.c	2003-08-11 22:38:38.000000000 +0200
+++ ipaq-microwin/src/nanox/srvmain.c	2004-08-25 13:38:30.000000000 +0200
@@ -93,6 +93,7 @@
 int		autoportrait = FALSE;	/* auto portrait mode switching*/
 MWCOORD		nxres;			/* requested server x resolution*/
 MWCOORD		nyres;			/* requested server y resolution*/
+GR_TRANSFORM	trans;			/* mouse transform for ts pointer */
 
 #if MW_FEATURE_TIMERS
 GR_TIMEOUT	screensaver_delay;	/* time before screensaver activates */
@@ -113,8 +114,21 @@
 static void
 usage(void)
 {
-	printf("Usage: %s [-e] [-p] [-A] [-NLRD] [-x#] [-y#] [-c <fontconfig-file> ...]\n",
-		progname);
+	printf("Usage: %s [OPTIONS]...\n\n", progname);
+
+	printf("OPTIONS are:\n");
+	printf("\t-e\t\t\thitting ESC terminates nano server\n");
+	printf("\t-p\t\t\tdo not terminate nano server when last client exits\n");
+	printf("\t-A\t\t\tauto portrait mode switching\n");
+	printf("\t-N\t\t\tset screen portrait mode to NONE\n");
+	printf("\t-L\t\t\tset screen portrait mode to LEFT\n");
+	printf("\t-R\t\t\tset screen portrait mode to RIGHT\n");
+	printf("\t-D\t\t\tset screen portrait mode to DOWN\n");
+	printf("\t-x #\t\t\trequest server x resolution\n");
+	printf("\t-y #\t\t\trequest server y resolution\n");
+	printf("\t-C <fontconfig-file>\tfont configuration file\n");
+	printf("\t-d <calibration-file>\ttouchscreen calibration data file\n");
+
 	exit(1);
 }
 
@@ -180,6 +194,15 @@
 			++t;
 			continue;
 		}
+		if ( !strcmp("-d",argv[t]) ) {
+			if (++t >= argc)
+				usage();
+			int ret = GsLoadTransformData(argv[t], &trans);
+			if (!ret)
+				GrSetTransform(&trans);
+			++t;
+			continue;
+		}
 #if FONTMAPPER
 		if ( !strcmp("-c",argv[t]) ) {
 			int read_configfile(char *file);
--- test-microwin/src/nanox/serv.h	2003-05-18 07:58:50.000000000 +0200
+++ ipaq-microwin/src/nanox/serv.h	2004-08-25 12:15:59.000000000 +0200
@@ -506,6 +506,7 @@
 void		GsResetScreenSaver(void);
 void		GsActivateScreenSaver(void *arg);
 void		GrGetNextEventWrapperFinish(int);
+int		GsLoadTransformData(char *filename, GR_TRANSFORM * trans);
 
 /*
  * External data definitions.

Previous by date: 25 Aug 2004 15:21:47 +0100 Re: CVS finally back up, Steven Scholz
Next by date: 25 Aug 2004 15:21:47 +0100 Re: Rotated fonts on microwindows?, Steven Scholz
Previous in thread: 25 Aug 2004 15:21:47 +0100 Re: ts on ipaq and nxlib, Greg Haerr
Next in thread:


Powered by ezmlm-browse 0.20.