more than one Mouse

Hello Everybody,
I try to get the input from two usb-mice to move in a 3D-World(LWJGL). So far no problem, but is there a way to identify the Mice? Everytime the Program starts, the Mice change there Position.


for(int i=0;i<controllers.length;i++) {
	if(controllers[i].getType()==Controller.Type.MOUSE) {
		if(firstMouse==null){
			firstMouse = controllers[i];
		}
		else if(secondMouse==null)secondMouse = controllers[i];
		else thirdMouse= controllers[i];
	}
}

I tryed to get the portnumber, but they are alle the same for every mouse.
I´m working on Windows 7 and XP.
My second Problem is that the Windows cursor is moved by all mice. Is there a way to stop that? The Windows cursor should only listen to the first mouse.

thanks for help

Hi

Are the mice the same make and model?, if not, you can get the name of the device.

JInput has no control over what moves the windows cursor, that is a windows issue.

Endolf

Yes it is the same model.

The devices are enumerated in the order that directx calls the callback. It’s possible that a directx app would have the same issue. I will do some digging at the weekend and see what I can find.

Endolf

very cool.
Thanks

when your program starts up, have a window showing how each mouse is moving and have the user choose which mouse to choose for what.

I have exactly the same problem on a redhat platform. two devices same make and model (2 usb track balls).

I can not tell them apart at the JInput level as they both have the same Controller name, and each time you boot the machine its 50:50 the order Jinput returns them in the array of controllers.

using rules to force the device names in /dev/input I can force the names to be in the same order (based on the ID of the device) however Jinput doesnt seem to base the return of the controllers on the device name.

anybody know what it bases the order on, and can I get it consistant?

given that listFiles doesnt guarantee order, I assume this is due to LinuxEnvironmentPlugin listFilePrivileged doing

dir.listFiles(filter);

I dont surpose somebody who knows what they are doing could update the code to apply an alpha sort on it

File[] files = dir.listFiles(filter);
Arrays.sort(files, new Comparator(){
public int compare(File f1, File f2)
{
return f1.getName().compareTo(f2.getName());
} });
return files;

Hi

Looks good, I hope to add this over the weekend (I’m out thursday and fridays).

Thanks for the update :slight_smile:

Endolf

Thanks,

I rebuilt jinput with the change and tested it and it works fine.
when I posted the original code I forgot jinput is built for 1.4, so no templates and no annotations, so for completness the code change is.

	File[] files = dir.listFiles(filter);
	Arrays.sort(files, new Comparator(){
	    public int compare(Object f1, Object f2)
	    {
	        return ((File)f1).getName().compareTo(((File)f2).getName());
	    } });

and if anybody needs to fix the order of devices on a linux platform ie. writting rules this was a usefull link http://reactivated.net/writing_udev_rules.html

Hi I dont suppose you know if this fix has been released? any chance of a url to a release with this version in it. getting hold of JInput releases isnt very obvious :frowning:

Cheers

shadow123

Hi

Sorry, I did forget to commit this. I have now made the change (but not tested it), the project pages for jinput are here, in the downloads section. Also, I’ve updated the webstart demo and the maven repository.

Endolf