Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/sbin/wsconsctl Pull up following revision(s) (requested b...
details: https://anonhg.NetBSD.org/src/rev/6177845b82c7
branches: netbsd-6
changeset: 775678:6177845b82c7
user: riz <riz%NetBSD.org@localhost>
date: Mon Feb 11 21:36:30 2013 +0000
description:
Pull up following revision(s) (requested by khorben in ticket #814):
sbin/wsconsctl/wsconsctl.h: revision 1.12
sbin/wsconsctl/mouse.c: revision 1.9
sbin/wsconsctl/mouse.c: revision 1.10
sbin/wsconsctl/util.c: revision 1.31
Added a field type for signed integers. This is required when handling
touchscreen calibration values, which is about to be implemented in
wsconsctl (see PR kern/45872).
Reviewed by uwe@ (thank you!)
Added a field type for signed integers. This is required when handling
touchscreen calibration values, which is about to be implemented in
wsconsctl (see PR kern/45872).
Reviewed by uwe@ (thank you!)
Added read-only support for touchscreen calibration (see PR kern/45872).
Tested with the uts(4) driver, as well as with mice without calibration
support.
Reviewed by uwe@ (thank you!)
Added complete support for touchscreen calibration (see PR kern/45872).
Tested with the uts(4) driver, as well as with mice without calibration
support.
Reviewed by uwe@ (thank you!)
diffstat:
sbin/wsconsctl/mouse.c | 155 +++++++++++++++++++++++++++++++++++++++++++-
sbin/wsconsctl/util.c | 15 +++-
sbin/wsconsctl/wsconsctl.h | 5 +-
3 files changed, 166 insertions(+), 9 deletions(-)
diffs (283 lines):
diff -r 4f633a8ff833 -r 6177845b82c7 sbin/wsconsctl/mouse.c
--- a/sbin/wsconsctl/mouse.c Mon Feb 11 21:07:54 2013 +0000
+++ b/sbin/wsconsctl/mouse.c Mon Feb 11 21:36:30 2013 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: mouse.c,v 1.8 2008/04/28 20:23:09 martin Exp $ */
+/* $NetBSD: mouse.c,v 1.8.22.1 2013/02/11 21:36:30 riz Exp $ */
/*-
- * Copyright (c) 1998, 2006 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2006, 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -45,8 +45,13 @@
static int mstype;
static int resolution;
static int samplerate;
+static struct wsmouse_calibcoords calibration;
+static char *calibration_samples;
static struct wsmouse_repeat repeat;
+static void mouse_get_calibration(int);
+static void mouse_put_calibration(int);
+
static void mouse_get_repeat(int);
static void mouse_put_repeat(int);
@@ -54,6 +59,16 @@
{ "resolution", &resolution, FMT_UINT, FLG_WRONLY },
{ "samplerate", &samplerate, FMT_UINT, FLG_WRONLY },
{ "type", &mstype, FMT_MSTYPE, FLG_RDONLY },
+ { "calibration.minx", &calibration.minx,
+ FMT_INT, FLG_MODIFY },
+ { "calibration.miny", &calibration.miny,
+ FMT_INT, FLG_MODIFY },
+ { "calibration.maxx", &calibration.maxx,
+ FMT_INT, FLG_MODIFY },
+ { "calibration.maxy", &calibration.maxy,
+ FMT_INT, FLG_MODIFY },
+ { "calibration.samples", &calibration_samples,
+ FMT_STRING, FLG_MODIFY },
{ "repeat.buttons", &repeat.wr_buttons,
FMT_BITFIELD, FLG_MODIFY },
{ "repeat.delay.first", &repeat.wr_delay_first,
@@ -75,6 +90,13 @@
if (ioctl(fd, WSMOUSEIO_GTYPE, &mstype) < 0)
err(EXIT_FAILURE, "WSMOUSEIO_GTYPE");
+ if (field_by_value(&calibration.minx)->flags & FLG_GET ||
+ field_by_value(&calibration.miny)->flags & FLG_GET ||
+ field_by_value(&calibration.maxx)->flags & FLG_GET ||
+ field_by_value(&calibration.maxy)->flags & FLG_GET ||
+ field_by_value(&calibration_samples)->flags & FLG_GET)
+ mouse_get_calibration(fd);
+
if (field_by_value(&repeat.wr_buttons)->flags & FLG_GET ||
field_by_value(&repeat.wr_delay_first)->flags & FLG_GET ||
field_by_value(&repeat.wr_delay_decrement)->flags & FLG_GET ||
@@ -83,11 +105,63 @@
}
static void
+mouse_get_calibration(int fd)
+{
+ struct wsmouse_calibcoords tmp;
+ char *samples;
+ char buf[48];
+ int i;
+
+ if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &tmp) < 0) {
+ field_disable_by_value(&calibration.minx);
+ field_disable_by_value(&calibration.miny);
+ field_disable_by_value(&calibration.maxx);
+ field_disable_by_value(&calibration.maxy);
+ field_disable_by_value(&calibration_samples);
+ return;
+ }
+
+ if (field_by_value(&calibration.minx)->flags & FLG_GET)
+ calibration.minx = tmp.minx;
+ if (field_by_value(&calibration.miny)->flags & FLG_GET)
+ calibration.miny = tmp.miny;
+ if (field_by_value(&calibration.maxx)->flags & FLG_GET)
+ calibration.maxx = tmp.maxx;
+ if (field_by_value(&calibration.maxy)->flags & FLG_GET)
+ calibration.maxy = tmp.maxy;
+ if (field_by_value(&calibration_samples)->flags & FLG_GET) {
+ free(calibration_samples);
+ if (tmp.samplelen <= 0) {
+ calibration_samples = strdup("");
+ if (calibration_samples == NULL)
+ err(EXIT_FAILURE, "could not list calibration"
+ " samples");
+ } else {
+ samples = malloc(tmp.samplelen * sizeof(buf));
+ if (samples == NULL)
+ err(EXIT_FAILURE, "could not list calibration"
+ " samples");
+ samples[0] = '\0';
+ for (i = 0; i < tmp.samplelen; i++) {
+ snprintf(buf, sizeof(buf), "%s%d,%d,%d,%d",
+ (i == 0) ? "" : ":",
+ tmp.samples[i].rawx,
+ tmp.samples[i].rawy,
+ tmp.samples[i].x,
+ tmp.samples[i].y);
+ strcat(samples, buf);
+ }
+ calibration_samples = samples;
+ }
+ }
+}
+
+static void
mouse_get_repeat(int fd)
{
struct wsmouse_repeat tmp;
- if (ioctl(fd, WSMOUSEIO_GETREPEAT, &tmp) == -1)
+ if (ioctl(fd, WSMOUSEIO_GETREPEAT, &tmp) < 0)
err(EXIT_FAILURE, "WSMOUSEIO_GETREPEAT");
if (field_by_value(&repeat.wr_buttons)->flags & FLG_GET)
@@ -119,6 +193,13 @@
pr_field(field_by_value(&samplerate), " -> ");
}
+ if (field_by_value(&calibration.minx)->flags & FLG_SET ||
+ field_by_value(&calibration.miny)->flags & FLG_SET ||
+ field_by_value(&calibration.maxx)->flags & FLG_SET ||
+ field_by_value(&calibration.maxy)->flags & FLG_SET ||
+ field_by_value(&calibration_samples)->flags & FLG_SET)
+ mouse_put_calibration(fd);
+
if (field_by_value(&repeat.wr_buttons)->flags & FLG_SET ||
field_by_value(&repeat.wr_delay_first)->flags & FLG_SET ||
field_by_value(&repeat.wr_delay_decrement)->flags & FLG_SET ||
@@ -127,12 +208,76 @@
}
static void
+mouse_put_calibration(int fd)
+{
+ struct wsmouse_calibcoords tmp;
+ int i;
+ const char *p;
+ char *q;
+
+ /* Fetch current values into the temporary structure. */
+ if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &tmp) < 0)
+ err(EXIT_FAILURE, "WSMOUSEIO_GCALIBCOORDS");
+
+ /* Overwrite the desired values in the temporary structure. */
+ if (field_by_value(&calibration.minx)->flags & FLG_SET)
+ tmp.minx = calibration.minx;
+ if (field_by_value(&calibration.miny)->flags & FLG_SET)
+ tmp.miny = calibration.miny;
+ if (field_by_value(&calibration.maxx)->flags & FLG_SET)
+ tmp.maxx = calibration.maxx;
+ if (field_by_value(&calibration.maxy)->flags & FLG_SET)
+ tmp.maxy = calibration.maxy;
+ if (field_by_value(&calibration_samples)->flags & FLG_SET) {
+ p = calibration_samples;
+ for (i = 0; p[0] != '\0' && i < WSMOUSE_CALIBCOORDS_MAX; i++) {
+ tmp.samples[i].rawx = strtol(p, &q, 0);
+ if (*q != ',')
+ break;
+ p = q + 1;
+ tmp.samples[i].rawy = strtol(p, &q, 0);
+ if (*q != ',')
+ break;
+ p = q + 1;
+ tmp.samples[i].x = strtol(p, &q, 0);
+ if (*q != ',')
+ break;
+ p = q + 1;
+ tmp.samples[i].y = strtol(p, &q, 0);
+ p = q + 1;
+ if (*q != '\0' && *q != ':')
+ break;
+ }
+ if (p[0] != '\0')
+ errx(EXIT_FAILURE, "%s: invalid calibration data",
+ calibration_samples);
+ tmp.samplelen = i;
+ }
+
+ /* Set new values for calibrating events. */
+ if (ioctl(fd, WSMOUSEIO_SCALIBCOORDS, &tmp) < 0)
+ err(EXIT_FAILURE, "WSMOUSEIO_SCALIBCOORDS");
+
+ /* Now print what changed. */
+ if (field_by_value(&calibration.minx)->flags & FLG_SET)
+ pr_field(field_by_value(&calibration.minx), " -> ");
+ if (field_by_value(&calibration.miny)->flags & FLG_SET)
+ pr_field(field_by_value(&calibration.miny), " -> ");
+ if (field_by_value(&calibration.maxx)->flags & FLG_SET)
+ pr_field(field_by_value(&calibration.maxx), " -> ");
+ if (field_by_value(&calibration.maxy)->flags & FLG_SET)
+ pr_field(field_by_value(&calibration.maxy), " -> ");
+ if (field_by_value(&calibration_samples)->flags & FLG_SET)
+ pr_field(field_by_value(&calibration_samples), " -> ");
+}
+
+static void
mouse_put_repeat(int fd)
{
struct wsmouse_repeat tmp;
/* Fetch current values into the temporary structure. */
- if (ioctl(fd, WSMOUSEIO_GETREPEAT, &tmp) == -1)
+ if (ioctl(fd, WSMOUSEIO_GETREPEAT, &tmp) < 0)
err(EXIT_FAILURE, "WSMOUSEIO_GETREPEAT");
/* Overwrite the desired values in the temporary structure. */
@@ -146,7 +291,7 @@
tmp.wr_delay_minimum = repeat.wr_delay_minimum;
/* Set new values for repeating events. */
- if (ioctl(fd, WSMOUSEIO_SETREPEAT, &tmp) == -1)
+ if (ioctl(fd, WSMOUSEIO_SETREPEAT, &tmp) < 0)
err(EXIT_FAILURE, "WSMOUSEIO_SETREPEAT");
/* Now print what changed. */
diff -r 4f633a8ff833 -r 6177845b82c7 sbin/wsconsctl/util.c
--- a/sbin/wsconsctl/util.c Mon Feb 11 21:07:54 2013 +0000
+++ b/sbin/wsconsctl/util.c Mon Feb 11 21:36:30 2013 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: util.c,v 1.30 2011/12/15 14:25:12 phx Exp $ */
+/* $NetBSD: util.c,v 1.30.2.1 2013/02/11 21:36:30 riz Exp $ */
/*-
- * Copyright (c) 1998, 2006 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2006, 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -257,6 +257,9 @@
case FMT_UINT:
(void)printf("%u", *((unsigned int *) f->valp));
break;
+ case FMT_INT:
+ (void)printf("%d", *((int *) f->valp));
+ break;
case FMT_STRING:
(void)printf("\"%s\"", *((char **) f->valp));
break;
@@ -361,6 +364,14 @@
else
*((unsigned int *) f->valp) = u;
break;
+ case FMT_INT:
+ if (sscanf(val, "%d", &i) != 1)
+ errx(EXIT_FAILURE, "%s: not a number", val);
+ if (merge)
+ *((int *) f->valp) += i;
+ else
+ *((int *) f->valp) = i;
+ break;
case FMT_STRING:
if ((*((char **) f->valp) = strdup(val)) == NULL)
err(EXIT_FAILURE, "strdup");
diff -r 4f633a8ff833 -r 6177845b82c7 sbin/wsconsctl/wsconsctl.h
--- a/sbin/wsconsctl/wsconsctl.h Mon Feb 11 21:07:54 2013 +0000
+++ b/sbin/wsconsctl/wsconsctl.h Mon Feb 11 21:36:30 2013 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: wsconsctl.h,v 1.11 2011/08/27 19:01:34 joerg Exp $ */
+/* $NetBSD: wsconsctl.h,v 1.11.4.1 2013/02/11 21:36:30 riz Exp $ */
/*-
- * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2004, 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -55,6 +55,7 @@
#define FMT_UINT 1 /* unsigned integer */
#define FMT_STRING 2 /* zero terminated string */
#define FMT_BITFIELD 3 /* bit field */
+#define FMT_INT 4 /* signed integer */
#define FMT_KBDTYPE 101 /* keyboard type */
#define FMT_MSTYPE 102 /* mouse type */
#define FMT_DPYTYPE 103 /* display type */
Home |
Main Index |
Thread Index |
Old Index