at.wisch.joystick
Class FFJoystick

java.lang.Object
  extended by at.wisch.joystick.AbstractController
      extended by at.wisch.joystick.Joystick
          extended by at.wisch.joystick.FFJoystick
All Implemented Interfaces:
AdvancedController, AdvancedFFController, Controller

public class FFJoystick
extends Joystick
implements AdvancedFFController

The class FFJoystick. This is the class that actually represents FFJoystick objects, which are necessary for playing force feedback effects on a Joystick. I also inherits all the capabilities for input handling from Joystick.

Attention: do not instantiate FFJoystick objects yourself. Aquire FFJoysticks using JoystickManager.

Author:
Martin Wischenbart

Field Summary
 
Fields inherited from class at.wisch.joystick.AbstractController
AXIS_DEFAULT_DEAD_ZONE, AXIS_MAXIMUM, AXIS_MINIMUM, AXIS_NEUTRAL, DEFAULT_AUTOCENTER_VALUE, DEFAULT_GAIN_VALUE, INFINITE_TIMES, POV_AXIS_NEGATIVE, POV_AXIS_NEUTRAL, POV_AXIS_POSITIVE, POV_CENTERED, POV_DOWN, POV_DOWN_LEFT, POV_DOWN_RIGHT, POV_LEFT, POV_RIGHT, POV_UP, POV_UP_LEFT, POV_UP_RIGHT
 
Method Summary
 boolean destroyAll()
          Destroy all effects: remove all effects, that are currently stored on the device.
 boolean destroyEffect(Effect effect)
          Destroy effect: remove an effect from the device.
 int getAutoCenter()
          Gets the currently set autocenter value.
 java.lang.String getFFDescription()
          Gets a short description of the joystick's capabilities for FF.
 int getGain()
          Gets the currently set gain value.
 int getNumOfFFAxes()
          Deprecated. on some operating systems this method will return a fixed value for any joystick. To be really platform independent work without using it. Simply assume the joystick has 2 FF axes.
 int getPlayableNumOfEffects()
          Deprecated. on some operating systems this method will return a fixed value for any joystick. To be really platform independent work without using it. Simply assume the joystick can play only few effects at once(~ around 10).
 ExtendedEffect getSimpleEffect()
          Gets a simple effect.
 int getStorableNumOfEffects()
          Deprecated. on some operating systems this method will return a fixed value for any joystick. To be really platform independent work without using it. Simply assume the joystick can store only few effects (~ around 10).
 java.util.HashSet<java.lang.Class<? extends Effect>> getSupportedEffects()
          Gets a HashSet of supported effects by this controller.
 boolean isAutocenterSupported()
          Checks if auto centering is supported by the device.
 boolean isEffectSupported(java.lang.Class<? extends Effect> effectClass)
          Checks if an effect is supported.
 boolean isEffectSupported(Effect effect)
          Checks if an effect is supported.
 boolean isGainSupported()
          Checks if a device supports setting gain.
 boolean isPaused()
          Checks if the device is currently paused.
 boolean isPauseSupported()
          Checks if the device supports pause/unpause for played effects.
 boolean isPlaying(Effect effect)
          Checks if an effect is currently playing.
 boolean isQueryingEffectStatusSupported()
          Checks if is querying the effect status is supported.
 boolean newEffect(Effect effect)
          Upload a new effect to the device.
 boolean pause()
          Deprecated. on some operating systems pause/unpause is never supported for any joystick. To be really platform independent work without pause/unpause.
 boolean playEffect(Effect effect, int iterations)
          Playback an effect on the device.
 boolean setAutoCenter(int autocenterValue)
          Sets the auto center value in %.
 boolean setGain(int gainValue)
          Sets the gain value in %.
 boolean stopAll()
          Stop all effects that are currently stored on the device.
 boolean stopEffect(Effect effect)
          Stop an effect which is currently on the device.
 java.lang.String toString()
          Gets a string containing the joystick's name and the description of the input and FF capabilities.
 boolean unpause()
          Deprecated. on some operating systems pause/unpause is never supported for any joystick. To be really platform independent work without pause/unpause.
 boolean updateEffect(Effect effect)
          Update an effect which was already uploaded to the device.
 
Methods inherited from class at.wisch.joystick.Joystick
getAxisCount, getAxisValue, getBallCount, getBallDelta, getButtonCount, getDeadZone, getDescription, getIndex, getInvertAxis, getInvertBall, getInvertPov, getName, getPovCount, getPovDirection, getPovX, getPovY, isButtonPressed, isFFJoystick, poll, setDeadZone, setInvertAxis, setInvertBall, setInvertPov
 
Methods inherited from class at.wisch.joystick.AbstractController
getAxisName, getBall1Delta, getBall2Delta, getBall3Delta, getBall4Delta, getBallName, getButtonName, getPov1X, getPov1Y, getPov2X, getPov2Y, getPov3X, getPov3Y, getPov4X, getPov4Y, getPovName, getPovX, getPovY, getRXAxisDeadZone, getRXAxisValue, getRYAxisDeadZone, getRYAxisValue, getRZAxisDeadZone, getRZAxisValue, getUAxisDeadZone, getUAxisValue, getVAxisDeadZone, getVAxisValue, getXAxisDeadZone, getXAxisValue, getYAxisDeadZone, getYAxisValue, getZAxisDeadZone, getZAxisValue, setRXAxisDeadZone, setRYAxisDeadZone, setRZAxisDeadZone, setUAxisDeadZone, setVAxisDeadZone, setXAxisDeadZone, setYAxisDeadZone, setZAxisDeadZone
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface at.wisch.joystick.AdvancedController
getBall1Delta, getBall2Delta, getBall3Delta, getBall4Delta, getBallCount, getBallDelta, getBallName, getPov1X, getPov1Y, getPov2X, getPov2Y, getPov3X, getPov3Y, getPov4X, getPov4Y, getPovCount, getPovDirection, getPovName, getPovX, getPovY, getUAxisDeadZone, getUAxisValue, getVAxisDeadZone, getVAxisValue, isFFJoystick, setUAxisDeadZone, setVAxisDeadZone
 
Methods inherited from interface org.lwjgl.input.Controller
getAxisCount, getAxisName, getAxisValue, getButtonCount, getButtonName, getDeadZone, getIndex, getName, getPovX, getPovY, getRXAxisDeadZone, getRXAxisValue, getRYAxisDeadZone, getRYAxisValue, getRZAxisDeadZone, getRZAxisValue, getXAxisDeadZone, getXAxisValue, getYAxisDeadZone, getYAxisValue, getZAxisDeadZone, getZAxisValue, isButtonPressed, poll, setDeadZone, setRXAxisDeadZone, setRYAxisDeadZone, setRZAxisDeadZone, setXAxisDeadZone, setYAxisDeadZone, setZAxisDeadZone
 

Method Detail

toString

public java.lang.String toString()
Gets a string containing the joystick's name and the description of the input and FF capabilities.

Overrides:
toString in class Joystick
Returns:
the joystick's name and a the description of the input and FF capabilities
See Also:
Joystick.getName(), Joystick.getDescription(), getFFDescription()

getFFDescription

public java.lang.String getFFDescription()
Gets a short description of the joystick's capabilities for FF. This includes supported effects and if pause/unpause, setting gain and setting autocenter are supported.

Returns:
the String containing the joystick's capabilities for input
See Also:
toString(), getSupportedEffects(), isPauseSupported(), isGainSupported(), isAutocenterSupported()

getSupportedEffects

public java.util.HashSet<java.lang.Class<? extends Effect>> getSupportedEffects()
Gets a HashSet of supported effects by this controller.

Specified by:
getSupportedEffects in interface AdvancedFFController
Returns:
a HashSet containing the classes of supported effects
See Also:
HashSet, Effect

isEffectSupported

public boolean isEffectSupported(Effect effect)
Checks if an effect is supported.

Specified by:
isEffectSupported in interface AdvancedFFController
Parameters:
effect - an Effect instance
Returns:
true, if the Effect is supported by this controller. false, otherwise.
See Also:
Effect

isEffectSupported

public boolean isEffectSupported(java.lang.Class<? extends Effect> effectClass)
Checks if an effect is supported.

Specified by:
isEffectSupported in interface AdvancedFFController
Parameters:
effectClass - an Effect class
Returns:
true, if the Effect is supported by this controller. false, otherwise.
See Also:
Effect

isQueryingEffectStatusSupported

public boolean isQueryingEffectStatusSupported()
Checks if is querying the effect status is supported.

Specified by:
isQueryingEffectStatusSupported in interface AdvancedFFController
Returns:
true, if is querying effect status supported. false, otherwise.
See Also:
Effect

getNumOfFFAxes

@Deprecated
public int getNumOfFFAxes()
Deprecated. on some operating systems this method will return a fixed value for any joystick. To be really platform independent work without using it. Simply assume the joystick has 2 FF axes.

Gets the number of FF axes a device has. For most controllers that is two. For a flight simulator joystick the axes usually correspond to the X and Y axes of the stick. For a gamepad the axes correspond to rumble motors.

Specified by:
getNumOfFFAxes in interface AdvancedFFController
Returns:
the number of FF axes the device has
See Also:
Direction

getPlayableNumOfEffects

@Deprecated
public int getPlayableNumOfEffects()
Deprecated. on some operating systems this method will return a fixed value for any joystick. To be really platform independent work without using it. Simply assume the joystick can play only few effects at once(~ around 10).

Gets the number of effects a device can play simultaneously.

Specified by:
getPlayableNumOfEffects in interface AdvancedFFController
Returns:
the number of effects playable at once
See Also:
AdvancedFFController.getStorableNumOfEffects()

getStorableNumOfEffects

@Deprecated
public int getStorableNumOfEffects()
Deprecated. on some operating systems this method will return a fixed value for any joystick. To be really platform independent work without using it. Simply assume the joystick can store only few effects (~ around 10).

Gets the number of effects a device can store.

Specified by:
getStorableNumOfEffects in interface AdvancedFFController
Returns:
the number of storable effects
See Also:
AdvancedFFController.getPlayableNumOfEffects()

isGainSupported

public boolean isGainSupported()
Checks if a device supports setting gain. Gain is a factor to scale the strength of all FF effects on a device. By default the gain is set to 100 (%), which is the maximum (DEFAULT_GAIN_VALUE).

Specified by:
isGainSupported in interface AdvancedFFController
Returns:
true, if is gain supported. false, otherwise.
See Also:
AdvancedFFController.setGain(int), AdvancedFFController.getGain()

getGain

public int getGain()
Gets the currently set gain value.

Specified by:
getGain in interface AdvancedFFController
Returns:
the currently set gain (value from 0 to 100)
See Also:
AdvancedFFController.setGain(int), AdvancedFFController.isGainSupported()

setGain

public boolean setGain(int gainValue)
Sets the gain value in %. Change the gain to scale the strength of all FF effects on this device.

Specified by:
setGain in interface AdvancedFFController
Parameters:
gainValue - the % gain value: any value from 0 to 100
Returns:
true, if successful. false, if not successful or if setting gain is not supported.
See Also:
AdvancedFFController.isGainSupported(), AdvancedFFController.getGain()

isAutocenterSupported

public boolean isAutocenterSupported()
Checks if auto centering is supported by the device. Auto centering means that a force towards the center of the stick is active at all times. By default autocenter is disabled, i.e. set to 0 (%), which is the minimum (DEFAULT_AUTOCENTER_VALUE).

Specified by:
isAutocenterSupported in interface AdvancedFFController
Returns:
true, if autocenter is supported. false, otherwise.
See Also:
AdvancedFFController.getAutoCenter(), AdvancedFFController.setAutoCenter(int)

getAutoCenter

public int getAutoCenter()
Gets the currently set autocenter value.

Specified by:
getAutoCenter in interface AdvancedFFController
Returns:
the currently set autocenter value (value from 0 to 100)
See Also:
AdvancedFFController.isAutocenterSupported(), AdvancedFFController.setAutoCenter(int)

setAutoCenter

public boolean setAutoCenter(int autocenterValue)
Sets the auto center value in %. Set auto centering to enable a force towards the center of the stick on this device.

Specified by:
setAutoCenter in interface AdvancedFFController
Parameters:
autocenterValue - the % autocenter strength: a value from 0 to 100
Returns:
true, if successful. false, if not successful or if setting autocenter is not supported.
See Also:
AdvancedFFController.isAutocenterSupported(), AdvancedFFController.getAutoCenter()

isPauseSupported

public boolean isPauseSupported()
Checks if the device supports pause/unpause for played effects.

Specified by:
isPauseSupported in interface AdvancedFFController
Returns:
true, if is pause/unpause supported. false, otherwise.
See Also:
AdvancedFFController.pause(), AdvancedFFController.unpause(), AdvancedFFController.isPaused()

pause

@Deprecated
public boolean pause()
Deprecated. on some operating systems pause/unpause is never supported for any joystick. To be really platform independent work without pause/unpause.

Pause all effects that are currently playing.

Specified by:
pause in interface AdvancedFFController
Returns:
true, if successful. false, if not successful or if pause/unpause is not supported.
See Also:
AdvancedFFController.isPauseSupported(), AdvancedFFController.unpause(), AdvancedFFController.isPaused()

unpause

@Deprecated
public boolean unpause()
Deprecated. on some operating systems pause/unpause is never supported for any joystick. To be really platform independent work without pause/unpause.

Resume all effects that were playing before AdvancedFFController.pause() was called.

Specified by:
unpause in interface AdvancedFFController
Returns:
true, if successful. false, if not successful or if pause/unpause is not supported.
See Also:
AdvancedFFController.isPauseSupported(), AdvancedFFController.pause(), AdvancedFFController.isPaused()

isPaused

public boolean isPaused()
Checks if the device is currently paused.

Specified by:
isPaused in interface AdvancedFFController
Returns:
true, if the device is paused. false if the device is not paused or if pause/unpause is not supported.
See Also:
AdvancedFFController.isPauseSupported(), AdvancedFFController.pause(), AdvancedFFController.unpause()

getSimpleEffect

public ExtendedEffect getSimpleEffect()
Gets a simple effect. We assume that every FFJoystick supports an ExtendedEffect. This method returns one of the following: ConstantEffect, RampEffect, SineEffect, SquareEffect, TriangleEffect, SawtoothUpEffect, SawtoothDownEffect,

Returns:
a simple effect of type ExtendedEffect or null if none is supported

newEffect

public boolean newEffect(Effect effect)
Upload a new effect to the device.

Specified by:
newEffect in interface AdvancedFFController
Parameters:
effect - the Effect
Returns:
true, if successful. false, if not successful or if the effect is not supported by this device.
See Also:
AdvancedFFController.isEffectSupported(Effect), AdvancedFFController.playEffect(Effect, int), AdvancedFFController.stopEffect(Effect), AdvancedFFController.destroyEffect(Effect)

playEffect

public boolean playEffect(Effect effect,
                          int iterations)
Playback an effect on the device. If the Effect was not uploaded before, it will be uploaded and played immediately.

Specified by:
playEffect in interface AdvancedFFController
Parameters:
effect - the Effect to be played
iterations - the number of iterations (i.e. how often to play the effect): any positive integer, or INFINITE_TIMES
Returns:
true, if successful. false, if not successful or if the effect is not supported by this device.
See Also:
AdvancedFFController.newEffect(Effect), AdvancedFFController.updateEffect(Effect), AdvancedFFController.stopEffect(Effect), AdvancedFFController.pause(), AdvancedFFController.unpause()

isPlaying

public boolean isPlaying(Effect effect)
Checks if an effect is currently playing.

Specified by:
isPlaying in interface AdvancedFFController
Parameters:
effect - the Effect to check
Returns:
true, if the effect is playing at the moment. false, if the effect was not uploaded before or if it is not supported.
See Also:
AdvancedFFController.playEffect(Effect, int), AdvancedFFController.stopEffect(Effect), AdvancedFFController.pause(), AdvancedFFController.unpause()

updateEffect

public boolean updateEffect(Effect effect)
Update an effect which was already uploaded to the device. If the Effect was not uploaded before, it will be uploaded. If you change the properties of an effect, you always have to call updateEffect so the changes will be stored on the device. You can update an effect while it is playing, but be aware that sometimes it causes the effect to restart (i.e. play from the beginning).

Specified by:
updateEffect in interface AdvancedFFController
Parameters:
effect - the Effect to be updated
Returns:
true, if successful. false, if not successful or if the effect is not supported by this device.
See Also:
AdvancedFFController.newEffect(Effect), AdvancedFFController.playEffect(Effect, int)

stopEffect

public boolean stopEffect(Effect effect)
Stop an effect which is currently on the device. It does not matter if it is actually played at the moment or not.

Specified by:
stopEffect in interface AdvancedFFController
Parameters:
effect - the Effect to be stopped
Returns:
true, if the Effect was stopped (no matter if it was actually being played). false, if the Effect was not on the device or stopping was not successful.
See Also:
AdvancedFFController.stopAll(), AdvancedFFController.destroyEffect(Effect)

destroyEffect

public boolean destroyEffect(Effect effect)
Destroy effect: remove an effect from the device. It does not matter if it is being played or not. The Effect object will remain intact and can be uploaded again later or onto other devices. If effects are being played during destruction, they will stop.

Specified by:
destroyEffect in interface AdvancedFFController
Parameters:
effect - the Effect to be removed from the device
Returns:
true, if successful. false, if the Effect was not on the device or destroying was not successful.
See Also:
AdvancedFFController.destroyAll(), AdvancedFFController.stopEffect(Effect)

stopAll

public boolean stopAll()
Stop all effects that are currently stored on the device. It does not matter how many effects that are and no matter if any of them are being played or not.

Specified by:
stopAll in interface AdvancedFFController
Returns:
true, if successful. false, if not successful.
See Also:
AdvancedFFController.stopEffect(Effect), AdvancedFFController.destroyAll()

destroyAll

public boolean destroyAll()
Destroy all effects: remove all effects, that are currently stored on the device. It does not matter if they are being played or not. If effects are being played during destruction, they will stop.

Specified by:
destroyAll in interface AdvancedFFController
Returns:
true, if successful. false, if not successful.
See Also:
AdvancedFFController.destroyEffect(Effect), AdvancedFFController.stopAll()