A few more bugs in the SWTMouse:
private void updateCenters() should look like this:
I was getting an exception for trying to access SWT widgets outside of the SWT thread, this is a way to do that. I used asyncExec instead of syncExec because syncExec would just hang. Also, the size wasn't getting returned correctly.
private void updateCenters()
{
// calculate center-of-component (in absolute sizes)
control.getDisplay().asyncExec( new Runnable()
{
public void run()
{
los.x = control.getLocation().x;
los.y = control.getLocation().y;
Composite parent = control.getParent();
while ( parent != null )
{
los.x += parent.getLocation().x;
los.y += parent.getLocation().y;
parent = parent.getParent();
}
centerControl.x = ( control.getSize().x / 2 ) + 1;
centerControl.y = ( control.getSize().y / 2 ) + 1;
parent = control.getParent();
while ( ( centerControl.x == 1 && centerControl.y == 1 ) && ( parent != null ) )
{
centerControl.x = ( parent.getSize().x / 2 ) + 1;
centerControl.y = ( parent.getSize().y / 2 ) + 1;
parent = parent.getParent();
}
calibrationStep = 0;
}
} );
}
private void recenter() Should be changed to this: (this is the same type of issue as above)
private void recenter() throws InputSystemException
{
if ( control.getDisplay().getThread().equals( Thread.currentThread() ) )
{
control.getDisplay().setCursorLocation( los.x + calibX + centerControl.x, los.y + calibY + centerControl.y );
}
else
{
control.getDisplay().asyncExec( new Runnable()
{
public void run()
{
control.getDisplay().setCursorLocation( los.x + calibX + centerControl.x, los.y + calibY + centerControl.y );
}
} );
}
}
There are only 2 remaining issues.
The mouse wheel doesn't work correctly (as it did in the previous revision).
The mouse cursor doesn't disappear when over the 3D canvas.
If you have any incite into either of these issues, it'd be helpful

For the mouse wheel issue I did try this, which didn't work (it was currently using _e.time() which definitely wouldn't work. I was hoping just switching to the System.nanoTime() would fix it):
long when = System.nanoTime() - lastGameTimeDelta;
//MouseWheelEvent e = MouseEventPool.allocWheel( SWTMouse.this, getWheel(), -_e.count, false, when, 0L );
MouseWheelEvent e = prepareMouseWheelMovedEvent( -_e.count, false, when );
I'm not sure at all about making the cursor hidden.