Sunday, March 18, 2007

Cool unknown libraries - Part 1

Every now and then someone asks me if there are any little unknown libraries to get some cool functionality.

So today I'd like to showcase ManyMouse.

This library, written in C, tries to do something new, and that is to provide a portable easy to use API to allow an app to work with multiple mice independently. It includes a nice demo game, a four player pong clone with each player controlled by a different mouse.

I find this quite nice if you want to implement certain games. I played it with a target shooting game, holding a gun (mouse) in each hand - literally. Currently it's implemented in ZSNES, a Super Nintendo emulator for use with games like Arkanoid or Terminator which allowed a mouse for each player to be plugged in on the original system.

More practical uses for it might be in VMWare, VirtualPC, QEmu, DOSBox, or the like, where one mouse could be bound to the application window (client OS) and another to be used within the host OS, so as not to have the two interfere. I currently find it annoying how you're using one of these apps, and find that it steals your mouse focus, and have no idea how to break out of it without shutting down the app (or at least that particular app within the client OS).

The API is also very nice and easy to use, I even find it easier than the APIs certain OSs provide for accessing mice. During each frame of your game or whenever you poll for input in your app, you ask ManyMouse for a list of actions that occurred since last poll, and it'll return a series of events telling you which mouse moved and what buttons were pressed, etc...
It can also tell you when a mouse was unplugged, and give you a list of the internal name for each device.

The only current drawback to ManyMouse is it's limited OS support. It as of this writing supports Windows NT 5.1+ (XP, 2003, Vista), Linux 2.4+ with evdev and read permissions to /dev/input/event* enabled, and Mac OS X. This leaves the various BSDs, Solaris, and some other less popular OSs unsupported. The Linux requirements may also require a user to get their administrator to install the evdev kernel interface or enable the read permissions to /dev/input/event*, as not all distros do that by default.

Although the author is currently working on getting it to work with X, which should support every modern UNIX, and remove any annoying setup requirements from Linux (under X) when completed. Someone also contributed Java bindings and it's now supposed to work with Java on any OS. If you have a cool app that could make use of independent support of multiple mice, give ManyMouse a whirl, or give it a shot if your native mouse reading API seems a bit scary. If you're able to, also consider giving the author a hand, and help finish up X support, or contribute functionality for another OS.

Some other time we'll have a look at some other cool unknown libraries.

No comments: