wiiremotej
Class TiltAccelerometerMouse

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

public class TiltAccelerometerMouse
extends AccelerometerMouse

A class for implementing a mouse using the accelerometer. It is assumed that the WiiRemote is held still and then tilted left/right and front/back. Mouse motion is determined from the pitch and roll only. Moving the remote (i.e. left, right, front back, up, down, etc) will produce some very odd results.


Field Summary
 
Fields inherited from class wiiremotej.AccelerometerMouse
NUNCHUK_EXTENSION, WII_REMOTE
 
Fields inherited from class wiiremotej.WiiRemoteMouse
xSensitivity, ySensitivity
 
Constructor Summary
TiltAccelerometerMouse(double xSensitivity, double ySensitivity, int device, double rollThreshold, double pitchThreshold)
          Creates a new TiltAccelerometerMouse with the given settings.
 
Method Summary
static TiltAccelerometerMouse getDefault()
          Returns a basic tilt mouse with the following settings.
 double getPitchThreshold()
          Returns the pitch threshold of this "mouse" in radians.
 double getRollThreshold()
          Returns the roll threshold of this "mouse" in radians.
 void processMouseEvent(WRAccelerationEvent evt)
          Processes an acceleration event and moves the mouse if necessary, according to sensitivity and threshold values.
 void setPitchThreshold(double pitchThreshold)
          Sets the pitch threshold of this "mouse" to the given value in radians.
 void setRollThreshold(double rollThreshold)
          Sets the roll threshold of this "mouse" to the given value in radians.
 
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

TiltAccelerometerMouse

public TiltAccelerometerMouse(double xSensitivity,
                              double ySensitivity,
                              int device,
                              double rollThreshold,
                              double pitchThreshold)
                       throws java.awt.AWTException,
                              java.lang.SecurityException
Creates a new TiltAccelerometerMouse with the given settings. Rotation must exceed the threshold values to be registered.

Parameters:
xSensitivity - pixels to move on the X axis per radian of roll. A negative modifier will move the mouse the opposite way.
ySensitivity - pixels to move on the Y axis per radian of pitch. A negative modifier will move the mouse the opposite way.
device - the device to use for acceleration input. See constant fields for options.
rollThreshold - the magnitude of the amount of roll necessary for the mouse to be moved on the X axis. This is in radians.
pitchThreshold - the magnitude of the amount of pitch necessary for the mouse to be moved on the Y axis. This is in radians.
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 threshold values.

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

getDefault

public static TiltAccelerometerMouse getDefault()
                                         throws java.awt.AWTException,
                                                java.lang.SecurityException
Returns a basic tilt mouse with the following settings. xSensitivity: 12. ySensitivity: 12. device: WII_REMOTE. rollThreshold: 0.1. pitchThreshold: 0.1.

Returns:
a basic tilt 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.

getRollThreshold

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

Returns:
the roll threshold of this "mouse."

getPitchThreshold

public double getPitchThreshold()
Returns the pitch threshold of this "mouse" in radians. That is, the amount of pitch needed for a mouse-movement to be registered on the Y axis.

Returns:
the pitch threshold of this "mouse."

setRollThreshold

public void setRollThreshold(double rollThreshold)
Sets the roll threshold of this "mouse" to the given value in radians.

Parameters:
rollThreshold - the new roll threshold.

setPitchThreshold

public void setPitchThreshold(double pitchThreshold)
Sets the pitch threshold of this "mouse" to the given value in radians.

Parameters:
pitchThreshold - the new pitch threshold.