[Fwd: Re: Determining if /dev/input/event* is really a mouse?]

Well, here you go. I’ll update my code snippet to reflect this soon.

–ryan.> ----- Original Message -----

Subject: Re: Determining if /dev/input/event* is really a mouse?
Date: Fri, 24 Jun 2005 00:06:54 +0200
From: vojtech@suse.cz (Vojtech Pavlik)
To: Ryan C. Gordon
References: <42BAEF94.60508 at clutteredmind.org>

On Thu, Jun 23, 2005 at 01:21:24PM -0400, Ryan C. Gordon wrote:

A couple developers on the SDL project (http://libsdl.org/) have been
playing around with applications that support multiple mice at once, via
the /dev/input/event* interface.

This works really well, with one dilemma: we’re having difficulty with
how to correctly identify a device as “mouse like” … currently, we
reject any evdev devices that don’t support EV_REL events, but this
excludes some tablet and touchpad devices that only report absolute
values…adding them means we would get various joysticks, etc, that we
would then think are mice.

A device with REL_X, REL_Y and at least BTN_LEFT is a mouse, trackball
or trackpoint.
A device with ABS_X, ABS_Y and BTN_TOUCH is a touchscreen.
A device with ABS_X, ABS_Y, BTN_TOUCH and BTN_TOOL_FINGER is a touchpad.
A device with ABS_X, ABS_Y, BTN_TOUCH and BTN_TOOL_PEN (or other
BTN_TOOL) is a graphical tablet.

The devices can have more features, mice can have more buttons, up to
two scroll wheels, everyone else can have pressure, touchpads have
gestures, tablets have various tools with serial numbers, etc.

A device with ABS_X, ABS_Y and BTN_TRIGGER is a joystick.
A device with ABS_X, ABS_Y and BTN_A is a gamepad.
A device with ABS_X, ABS_Y and other kinds of buttons might be a 6dof or
some other unusual thing.

A device with KEY_A - KEY_Z is a keyboard, of course. It may have a
wheel, too.

Then there are steering wheels and other simulation devices …

You can look at the source of joydev/mousedev to see how they do the
exact mapping, but the above should be the spirit of it.

We considered enumerating the /dev/usb/hid/hiddev* devices, and those
with the correct USB usage page could be matched against the evdevs by
vendor/product ID, but this unnecessarily excludes PS/2 and serial mice,

That’s a dead end. I’ll kill hiddev anyway, it doesn’t do well what it’s
supposed to do. (After I create a good replacement, of course).

Using /dev/input/mouse* instead limits us to 5 buttons and one mouse
wheel, and the kernel documentation refers to it as a “hack” that should
be passed by in favor of evdev.


It’s clear the kernel can distinguish the mouse-like devices from the
rest of the input hardware, since it properly configures /dev/input/mice
and the /dev/input/mouse* device nodes; is there a definitive way to
query for this from a userland app? If not, is it reasonable to add an
ioctl() call to discover this information about a given event device?

Vojtech Pavlik
SuSE Labs, SuSE CR