2 mice

I’ve been wondering about putting together a ‘Sale of the Century’ type game for kids. I’d like to be able to use off-the-shelf hardware, so had thought of just using a few USB mice as buzzers. Each contestant would be given a mouse to hold. The software would listen for the first button click and display a message or play a sound to indicate which mouse that corresponded to.

Is it possible to detect mouse events from different mice plugged into the same system and distinguish them from each other? If not, I imagine I could probably do it with gamepads instead.

Any advice would be appreciated.

It’s possible with XP, but not with NT, 2k or win9x (afaik).

I don’t know how it’s with Mac/Linux, but I could imagine that it works there.

However, I don’t know if it’s supported by JInput.

You Don’t Know Jack used the keyboard for example (on Windows and Mac), which worked pretty well with 2 players and was sorta cramped with 3 players.

Hi

Under windows XP, you can disable the directx plugin and use the ‘Raw’ plugin, this will expose multiple mice if you have them. Example, my laptop has a built in mouse, but I plug in an external usb mouse as it’s easier to use when I have a desk to put my laptop on. Using the platform default plugin on windows shows 1 mouse. With the raw plugin, I get 2.

You have to disable the directx plugin becase both plugins can’t capture the device(s) at the same time it appears.

To disable the default platform plugin add the property jinput.useDefaultPlugin=false and to list the plugins you with to load, add their classes to the jinput.plugins property, for the raw one, you want jinput.plugins=net.java.games.input.RawInputEnvironmentPlugin. So to run the controller read test that comes with jinput, in the main directory, you should be able to run java -Djava.library.path=dist -cp dist\jinput.jar;dist\jinput-test.jar -Djinput.plugins=net.java.games.input.RawInputEnvironmentPlugin -Djinput.useDefaultPlugin=false net.java.games.input.test.ControllerReadTest.

Under Linux it should already pick multiple mice up anyway. I’m unsure about OSX, and have no way to test, I’ll try giving Elias a prod and see what falls out :slight_smile:

HTH

Endolf

@oNyx: On other windows’ than XP, the (default) DirectInput plugin should work. The Raw plugin is only there to fix the stupid decision by microsoft to exclude multiple mice (and keyboards) from DirectInput.

An alternative way to get the raw plugin is to try a “new RawInputEnvironmentPlugin()” before you try ControllerEnvironment.getDefaultEnvironment(). As Endolf stated, it’s important that you don’t have both the default DI plugin and the raw plugin active at the same time since directinput and raw input steps on each other’s toes.

@Endolf: Multiple mice on mac should just work.

I tried that on my WinXP box with two USB mice connected and it worked perfectly. The test pops up a window displaying the properties for each mouse and the keyboard. I can click the mouse buttons and see the corresponding properties change for that mouse.

Excellent, thanks.