2021-09-28 09:20:09 +03:00
|
|
|
/* $NetBSD: mouse.c,v 1.11 2021/09/28 06:20:09 nia Exp $ */
|
1998-12-28 17:01:16 +03:00
|
|
|
|
|
|
|
/*-
|
2012-12-24 05:27:23 +04:00
|
|
|
* Copyright (c) 1998, 2006, 2012 The NetBSD Foundation, Inc.
|
1998-12-28 17:01:16 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2006-02-05 20:38:33 +03:00
|
|
|
* by Juergen Hannken-Illjes and Julio M. Merino Vidal.
|
1998-12-28 17:01:16 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <dev/wscons/wsconsio.h>
|
2006-02-05 20:38:33 +03:00
|
|
|
|
1998-12-28 17:01:16 +03:00
|
|
|
#include <err.h>
|
2006-02-05 20:38:33 +03:00
|
|
|
#include <errno.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
1998-12-28 17:01:16 +03:00
|
|
|
#include "wsconsctl.h"
|
|
|
|
|
2021-09-28 09:20:09 +03:00
|
|
|
static int reverse_scrolling;
|
|
|
|
static int horiz_scroll_dist;
|
|
|
|
static int vert_scroll_dist;
|
1998-12-28 17:01:16 +03:00
|
|
|
static int mstype;
|
1999-11-11 21:29:40 +03:00
|
|
|
static int resolution;
|
|
|
|
static int samplerate;
|
2012-12-24 05:27:23 +04:00
|
|
|
static struct wsmouse_calibcoords calibration;
|
|
|
|
static char *calibration_samples;
|
2006-02-05 20:38:33 +03:00
|
|
|
static struct wsmouse_repeat repeat;
|
|
|
|
|
2021-09-28 09:20:09 +03:00
|
|
|
static void mouse_get_parameters(int);
|
|
|
|
static void mouse_put_parameters(int);
|
|
|
|
|
2012-12-24 05:27:23 +04:00
|
|
|
static void mouse_get_calibration(int);
|
2012-12-24 05:29:20 +04:00
|
|
|
static void mouse_put_calibration(int);
|
2012-12-24 05:27:23 +04:00
|
|
|
|
2006-02-05 20:38:33 +03:00
|
|
|
static void mouse_get_repeat(int);
|
|
|
|
static void mouse_put_repeat(int);
|
1998-12-28 17:01:16 +03:00
|
|
|
|
|
|
|
struct field mouse_field_tab[] = {
|
2021-09-28 09:20:09 +03:00
|
|
|
{ "resolution", &resolution, FMT_UINT, FLG_WRONLY },
|
|
|
|
{ "samplerate", &samplerate, FMT_UINT, FLG_WRONLY },
|
|
|
|
{ "type", &mstype, FMT_MSTYPE, FLG_RDONLY },
|
|
|
|
{ "scroll.reverse", &reverse_scrolling, FMT_INT, FLG_MODIFY },
|
|
|
|
{ "scroll.distance.x", &horiz_scroll_dist, FMT_INT, FLG_MODIFY },
|
|
|
|
{ "scroll.distance.y", &vert_scroll_dist, FMT_INT, FLG_MODIFY },
|
2012-12-24 05:27:23 +04:00
|
|
|
{ "calibration.minx", &calibration.minx,
|
2021-09-28 09:20:09 +03:00
|
|
|
FMT_INT, FLG_MODIFY },
|
2012-12-24 05:27:23 +04:00
|
|
|
{ "calibration.miny", &calibration.miny,
|
2021-09-28 09:20:09 +03:00
|
|
|
FMT_INT, FLG_MODIFY },
|
2012-12-24 05:27:23 +04:00
|
|
|
{ "calibration.maxx", &calibration.maxx,
|
2021-09-28 09:20:09 +03:00
|
|
|
FMT_INT, FLG_MODIFY },
|
2012-12-24 05:27:23 +04:00
|
|
|
{ "calibration.maxy", &calibration.maxy,
|
2021-09-28 09:20:09 +03:00
|
|
|
FMT_INT, FLG_MODIFY },
|
2012-12-24 05:27:23 +04:00
|
|
|
{ "calibration.samples", &calibration_samples,
|
2021-09-28 09:20:09 +03:00
|
|
|
FMT_STRING, FLG_MODIFY },
|
2006-02-05 20:38:33 +03:00
|
|
|
{ "repeat.buttons", &repeat.wr_buttons,
|
2021-09-28 09:20:09 +03:00
|
|
|
FMT_BITFIELD, FLG_MODIFY },
|
2006-02-05 20:38:33 +03:00
|
|
|
{ "repeat.delay.first", &repeat.wr_delay_first,
|
2021-09-28 09:20:09 +03:00
|
|
|
FMT_UINT, FLG_MODIFY },
|
2006-02-05 20:38:33 +03:00
|
|
|
{ "repeat.delay.decrement", &repeat.wr_delay_decrement,
|
2021-09-28 09:20:09 +03:00
|
|
|
FMT_UINT, FLG_MODIFY },
|
2006-02-05 20:38:33 +03:00
|
|
|
{ "repeat.delay.minimum", &repeat.wr_delay_minimum,
|
2021-09-28 09:20:09 +03:00
|
|
|
FMT_UINT, FLG_MODIFY },
|
1998-12-28 17:01:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
int mouse_field_tab_len = sizeof(mouse_field_tab)/
|
|
|
|
sizeof(mouse_field_tab[0]);
|
|
|
|
|
|
|
|
void
|
2005-01-19 23:37:52 +03:00
|
|
|
mouse_get_values(int fd)
|
1998-12-28 17:01:16 +03:00
|
|
|
{
|
2006-02-05 21:11:46 +03:00
|
|
|
|
1998-12-28 17:01:16 +03:00
|
|
|
if (field_by_value(&mstype)->flags & FLG_GET)
|
|
|
|
if (ioctl(fd, WSMOUSEIO_GTYPE, &mstype) < 0)
|
2006-02-05 21:11:46 +03:00
|
|
|
err(EXIT_FAILURE, "WSMOUSEIO_GTYPE");
|
2006-02-05 20:38:33 +03:00
|
|
|
|
2012-12-24 05:27:23 +04:00
|
|
|
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);
|
|
|
|
|
2006-02-05 20:38:33 +03:00
|
|
|
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 ||
|
|
|
|
field_by_value(&repeat.wr_delay_minimum)->flags & FLG_GET)
|
|
|
|
mouse_get_repeat(fd);
|
2021-09-28 09:20:09 +03:00
|
|
|
|
|
|
|
if (field_by_value(&horiz_scroll_dist)->flags & FLG_GET ||
|
|
|
|
field_by_value(&vert_scroll_dist)->flags & FLG_GET ||
|
|
|
|
field_by_value(&reverse_scrolling)->flags & FLG_GET)
|
|
|
|
mouse_get_parameters(fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mouse_get_parameters(int fd)
|
|
|
|
{
|
|
|
|
struct wsmouse_param params[WSMOUSECFG_MAX];
|
|
|
|
struct wsmouse_parameters pl;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
pl.nparams = 0;
|
|
|
|
pl.params = params;
|
|
|
|
|
|
|
|
if (field_by_value(&reverse_scrolling)->flags & FLG_GET)
|
|
|
|
params[pl.nparams++].key = WSMOUSECFG_REVERSE_SCROLLING;
|
|
|
|
if (field_by_value(&horiz_scroll_dist)->flags & FLG_GET)
|
|
|
|
params[pl.nparams++].key = WSMOUSECFG_HORIZSCROLLDIST;
|
|
|
|
if (field_by_value(&vert_scroll_dist)->flags & FLG_GET)
|
|
|
|
params[pl.nparams++].key = WSMOUSECFG_VERTSCROLLDIST;
|
|
|
|
|
|
|
|
if (ioctl(fd, WSMOUSEIO_GETPARAMS, &pl) < 0) {
|
|
|
|
if (field_by_value(&horiz_scroll_dist)->flags & FLG_GET)
|
|
|
|
field_disable_by_value(&horiz_scroll_dist);
|
|
|
|
if (field_by_value(&vert_scroll_dist)->flags & FLG_GET)
|
|
|
|
field_disable_by_value(&vert_scroll_dist);
|
|
|
|
if (field_by_value(&reverse_scrolling)->flags & FLG_GET)
|
|
|
|
field_disable_by_value(&reverse_scrolling);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < pl.nparams; ++i) {
|
|
|
|
switch (params[i].key) {
|
|
|
|
case WSMOUSECFG_REVERSE_SCROLLING:
|
|
|
|
reverse_scrolling = params[i].value;
|
|
|
|
break;
|
|
|
|
case WSMOUSECFG_HORIZSCROLLDIST:
|
|
|
|
horiz_scroll_dist = params[i].value;
|
|
|
|
break;
|
|
|
|
case WSMOUSECFG_VERTSCROLLDIST:
|
|
|
|
vert_scroll_dist = params[i].value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-02-05 20:38:33 +03:00
|
|
|
}
|
|
|
|
|
2012-12-24 05:27:23 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-05 20:38:33 +03:00
|
|
|
static void
|
|
|
|
mouse_get_repeat(int fd)
|
|
|
|
{
|
|
|
|
struct wsmouse_repeat tmp;
|
|
|
|
|
2012-12-24 05:27:23 +04:00
|
|
|
if (ioctl(fd, WSMOUSEIO_GETREPEAT, &tmp) < 0)
|
2006-02-05 21:11:46 +03:00
|
|
|
err(EXIT_FAILURE, "WSMOUSEIO_GETREPEAT");
|
2006-02-05 20:38:33 +03:00
|
|
|
|
|
|
|
if (field_by_value(&repeat.wr_buttons)->flags & FLG_GET)
|
|
|
|
repeat.wr_buttons = tmp.wr_buttons;
|
|
|
|
if (field_by_value(&repeat.wr_delay_first)->flags & FLG_GET)
|
|
|
|
repeat.wr_delay_first = tmp.wr_delay_first;
|
|
|
|
if (field_by_value(&repeat.wr_delay_decrement)->flags & FLG_GET)
|
|
|
|
repeat.wr_delay_decrement = tmp.wr_delay_decrement;
|
|
|
|
if (field_by_value(&repeat.wr_delay_minimum)->flags & FLG_GET)
|
|
|
|
repeat.wr_delay_minimum = tmp.wr_delay_minimum;
|
1998-12-28 17:01:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-01-19 23:37:52 +03:00
|
|
|
mouse_put_values(int fd)
|
1998-12-28 17:01:16 +03:00
|
|
|
{
|
1999-11-15 16:47:30 +03:00
|
|
|
int tmp;
|
1999-11-11 21:29:40 +03:00
|
|
|
|
1999-11-15 16:47:30 +03:00
|
|
|
if (field_by_value(&resolution)->flags & FLG_SET) {
|
|
|
|
tmp = resolution;
|
|
|
|
if (ioctl(fd, WSMOUSEIO_SRES, &tmp) < 0)
|
2006-02-05 21:11:46 +03:00
|
|
|
err(EXIT_FAILURE, "WSMOUSEIO_SRES");
|
1999-11-15 16:47:30 +03:00
|
|
|
pr_field(field_by_value(&resolution), " -> ");
|
|
|
|
}
|
2006-02-05 20:38:33 +03:00
|
|
|
|
1999-11-15 16:47:30 +03:00
|
|
|
if (field_by_value(&samplerate)->flags & FLG_SET) {
|
|
|
|
tmp = samplerate;
|
|
|
|
if (ioctl(fd, WSMOUSEIO_SRATE, &tmp) < 0)
|
2006-02-05 21:11:46 +03:00
|
|
|
err(EXIT_FAILURE, "WSMOUSEIO_SRATE");
|
2006-02-05 20:45:06 +03:00
|
|
|
pr_field(field_by_value(&samplerate), " -> ");
|
1999-11-15 16:47:30 +03:00
|
|
|
}
|
2006-02-05 20:38:33 +03:00
|
|
|
|
2012-12-24 05:29:20 +04:00
|
|
|
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);
|
|
|
|
|
2006-02-05 20:38:33 +03:00
|
|
|
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 ||
|
|
|
|
field_by_value(&repeat.wr_delay_minimum)->flags & FLG_SET)
|
|
|
|
mouse_put_repeat(fd);
|
2021-09-28 09:20:09 +03:00
|
|
|
|
|
|
|
if (field_by_value(&horiz_scroll_dist)->flags & FLG_SET ||
|
|
|
|
field_by_value(&vert_scroll_dist)->flags & FLG_SET ||
|
|
|
|
field_by_value(&reverse_scrolling)->flags & FLG_SET)
|
|
|
|
mouse_put_parameters(fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mouse_put_parameters(int fd)
|
|
|
|
{
|
|
|
|
struct wsmouse_param params[WSMOUSECFG_MAX];
|
|
|
|
struct wsmouse_parameters pl;
|
|
|
|
|
|
|
|
pl.nparams = 0;
|
|
|
|
pl.params = params;
|
|
|
|
|
|
|
|
if (field_by_value(&reverse_scrolling)->flags & FLG_SET) {
|
|
|
|
params[pl.nparams].key = WSMOUSECFG_REVERSE_SCROLLING;
|
|
|
|
params[pl.nparams++].value = reverse_scrolling;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (field_by_value(&horiz_scroll_dist)->flags & FLG_SET) {
|
|
|
|
params[pl.nparams].key = WSMOUSECFG_HORIZSCROLLDIST;
|
|
|
|
params[pl.nparams++].value = horiz_scroll_dist;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (field_by_value(&vert_scroll_dist)->flags & FLG_SET) {
|
|
|
|
params[pl.nparams].key = WSMOUSECFG_VERTSCROLLDIST;
|
|
|
|
params[pl.nparams++].value = vert_scroll_dist;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ioctl(fd, WSMOUSEIO_SETPARAMS, &pl) < 0) {
|
|
|
|
if (field_by_value(&horiz_scroll_dist)->flags & FLG_SET)
|
|
|
|
field_disable_by_value(&horiz_scroll_dist);
|
|
|
|
if (field_by_value(&vert_scroll_dist)->flags & FLG_SET)
|
|
|
|
field_disable_by_value(&vert_scroll_dist);
|
|
|
|
if (field_by_value(&vert_scroll_dist)->flags & FLG_SET)
|
|
|
|
field_disable_by_value(&reverse_scrolling);
|
|
|
|
return;
|
|
|
|
}
|
2006-02-05 20:38:33 +03:00
|
|
|
}
|
|
|
|
|
2012-12-24 05:29:20 +04:00
|
|
|
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), " -> ");
|
|
|
|
}
|
|
|
|
|
2006-02-05 20:38:33 +03:00
|
|
|
static void
|
|
|
|
mouse_put_repeat(int fd)
|
|
|
|
{
|
|
|
|
struct wsmouse_repeat tmp;
|
|
|
|
|
|
|
|
/* Fetch current values into the temporary structure. */
|
2012-12-24 05:27:23 +04:00
|
|
|
if (ioctl(fd, WSMOUSEIO_GETREPEAT, &tmp) < 0)
|
2006-02-05 21:11:46 +03:00
|
|
|
err(EXIT_FAILURE, "WSMOUSEIO_GETREPEAT");
|
2006-02-05 20:38:33 +03:00
|
|
|
|
|
|
|
/* Overwrite the desired values in the temporary structure. */
|
|
|
|
if (field_by_value(&repeat.wr_buttons)->flags & FLG_SET)
|
|
|
|
tmp.wr_buttons = repeat.wr_buttons;
|
|
|
|
if (field_by_value(&repeat.wr_delay_first)->flags & FLG_SET)
|
|
|
|
tmp.wr_delay_first = repeat.wr_delay_first;
|
|
|
|
if (field_by_value(&repeat.wr_delay_decrement)->flags & FLG_SET)
|
|
|
|
tmp.wr_delay_decrement = repeat.wr_delay_decrement;
|
|
|
|
if (field_by_value(&repeat.wr_delay_minimum)->flags & FLG_SET)
|
|
|
|
tmp.wr_delay_minimum = repeat.wr_delay_minimum;
|
|
|
|
|
|
|
|
/* Set new values for repeating events. */
|
2012-12-24 05:27:23 +04:00
|
|
|
if (ioctl(fd, WSMOUSEIO_SETREPEAT, &tmp) < 0)
|
2006-02-05 21:11:46 +03:00
|
|
|
err(EXIT_FAILURE, "WSMOUSEIO_SETREPEAT");
|
2006-02-05 20:38:33 +03:00
|
|
|
|
|
|
|
/* Now print what changed. */
|
|
|
|
if (field_by_value(&repeat.wr_buttons)->flags & FLG_SET)
|
|
|
|
pr_field(field_by_value(&repeat.wr_buttons), " -> ");
|
|
|
|
if (field_by_value(&repeat.wr_delay_first)->flags & FLG_SET)
|
|
|
|
pr_field(field_by_value(&repeat.wr_delay_first), " -> ");
|
|
|
|
if (field_by_value(&repeat.wr_delay_decrement)->flags & FLG_SET)
|
|
|
|
pr_field(field_by_value(&repeat.wr_delay_decrement), " -> ");
|
|
|
|
if (field_by_value(&repeat.wr_delay_minimum)->flags & FLG_SET)
|
|
|
|
pr_field(field_by_value(&repeat.wr_delay_minimum), " -> ");
|
1998-12-28 17:01:16 +03:00
|
|
|
}
|