Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/wsmoused wsmoused: support absolute mouse position ...
details: https://anonhg.NetBSD.org/src/rev/288a86f5ea25
branches: trunk
changeset: 1026422:288a86f5ea25
user: uwe <uwe%NetBSD.org@localhost>
date: Wed Nov 24 14:34:51 2021 +0000
description:
wsmoused: support absolute mouse position events
Tested with VirtualBox Guest Addtions.
diffstat:
usr.sbin/wsmoused/selection.c | 30 +++++++++++++++++++++++++++---
usr.sbin/wsmoused/wsmoused.c | 36 ++++++++++++++++++++++++++++++++----
usr.sbin/wsmoused/wsmoused.h | 14 ++++++++++++--
3 files changed, 71 insertions(+), 9 deletions(-)
diffs (160 lines):
diff -r c84a3e929e30 -r 288a86f5ea25 usr.sbin/wsmoused/selection.c
--- a/usr.sbin/wsmoused/selection.c Wed Nov 24 10:01:24 2021 +0000
+++ b/usr.sbin/wsmoused/selection.c Wed Nov 24 14:34:51 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: selection.c,v 1.10 2007/05/27 15:05:00 jmmv Exp $ */
+/* $NetBSD: selection.c,v 1.11 2021/11/24 14:34:51 uwe Exp $ */
/*
* Copyright (c) 2002, 2003, 2004, 2007 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: selection.c,v 1.10 2007/05/27 15:05:00 jmmv Exp $");
+__RCSID("$NetBSD: selection.c,v 1.11 2021/11/24 14:34:51 uwe Exp $");
#endif /* not lint */
#include <sys/ioctl.h>
@@ -226,6 +226,7 @@
void
selection_wsmouse_event(struct wscons_event evt)
{
+ const struct wsmouse_calibcoords *abs = &Selmouse.sm_mouse->m_calib;
if (IS_MOTION_EVENT(evt.type)) {
if (Selmouse.sm_selecting)
@@ -259,7 +260,30 @@
Selmouse.sm_count_y++;
break;
- case WSCONS_EVENT_MOUSE_DELTA_Z:
+ case WSCONS_EVENT_MOUSE_DELTA_Z: /* FALLTHROUGH */
+ case WSCONS_EVENT_MOUSE_DELTA_W:
+ break;
+
+ case WSCONS_EVENT_MOUSE_ABSOLUTE_X:
+ if (!Selmouse.sm_mouse->m_doabs)
+ break;
+ /* max x is inclusive in both selmouse and tpcalib */
+ Selmouse.sm_x
+ = ((evt.value - abs->minx) * (Selmouse.sm_max_x + 1))
+ / (abs->maxx - abs->minx + 1);
+ break;
+
+ case WSCONS_EVENT_MOUSE_ABSOLUTE_Y:
+ if (!Selmouse.sm_mouse->m_doabs)
+ break;
+ /* max y is inclusive in both selmouse and tpcalib */
+ Selmouse.sm_y
+ = ((evt.value - abs->miny) * (Selmouse.sm_max_y + 1))
+ / (abs->maxy - abs->miny + 1);
+ break;
+
+ case WSCONS_EVENT_MOUSE_ABSOLUTE_Z: /* FALLTHROUGH */
+ case WSCONS_EVENT_MOUSE_ABSOLUTE_W:
break;
default:
diff -r c84a3e929e30 -r 288a86f5ea25 usr.sbin/wsmoused/wsmoused.c
--- a/usr.sbin/wsmoused/wsmoused.c Wed Nov 24 10:01:24 2021 +0000
+++ b/usr.sbin/wsmoused/wsmoused.c Wed Nov 24 14:34:51 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsmoused.c,v 1.27 2021/09/01 06:10:06 mlelstv Exp $ */
+/* $NetBSD: wsmoused.c,v 1.28 2021/11/24 14:34:51 uwe Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 2002, 2003\
The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: wsmoused.c,v 1.27 2021/09/01 06:10:06 mlelstv Exp $");
+__RCSID("$NetBSD: wsmoused.c,v 1.28 2021/11/24 14:34:51 uwe Exp $");
#endif /* not lint */
#include <sys/ioctl.h>
@@ -250,7 +250,7 @@
static void
open_device(unsigned int secs)
{
- int version = WSMOUSE_EVENT_VERSION;
+ int status;
if (Mouse.m_devfd != -1)
return;
@@ -262,10 +262,38 @@
if (Mouse.m_devfd == -1)
log_err(EXIT_FAILURE, "cannot open %s", Mouse.m_devname);
- if (ioctl(Mouse.m_devfd, WSMOUSEIO_SETVERSION, &version) == -1)
+ const int version = WSMOUSE_EVENT_VERSION;
+ status = ioctl(Mouse.m_devfd, WSMOUSEIO_SETVERSION, &version);
+ if (status == -1)
log_err(EXIT_FAILURE, "cannot set version %s", Mouse.m_devname);
+
+
+ /*
+ * Get calibration data for touch panel. Not fatal if we can't.
+ */
+ Mouse.m_doabs = 0;
+
+ unsigned int mouse_type = 0; /* defined WSMOUSE_TYPE_* start at 1 */
+ status = ioctl(Mouse.m_devfd, WSMOUSEIO_GTYPE, &mouse_type);
+ if (status == -1) {
+ log_warn("WSMOUSEIO_GTYPE");
+ return;
+ }
+
+ /* absolute position events make no sense for free-ranging mice */
+ if (mouse_type != WSMOUSE_TYPE_TPANEL)
+ return;
+
+ status = ioctl(Mouse.m_devfd, WSMOUSEIO_GCALIBCOORDS, &Mouse.m_calib);
+ if (status == -1) {
+ log_warn("WSMOUSEIO_GCALIBCOORDS");
+ return;
+ }
+
+ Mouse.m_doabs = 1;
}
+
/* --------------------------------------------------------------------- */
/* Main program event loop. This function polls the wscons status
diff -r c84a3e929e30 -r 288a86f5ea25 usr.sbin/wsmoused/wsmoused.h
--- a/usr.sbin/wsmoused/wsmoused.h Wed Nov 24 10:01:24 2021 +0000
+++ b/usr.sbin/wsmoused/wsmoused.h Wed Nov 24 14:34:51 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsmoused.h,v 1.9 2006/03/18 02:06:38 elad Exp $ */
+/* $NetBSD: wsmoused.h,v 1.10 2021/11/24 14:34:51 uwe Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 The NetBSD Foundation, Inc.
@@ -34,7 +34,13 @@
#define IS_MOTION_EVENT(type) (((type) == WSCONS_EVENT_MOUSE_DELTA_X) || \
((type) == WSCONS_EVENT_MOUSE_DELTA_Y) || \
- ((type) == WSCONS_EVENT_MOUSE_DELTA_Z))
+ ((type) == WSCONS_EVENT_MOUSE_DELTA_Z) || \
+ ((type) == WSCONS_EVENT_MOUSE_DELTA_W) || \
+ ((type) == WSCONS_EVENT_MOUSE_ABSOLUTE_X) || \
+ ((type) == WSCONS_EVENT_MOUSE_ABSOLUTE_Y) || \
+ ((type) == WSCONS_EVENT_MOUSE_ABSOLUTE_Z) || \
+ ((type) == WSCONS_EVENT_MOUSE_ABSOLUTE_W))
+
#define IS_BUTTON_EVENT(type) (((type) == WSCONS_EVENT_MOUSE_UP) || \
((type) == WSCONS_EVENT_MOUSE_DOWN))
@@ -45,6 +51,10 @@
char *m_devname; /* File name of wsmouse device */
char *m_fifoname; /* File name of fifo */
int m_disabled; /* Whether if the mouse is disabled or not */
+
+ /* support for absolute position events */
+ int m_doabs;
+ struct wsmouse_calibcoords m_calib;
};
struct mode_bootstrap {
Home |
Main Index |
Thread Index |
Old Index