Xors3d Engine
Joystick

Functions

BBDECL int BBCALL xCountJoys ()
 Returns the number of attached joysticks.
BBDECL void BBCALL xFlushJoy ()
 Clears information about joystick keys hits.
BBDECL int BBCALL xGetJoy (int portID=0)
 Returns pressed joystick button.
BBDECL int BBCALL xJoyDown (int key, int portID=0)
 Detects if a joystick button is being held down.
BBDECL float BBCALL xJoyHat (int portID=0)
 Returns the state of a joystick 'hat' or 'pov' (point-of-view) control.
BBDECL int BBCALL xJoyHit (int key, int portID=0)
 Returns the number of times a specified button has been hit.
BBDECL float BBCALL xJoyPitch (int portID=0)
 Returns the pitch value of a joystick.
BBDECL float BBCALL xJoyRoll (int portID=0)
 Returns the roll value of a joystick.
BBDECL int BBCALL xJoyType (int portID=0)
 Returns joystick type.
BBDECL float BBCALL xJoyU (int portID=0)
 Returns the value of the u-axis of the joystick.
BBDECL int BBCALL xJoyUDir (int portID=0)
 Returns the direction of the u-axis of the joystick.
BBDECL float BBCALL xJoyV (int portID=0)
 Returns the value of the v-axis of the joystick.
BBDECL int BBCALL xJoyVDir (int portID=0)
 Returns the direction of the v-axis of the joystick.
BBDECL float BBCALL xJoyX (int portID=0)
 Returns the value of the x-axis of the joystick.
BBDECL int BBCALL xJoyXDir (int portID=0)
 Returns the direction of the x-axis of the joystick.
BBDECL float BBCALL xJoyY (int portID=0)
 Returns the value of the y-axis of the joystick.
BBDECL float BBCALL xJoyYaw (int portID=0)
 Returns the yaw value of a joystick.
BBDECL int BBCALL xJoyYDir (int portID=0)
 Returns the direction of the y-axis of the joystick.
BBDECL float BBCALL xJoyZ (int portID=0)
 Returns the value of the z-axis of the joystick.
BBDECL int BBCALL xJoyZDir (int portID=0)
 Returns the direction of the z-axis of the joystick.
BBDECL int BBCALL xWaitJoy (int portID=0)
 Stops program execution unless any joystick key is not pressed.

Function Documentation

BBDECL int BBCALL xJoyType ( int  portID = 0)

Returns joystick type.

This command returns the type of joystick which is currently connected to the computer. See 'Joystick types' for return values.

Parameters:
portIDNumber of joystick port to be checked
BBDECL int BBCALL xJoyDown ( int  key,
int  portID = 0 
)

Detects if a joystick button is being held down.

This command (and its counterparts xKeyDown and xMouseDown) is used to detect if a joystick button is being held down. You must check for each joystick button independantly with its corresponding number.

Parameters:
keyNumber of joystick button to check
portIDNumber of joystick port to check
See also:
xJoyHit()
BBDECL int BBCALL xJoyHit ( int  key,
int  portID = 0 
)

Returns the number of times a specified button has been hit.

This command returns the number of times a specified joystick button has been hit since the last time you called the xJoyHit() command

Parameters:
keyNumber of joystick button to check
portIDNumber of joystick port to check
See also:
xJoyDown()
BBDECL int BBCALL xGetJoy ( int  portID = 0)

Returns pressed joystick button.

Unlike the other similar commands (xJoyDown() and xJoyHit()), this command doesn't need to know which button you are trying to test for. It looks for any joystick button, then returns the number the user pressed. Since you are polling all the buttons instead of just a specific one, this may be a tad less efficient than using xJoyDown() or xJoyHit().

Parameters:
portIDNumber of joystick port to check
BBDECL void BBCALL xFlushJoy ( )

Clears information about joystick keys hits.

There are many times when you aren't interested in the dozens of possible joystick button pressed the player might have made before you are checking for one in particular. Or perhaps you want to pause the game and wait for any joystick button to be hit, but you don't want a 'queued' button press bypassing this. Use this command before you specifically want to poll a joystick button hit from the user.

BBDECL int BBCALL xWaitJoy ( int  portID = 0)

Stops program execution unless any joystick key is not pressed.

This command makes your program halt until a joystick button is pressed on the joystick. Used alone, it simply halts and waits for a button press. It return pressed button's code value.

Parameters:
portIDNumber of joystick port to check
BBDECL float BBCALL xJoyX ( int  portID = 0)

Returns the value of the x-axis of the joystick.

This command returns the value of the x-axis of the joystick. The range is [-1; 1] (full left to full right). The value returned is a floating point number.

Parameters:
portIDNumber of joystick port to check
BBDECL float BBCALL xJoyY ( int  portID = 0)

Returns the value of the y-axis of the joystick.

This command returns the value of the y-axis of the joystick. The range is [-1; 1] (full left to full right). The value returned is a floating point number.

Parameters:
portIDNumber of joystick port to check
BBDECL float BBCALL xJoyZ ( int  portID = 0)

Returns the value of the z-axis of the joystick.

This command returns the value of the z-axis of the joystick. The range is [-1; 1] (full left to full right). The value returned is a floating point number.

Parameters:
portIDNumber of joystick port to check
BBDECL float BBCALL xJoyU ( int  portID = 0)

Returns the value of the u-axis of the joystick.

Returns a float value in range [-1; 1] that represents the U value of a joystick's output. The U value of a joystick usually corresponds to a joystick's 'slider' or 'throttle' feature, although this may vary depending on the joystick, and will not be available with all joysticks. The value returned is a floating point number.

Parameters:
portIDNumber of joystick port to check
BBDECL float BBCALL xJoyV ( int  portID = 0)

Returns the value of the v-axis of the joystick.

Returns a float value in range [-1; 1] that represents the V value of a joystick's output. The value returned is a floating point number.

Parameters:
portIDNumber of joystick port to check
BBDECL float BBCALL xJoyPitch ( int  portID = 0)

Returns the pitch value of a joystick.

Parameters:
portIDNumber of joystick port to check
BBDECL float BBCALL xJoyYaw ( int  portID = 0)

Returns the yaw value of a joystick.

Parameters:
portIDNumber of joystick port to check
BBDECL float BBCALL xJoyRoll ( int  portID = 0)

Returns the roll value of a joystick.

The roll value of a joystick usually corresponds to a joystick's 'twistable stick' or 'rudder' feature, although this may vary depending on the joystick, and will not be available with all joysticks.

Parameters:
portIDNumber of joystick port to check
BBDECL float BBCALL xJoyHat ( int  portID = 0)

Returns the state of a joystick 'hat' or 'pov' (point-of-view) control.

If the returned value is -1, the hat is currently centred.

Parameters:
portIDNumber of joystick port to check
BBDECL int BBCALL xJoyXDir ( int  portID = 0)

Returns the direction of the x-axis of the joystick.

This command returns the direction of the x-axis of the joystick being pressed. The value is -1 (left) or 1 (right). The value returned is an integer number. Perfect for digital joysticks.

Parameters:
portIDNumber of joystick port to check
BBDECL int BBCALL xJoyYDir ( int  portID = 0)

Returns the direction of the y-axis of the joystick.

This command returns the direction of the y-axis of the joystick being pressed. The value is -1 (left) or 1 (right). The value returned is an integer number. Perfect for digital joysticks.

Parameters:
portIDNumber of joystick port to check
BBDECL int BBCALL xJoyZDir ( int  portID = 0)

Returns the direction of the z-axis of the joystick.

This command returns the direction of the z-axis of the joystick being pressed. The value is -1 (left) or 1 (right). The value returned is an integer number. Perfect for digital joysticks.

Parameters:
portIDNumber of joystick port to check
BBDECL int BBCALL xJoyUDir ( int  portID = 0)

Returns the direction of the u-axis of the joystick.

This command returns the direction of the u-axis of the joystick being pressed. The value is -1 (left) or 1 (right). The value returned is an integer number. Perfect for digital joysticks.

Parameters:
portIDNumber of joystick port to check
BBDECL int BBCALL xJoyVDir ( int  portID = 0)

Returns the direction of the v-axis of the joystick.

This command returns the direction of the v-axis of the joystick being pressed. The value is -1 (left) or 1 (right). The value returned is an integer number. Perfect for digital joysticks.

Parameters:
portIDNumber of joystick port to check
BBDECL int BBCALL xCountJoys ( )

Returns the number of attached joysticks.

This function doesn't update the number of joysticks in runtime. It means that after detaching of the joystick, this function continues to return the same number. Use Input::ListenControllerConnection to handle this.

Returns:
Number of attached joysticks.