NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Bluetooth wheel mouse and X11



On Wed, 22 May 2024, Joel wrote:

wsmuxctl -f 0 -l
wsmouse0
wsmouse2


Can you run this program on the console (no X; no wsmoused) and see if it
reports any scroll events when you move the mouse? Run on /dev/wsmouse2
first, then on /dev/wsmouse. Both should report the same type of events, I
think.

-RVP

--- START mousetest.c ---
/**
 * 64-bit systems: hexdump -e '24/1 "%02x " "\n"' /dev/wsmouseN
 * 32-bit systems: hexdump -e '20/1 "%02x " "\n"' /dev/wsmouseN
 */

#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dev/wscons/wsconsio.h>

int
main(int argc, char* argv[])
{
	struct wscons_event e[16], *ep;
	char* dev;
	int fd;

	if (argc != 2) {
		fprintf(stderr, "Usage: %s mouse-dev\n", getprogname());
		exit(EXIT_FAILURE);
	}

	dev = argv[1];
	if ((fd = open(dev, O_RDONLY)) == -1)
		err(EXIT_FAILURE, "%s: open failed", dev);

	for (;;) {
		ssize_t i, n;
		if ((n = read(fd, e, sizeof e)) <= 0) {
			close(fd);
			err(EXIT_FAILURE, "%s: packet read failed", dev);
		}
		if (n % sizeof(e[0])) {
			close(fd);
			err(EXIT_FAILURE, "%s: partial packet read", dev);
		}
		n /= sizeof(e[0]);
		for (i = 0, ep = e; i < n; i++, ep++) {
			switch (ep->type) {
			case WSCONS_EVENT_MOUSE_UP:
				printf(" release: %d\n", ep->value);
				break;
			case WSCONS_EVENT_MOUSE_DOWN:
				printf("   press: %d\n", ep->value);
				break;
			case WSCONS_EVENT_MOUSE_DELTA_X:
				printf("    move: %d (%s)\n", ep->value, ep->value < 0 ? "left" : "right");
				break;
			case WSCONS_EVENT_MOUSE_DELTA_Y:
				printf("    move: %d (%s)\n", ep->value, ep->value < 0 ? "down" : "up");
				break;
			case WSCONS_EVENT_MOUSE_ABSOLUTE_X:
				printf("   loc X: %d\n", ep->value);
				break;
			case WSCONS_EVENT_MOUSE_ABSOLUTE_Y:
				printf("   loc Y: %d\n", ep->value);
				break;
			case WSCONS_EVENT_MOUSE_DELTA_Z:
				printf("  scroll: %d (%s)\n", ep->value, ep->value < 0 ? "up" : "down");
				break;
			case WSCONS_EVENT_MOUSE_ABSOLUTE_Z:
				printf("   loc Z: %d\n", ep->value);
				break;
			case WSCONS_EVENT_MOUSE_DELTA_W:
				printf(" delta-w: %d (%s)\n", ep->value, ep->value < 0 ? "left" : "right");
				break;
			case WSCONS_EVENT_MOUSE_ABSOLUTE_W:
				printf("   loc W: %d\n", ep->value);
				break;
			case WSCONS_EVENT_HSCROLL:
				printf("H-scroll: %d\n", ep->value);
				break;
			case WSCONS_EVENT_VSCROLL:
				printf("V-scroll: %d\n", ep->value);
				break;
			default:
				printf("Unknown: %u %d\n", ep->type, ep->value);
				break;
			}
		}
	}
	return 0;
}
--- END mousetest.c ---


Home | Main Index | Thread Index | Old Index