Not need call ioctl(WSMOUSEIO_GCALIBCOORDS or WSMOUSEIO_SCALIBCOORDS) twice, enough once.
OK ? -- Alexandr Shadchin Index: mouse.c =================================================================== RCS file: /cvs/src/sbin/wsconsctl/mouse.c,v retrieving revision 1.11 diff -u -p -r1.11 mouse.c --- mouse.c 20 Aug 2010 00:20:55 -0000 1.11 +++ mouse.c 13 Jul 2012 16:35:18 -0000 @@ -44,7 +44,7 @@ static int resolution; static int samplerate; static int rawmode; -struct wsmouse_calibcoords wmcoords, wmcoords_save; +struct wsmouse_calibcoords wmcoords; struct field mouse_field_tab[] = { { "resolution", &resolution, FMT_UINT, FLG_WRONLY }, @@ -61,26 +61,20 @@ mouse_get_values(int fd) if (field_by_value(mouse_field_tab, &mstype)->flags & FLG_GET) if (ioctl(fd, WSMOUSEIO_GTYPE, &mstype) < 0) warn("WSMOUSEIO_GTYPE"); - - if (field_by_value(mouse_field_tab, &rawmode)->flags & FLG_GET) { + + if ((field_by_value(mouse_field_tab, &rawmode)->flags & FLG_GET) || + (field_by_value(mouse_field_tab, &wmcoords)->flags & FLG_GET)) { if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords) < 0) { - if (errno == ENOTTY) + if (errno == ENOTTY) { field_by_value(mouse_field_tab, &rawmode)->flags |= FLG_DEAD; - else + field_by_value(mouse_field_tab, + &wmcoords)->flags |= FLG_DEAD; + } else warn("WSMOUSEIO_GCALIBCOORDS"); } rawmode = wmcoords.samplelen; } - - if (field_by_value(mouse_field_tab, &wmcoords)->flags & FLG_GET) - if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords) < 0) { - if (errno == ENOTTY) - field_by_value(mouse_field_tab, - &wmcoords)->flags |= FLG_DEAD; - else - warn("WSMOUSEIO_GCALIBCOORDS"); - } } int @@ -98,29 +92,13 @@ mouse_put_values(int fd) return 1; } } - if (field_by_value(mouse_field_tab, &rawmode)->flags & FLG_SET) { + if ((field_by_value(mouse_field_tab, &rawmode)->flags & FLG_SET) || + (field_by_value(mouse_field_tab, &wmcoords)->flags & FLG_SET)) { wmcoords.samplelen = rawmode; if (ioctl(fd, WSMOUSEIO_SCALIBCOORDS, &wmcoords) < 0) { if (errno == ENOTTY) { field_by_value(mouse_field_tab, &rawmode)->flags |= FLG_DEAD; - } else { - warn("WSMOUSEIO_SCALIBCOORDS"); - return 1; - } - } - } - if (field_by_value(mouse_field_tab, &wmcoords)->flags & FLG_SET) { - if (ioctl(fd, WSMOUSEIO_GCALIBCOORDS, &wmcoords_save) < 0) { - if (errno == ENOTTY) - field_by_value(mouse_field_tab, - &wmcoords)->flags |= FLG_DEAD; - else - warn("WSMOUSEIO_GCALIBCOORDS"); - } - wmcoords.samplelen = wmcoords_save.samplelen; - if (ioctl(fd, WSMOUSEIO_SCALIBCOORDS, &wmcoords) < 0) { - if (errno == ENOTTY) { field_by_value(mouse_field_tab, &wmcoords)->flags |= FLG_DEAD; } else {