wiiremotej
Class MotionAccelerometerMouse

java.lang.Object
  extended by wiiremotej.WiiRemoteMouse
      extended by wiiremotej.AccelerometerMouse
          extended by wiiremotej.MotionAccelerometerMouse

public class MotionAccelerometerMouse
extends AccelerometerMouse

A class for implementing a mouse using the accelerometer. It is assumed that the WiiRemote is held flat and then moved left/right and up/down. Mouse motion is determined from the X and Z accelerations only. Turning the remote on its side will produce some very odd results. Note that the Z axis of the Wii Remote is used because the Y axis is into the computer, and that makes a lot less sense than moving the remote up and down.


Field Summary
 
Fields inherited from class wiiremotej.AccelerometerMouse
NUNCHUK_EXTENSION, WII_REMOTE
 
Fields inherited from class wiiremotej.WiiRemoteMouse
xSensitivity, ySensitivity
 
Constructor Summary
MotionAccelerometerMouse(double xSensitivity, double ySensitivity, int device, double xMotionThreshold, double zMotionThreshold)
          Creates a new MotionAccelerometerMouse with the given settings.
 
Method Summary
static MotionAccelerometerMouse getDefault()
          Returns a basic motion mouse with the following settings.
 double getXMotionThreshold()
          Returns the X motion threshold of this "mouse" in Gs.
 double getZMotionThreshold()
          Returns the Z motion threshold of this "mouse" in Gs.
 void processMouseEvent(WRAccelerationEvent evt)
          Processes an acceleration event and moves the mouse if necessary, according to sensitivity and motion threshold values.
 void setXMotionThreshold(double xMotionThreshold)
          Sets the X motion threshold of this "mouse" to the given value in Gs.
 void setZMotionThreshold(double zMotionThreshold)
          Sets the Z motion threshold of this "mouse" to the given value in Gs.
 
Methods inherited from class wiiremotej.AccelerometerMouse
getDevice, setDevice
 
Methods inherited from class wiiremotej.WiiRemoteMouse
getXSensitivity, getYSensitivity, moveMouse, setXSensitivity, setYSensitivity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MotionAccelerometerMouse

public MotionAccelerometerMouse(double xSensitivity,
                                double ySensitivity,
                                int device,
                                double xMotionThreshold,
                                double zMotionThreshold)
                         throws java.awt.AWTException,
                                java.lang.SecurityException
Creates a new MotionAccelerometerMouse with the given settings. Acceleration must exceed the motion threshold values to be registered. For the mouse button values, see WRButtonEvent.

Parameters:
xSensitivity - pixels to move on the X axis per G of X acceleration. A negative modifier will move the mouse the opposite way.
ySensitivity - pixels to move on the Y axis per G of Z acceleration. A negative modifier will move the mouse the opposite way.
device - the device to use for acceleration input. See constant fields for options.
xMotionThreshold - the magnitude of the amount of acceleration necessary on the X axis for the mouse to be moved on the X axis. This is in Gs.
zMotionThreshold - the magnitude of the amount of acceleration necessary on the Z axis for the mouse to be moved on the Y axis. This is in Gs.
Throws:
java.awt.AWTException - if the platform configuration does not allow low-level input control. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.
java.lang.SecurityException - if createRobot permission is not granted.
Method Detail

processMouseEvent

public void processMouseEvent(WRAccelerationEvent evt)
Processes an acceleration event and moves the mouse if necessary, according to sensitivity and motion threshold values.

Specified by:
processMouseEvent in class AccelerometerMouse
Parameters:
evt - the acceleration event to process.

getDefault

public static MotionAccelerometerMouse getDefault()
                                           throws java.awt.AWTException,
                                                  java.lang.SecurityException
Returns a basic motion mouse with the following settings. xSensitivity: 100. ySensitivity: 100. device: WII_REMOTE. xMotionThreshold: 0.2. zMotionThreshold: 0.1.

Returns:
a basic motion mouse.
Throws:
java.awt.AWTException - if the platform configuration does not allow low-level input control. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.
java.lang.SecurityException - if createRobot permission is not granted.

getXMotionThreshold

public double getXMotionThreshold()
Returns the X motion threshold of this "mouse" in Gs. That is, the amount of acceleration needed for a mouse-movement to be registered on the X axis.

Returns:
the X motion threshold of this "mouse."

getZMotionThreshold

public double getZMotionThreshold()
Returns the Z motion threshold of this "mouse" in Gs. That is, the amount of acceleration needed for a mouse-movement to be registered on the Y axis.

Returns:
the Z motion threshold of this "mouse."

setXMotionThreshold

public void setXMotionThreshold(double xMotionThreshold)
Sets the X motion threshold of this "mouse" to the given value in Gs.

Parameters:
xMotionThreshold - the new X motion threshold.

setZMotionThreshold

public void setZMotionThreshold(double zMotionThreshold)
Sets the Z motion threshold of this "mouse" to the given value in Gs.

Parameters:
zMotionThreshold - the new Z motion threshold.