mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-23 11:18:54 +00:00
Allow dumping the USB mouse reports via 'sysctl -b dev.ums.N.parseinfo',
previously only available via bootverbose. PR: usb/137191 Submitted by: Eygene Ryabinkin
This commit is contained in:
parent
ab593611be
commit
4ed0304c97
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=198373
@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/priv.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/sbuf.h>
|
||||
|
||||
#include <dev/usb/usb.h>
|
||||
#include <dev/usb/usbdi.h>
|
||||
@ -161,7 +162,9 @@ static usb_fifo_open_t ums_open;
|
||||
static usb_fifo_close_t ums_close;
|
||||
static usb_fifo_ioctl_t ums_ioctl;
|
||||
|
||||
static void ums_put_queue(struct ums_softc *sc, int32_t dx, int32_t dy, int32_t dz, int32_t dt, int32_t buttons);
|
||||
static void ums_put_queue(struct ums_softc *, int32_t, int32_t,
|
||||
int32_t, int32_t, int32_t);
|
||||
static int ums_sysctl_handler_parseinfo(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
static struct usb_fifo_methods ums_fifo_methods = {
|
||||
.f_open = &ums_open,
|
||||
@ -643,6 +646,12 @@ ums_attach(device_t dev)
|
||||
if (err) {
|
||||
goto detach;
|
||||
}
|
||||
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
|
||||
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
|
||||
OID_AUTO, "parseinfo", CTLTYPE_STRING|CTLFLAG_RD,
|
||||
sc, 0, ums_sysctl_handler_parseinfo,
|
||||
"", "Dump UMS report parsing information");
|
||||
|
||||
return (0);
|
||||
|
||||
detach:
|
||||
@ -916,6 +925,67 @@ ums_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags)
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
ums_sysctl_handler_parseinfo(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct ums_softc *sc = arg1;
|
||||
struct ums_info *info;
|
||||
struct sbuf *sb;
|
||||
int i, j, err;
|
||||
|
||||
sb = sbuf_new_auto();
|
||||
for (i = 0; i < UMS_INFO_MAX; i++) {
|
||||
info = &sc->sc_info[i];
|
||||
|
||||
/* Don't emit empty info */
|
||||
if ((info->sc_flags &
|
||||
(UMS_FLAG_X_AXIS | UMS_FLAG_Y_AXIS | UMS_FLAG_Z_AXIS |
|
||||
UMS_FLAG_T_AXIS | UMS_FLAG_W_AXIS)) == 0 &&
|
||||
info->sc_buttons == 0)
|
||||
continue;
|
||||
|
||||
sbuf_printf(sb, "i%d:", i + 1);
|
||||
if (info->sc_flags & UMS_FLAG_X_AXIS)
|
||||
sbuf_printf(sb, " X:r%d, p%d, s%d;",
|
||||
(int)info->sc_iid_x,
|
||||
(int)info->sc_loc_x.pos,
|
||||
(int)info->sc_loc_x.size);
|
||||
if (info->sc_flags & UMS_FLAG_Y_AXIS)
|
||||
sbuf_printf(sb, " Y:r%d, p%d, s%d;",
|
||||
(int)info->sc_iid_y,
|
||||
(int)info->sc_loc_y.pos,
|
||||
(int)info->sc_loc_y.size);
|
||||
if (info->sc_flags & UMS_FLAG_Z_AXIS)
|
||||
sbuf_printf(sb, " Z:r%d, p%d, s%d;",
|
||||
(int)info->sc_iid_z,
|
||||
(int)info->sc_loc_z.pos,
|
||||
(int)info->sc_loc_z.size);
|
||||
if (info->sc_flags & UMS_FLAG_T_AXIS)
|
||||
sbuf_printf(sb, " T:r%d, p%d, s%d;",
|
||||
(int)info->sc_iid_t,
|
||||
(int)info->sc_loc_t.pos,
|
||||
(int)info->sc_loc_t.size);
|
||||
if (info->sc_flags & UMS_FLAG_W_AXIS)
|
||||
sbuf_printf(sb, " W:r%d, p%d, s%d;",
|
||||
(int)info->sc_iid_w,
|
||||
(int)info->sc_loc_w.pos,
|
||||
(int)info->sc_loc_w.size);
|
||||
|
||||
for (j = 0; j < info->sc_buttons; j++) {
|
||||
sbuf_printf(sb, " B%d:r%d, p%d, s%d;", j + 1,
|
||||
(int)info->sc_iid_btn[j],
|
||||
(int)info->sc_loc_btn[j].pos,
|
||||
(int)info->sc_loc_btn[j].size);
|
||||
}
|
||||
sbuf_printf(sb, "\n");
|
||||
}
|
||||
sbuf_finish(sb);
|
||||
err = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
|
||||
sbuf_delete(sb);
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
static devclass_t ums_devclass;
|
||||
|
||||
static device_method_t ums_methods[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user