CVS commit: src/usr.sbin/wsmoused
Module Name:src Committed By: mlelstv Date: Tue Feb 7 20:37:48 UTC 2023 Modified Files: src/usr.sbin/wsmoused: selection.c Log Message: Really compute selection coordinates from buffer offset, don't assume that row=0 col=offset is equivalent. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/wsmoused/selection.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wsmoused
Module Name:src Committed By: mlelstv Date: Tue Feb 7 20:37:48 UTC 2023 Modified Files: src/usr.sbin/wsmoused: selection.c Log Message: Really compute selection coordinates from buffer offset, don't assume that row=0 col=offset is equivalent. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/wsmoused/selection.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wsmoused/selection.c diff -u src/usr.sbin/wsmoused/selection.c:1.11 src/usr.sbin/wsmoused/selection.c:1.12 --- src/usr.sbin/wsmoused/selection.c:1.11 Wed Nov 24 14:34:51 2021 +++ src/usr.sbin/wsmoused/selection.c Tue Feb 7 20:37:48 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: selection.c,v 1.11 2021/11/24 14:34:51 uwe Exp $ */ +/* $NetBSD: selection.c,v 1.12 2023/02/07 20:37:48 mlelstv Exp $ */ /* * Copyright (c) 2002, 2003, 2004, 2007 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include #ifndef lint -__RCSID("$NetBSD: selection.c,v 1.11 2021/11/24 14:34:51 uwe Exp $"); +__RCSID("$NetBSD: selection.c,v 1.12 2023/02/07 20:37:48 mlelstv Exp $"); #endif /* not lint */ #include @@ -144,6 +144,7 @@ static void selarea_copy_text(void); static void selarea_start(void); static void selarea_end(void); static void selarea_calculate(void); +static void selarea_getrowcol(size_t, size_t *, size_t *); static void selarea_hide(void); static void selarea_show(void); static void selarea_paste(void); @@ -648,14 +649,29 @@ selarea_calculate(void) /* -- */ +/* Turns selection absolute position in the screen buffer back into + row, col co-ordinates */ +static void +selarea_getrowcol(size_t pos, size_t* row, size_t* col) +{ + size_t xres = Selmouse.sm_max_x + 1; + + *row = pos / xres; + *col = pos - (*row * xres); +} + +/* -- */ + /* Hides the highlighted region, returning it to normal colors. */ static void selarea_hide(void) { - size_t i; + size_t i, row, col; - for (i = Selarea.sa_startoff; i <= Selarea.sa_endoff; i++) - char_invert(0, i); + for (i = Selarea.sa_startoff; i <= Selarea.sa_endoff; i++) { + selarea_getrowcol(i, , ); + char_invert(row, col); + } } /* -- */ @@ -664,11 +680,13 @@ selarea_hide(void) static void selarea_show(void) { - size_t i; + size_t i, row, col; selarea_calculate(); - for (i = Selarea.sa_startoff; i <= Selarea.sa_endoff; i++) - char_invert(0, i); + for (i = Selarea.sa_startoff; i <= Selarea.sa_endoff; i++) { + selarea_getrowcol(i, , ); + char_invert(row, col); + } } /* -- */
CVS commit: src/usr.sbin/wsmoused
Module Name:src Committed By: uwe Date: Wed Nov 24 14:34:51 UTC 2021 Modified Files: src/usr.sbin/wsmoused: selection.c wsmoused.c wsmoused.h Log Message: wsmoused: support absolute mouse position events Tested with VirtualBox Guest Addtions. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/wsmoused/selection.c cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/wsmoused/wsmoused.c cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/wsmoused/wsmoused.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wsmoused/selection.c diff -u src/usr.sbin/wsmoused/selection.c:1.10 src/usr.sbin/wsmoused/selection.c:1.11 --- src/usr.sbin/wsmoused/selection.c:1.10 Sun May 27 15:05:00 2007 +++ src/usr.sbin/wsmoused/selection.c Wed Nov 24 14:34:51 2021 @@ -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 #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 @@ -226,6 +226,7 @@ selection_cleanup(void) void selection_wsmouse_event(struct wscons_event evt) { + const struct wsmouse_calibcoords *abs = _mouse->m_calib; if (IS_MOTION_EVENT(evt.type)) { if (Selmouse.sm_selecting) @@ -259,7 +260,30 @@ selection_wsmouse_event(struct wscons_ev 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: Index: src/usr.sbin/wsmoused/wsmoused.c diff -u src/usr.sbin/wsmoused/wsmoused.c:1.27 src/usr.sbin/wsmoused/wsmoused.c:1.28 --- src/usr.sbin/wsmoused/wsmoused.c:1.27 Wed Sep 1 06:10:06 2021 +++ src/usr.sbin/wsmoused/wsmoused.c Wed Nov 24 14:34:51 2021 @@ -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 @@ -250,7 +250,7 @@ init_mouse(void) static void open_device(unsigned int secs) { - int version = WSMOUSE_EVENT_VERSION; + int status; if (Mouse.m_devfd != -1) return; @@ -262,10 +262,38 @@ open_device(unsigned int secs) if (Mouse.m_devfd == -1) log_err(EXIT_FAILURE, "cannot open %s", Mouse.m_devname); - if (ioctl(Mouse.m_devfd, WSMOUSEIO_SETVERSION, ) == -1) + const int version = WSMOUSE_EVENT_VERSION; + status = ioctl(Mouse.m_devfd, WSMOUSEIO_SETVERSION, ); + 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, _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, _calib); + if (status == -1) { + log_warn("WSMOUSEIO_GCALIBCOORDS"); + return; + } + + Mouse.m_doabs = 1; } + /* - */ /* Main program event loop. This function polls the wscons status Index: src/usr.sbin/wsmoused/wsmoused.h diff -u src/usr.sbin/wsmoused/wsmoused.h:1.9 src/usr.sbin/wsmoused/wsmoused.h:1.10 --- src/usr.sbin/wsmoused/wsmoused.h:1.9 Sat Mar 18 02:06:38 2006 +++ src/usr.sbin/wsmoused/wsmoused.h Wed Nov 24 14:34:51 2021 @@ -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,
CVS commit: src/usr.sbin/wsmoused
Module Name:src Committed By: uwe Date: Wed Nov 24 14:34:51 UTC 2021 Modified Files: src/usr.sbin/wsmoused: selection.c wsmoused.c wsmoused.h Log Message: wsmoused: support absolute mouse position events Tested with VirtualBox Guest Addtions. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/wsmoused/selection.c cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/wsmoused/wsmoused.c cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/wsmoused/wsmoused.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wsmoused
Module Name:src Committed By: mlelstv Date: Wed Sep 1 06:10:06 UTC 2021 Modified Files: src/usr.sbin/wsmoused: wsmoused.c Log Message: conditional build fix. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/wsmoused/wsmoused.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wsmoused/wsmoused.c diff -u src/usr.sbin/wsmoused/wsmoused.c:1.26 src/usr.sbin/wsmoused/wsmoused.c:1.27 --- src/usr.sbin/wsmoused/wsmoused.c:1.26 Tue May 31 03:37:02 2011 +++ src/usr.sbin/wsmoused/wsmoused.c Wed Sep 1 06:10:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: wsmoused.c,v 1.26 2011/05/31 03:37:02 christos Exp $ */ +/* $NetBSD: wsmoused.c,v 1.27 2021/09/01 06:10:06 mlelstv 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.26 2011/05/31 03:37:02 christos Exp $"); +__RCSID("$NetBSD: wsmoused.c,v 1.27 2021/09/01 06:10:06 mlelstv Exp $"); #endif /* not lint */ #include @@ -71,7 +71,7 @@ static int Foreground = 1; static int X_Console = -1; static int X_Console_Delay = 5; -#ifdef WSMOUSED_SELECTION_MODE +#ifdef WSMOUSED_ACTION_MODE extern struct mode_bootstrap Action_Mode; #endif #ifdef WSMOUSED_SELECTION_MODE
CVS commit: src/usr.sbin/wsmoused
Module Name:src Committed By: mlelstv Date: Wed Sep 1 06:10:06 UTC 2021 Modified Files: src/usr.sbin/wsmoused: wsmoused.c Log Message: conditional build fix. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/wsmoused/wsmoused.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.