sdljava.joystick

Class SDLJoystick

public class SDLJoystick extends Object

Binding to the SDL Joystick routines.

Version: $Id: SDLJoystick.java,v 1.3 2005/01/19 03:09:12 ivan_ganza Exp $

Author: Ivan Z. Ganza

Field Summary
SWIGTYPE_p__SDL_JoystickswigJoystick
Constructor Summary
SDLJoystick(SWIGTYPE_p__SDL_Joystick swigJoystick)
Method Summary
protected voidfinalize()
voidjoystickClose()
Closes a previously opened joystick
intjoystickGetAxis(int axis)
Get the current state of an axis

SDL_JoystickGetAxis returns the current state of the given axis on the given joystick.

voidjoystickGetBall(int ball, Integer dx, Integer dy)
Get relative trackball motion
booleanjoystickGetButton(int button)
Get the current state of a given button on a given joystick
HatStatejoystickGetHat(int hat)
Get the current state of a joystick hat
intjoystickIndex()
Get the index of an SDL_Joystick.
static StringjoystickName(int index)
Get joystick name

Get the implementation dependent name of joystick.

intjoystickNumAxes()
Get the number of joystick axes
intjoystickNumBalls()
Get the number of joystick trackballs
intjoystickNumButtons()
Get the number of joystick Buttons
intjoystickNumHats()
Get the number of joystick hats
static SDLJoystickjoystickOpen(int index)
Opens a joystick for use.
static booleanjoystickOpened(int index)
Determine if a joystick has been opened

Determines whether a joystick has already been opened within the application.

static voidjoystickUpdate()
Updates the state of all joysticks

Updates the state(position, buttons, etc.) of all open joysticks.

static intnumJoysticks()
Count available joysticks.

Field Detail

swigJoystick

SWIGTYPE_p__SDL_Joystick swigJoystick

Constructor Detail

SDLJoystick

private SDLJoystick(SWIGTYPE_p__SDL_Joystick swigJoystick)

Method Detail

finalize

protected void finalize()

joystickClose

public void joystickClose()
Closes a previously opened joystick

joystickGetAxis

public int joystickGetAxis(int axis)
Get the current state of an axis

SDL_JoystickGetAxis returns the current state of the given axis on the given joystick.

On most modern joysticks the X axis is usually represented by axis 0 and the Y axis by axis 1. The value returned by SDL_JoystickGetAxis is a signed integer (-32768 to 32767) representing the current position of the axis, it may be necessary to impose certain tolerances on these values to account for jitter. It is worth noting that some joysticks use axes 2 and 3 for extra buttons.

Parameters: axis an int value

Returns: the current position of the axis.

joystickGetBall

public void joystickGetBall(int ball, Integer dx, Integer dy)
Get relative trackball motion

Parameters: ball The ball dx The value of the x change will be placed here dy The value of the y change will be placed here

Throws: SDLException if an error occurs

joystickGetButton

public boolean joystickGetButton(int button)
Get the current state of a given button on a given joystick

Parameters: button an int value

Returns: if the given button on the given joystick is pressed

joystickGetHat

public HatState joystickGetHat(int hat)
Get the current state of a joystick hat

Parameters: hat The hat to get the state for

Returns: the current state of the given hat on the given joystick.

joystickIndex

public int joystickIndex()
Get the index of an SDL_Joystick.

Returns: Index number of the joystick.

joystickName

public static String joystickName(int index)
Get joystick name

Get the implementation dependent name of joystick. The index parameter refers to the N'th joystick on the system.

Returns: The joystick name

joystickNumAxes

public int joystickNumAxes()
Get the number of joystick axes

Returns: The number of axes

joystickNumBalls

public int joystickNumBalls()
Get the number of joystick trackballs

Returns: The number of trackballs

joystickNumButtons

public int joystickNumButtons()
Get the number of joystick Buttons

Returns: The number of Buttons

joystickNumHats

public int joystickNumHats()
Get the number of joystick hats

Returns: The number of hats

joystickOpen

public static SDLJoystick joystickOpen(int index)
Opens a joystick for use. A joystick must be opened before it can be used

Parameters: index index refers to the N'th joystick in the system

Returns: The joystick

Throws: SDLException if an error occured

joystickOpened

public static boolean joystickOpened(int index)
Determine if a joystick has been opened

Determines whether a joystick has already been opened within the application.

Parameters: index index refers to the N'th joystick on the system.

Returns: if the joystick at index has been opened

joystickUpdate

public static void joystickUpdate()
Updates the state of all joysticks

Updates the state(position, buttons, etc.) of all open joysticks. If joystick events have been enabled with SDL_JoystickEventState then this is called automatically in the event loop.

numJoysticks

public static int numJoysticks()
Count available joysticks.

Counts the number of joysticks attached to the system.

Returns: Returns the number of attached joysticks