Hi
This is off the top of my head. It almost certainly won’t compile, and probably won’t run even when you get past that, but it should be along the right lines :).
// Get the environment and all controllers.
Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
// Loop through them all, there may be more than one mouse remember.
for(Controller tempController : controllers) {
// If it's a mouse, we are interested
if(tempController.getType()==Controller.Type.MOUSE) {
// Get the X axis
Component xAxis = tempController.getComponents(Component.Identifier.Axis.X);
//Get the Y axis
Component yAxis = tempController.getComponents(Component.Identifier.Axis.Y);
}
}
You can then poll the device (50 times a second is good otherwise the OS buffers tend to fill up) and then grab the values of those axis.
The other way, is to get just the device like above, then call
getEventQueue()
on it, poll it every 50th of a second and then call
getNextEvent()
on the event queue. Each event will have the identifier of the axis it’s for and you can just check that for
Component.Identifier.Axis.X
and
Component.Identifier.Axis.Y
HTH
Endolf