Module SCA_JoystickSensor :: Class SCA_JoystickSensor
[hide private]
[frames] | no frames]

Class SCA_JoystickSensor

source code

SCA_ILogicBrick.SCA_ILogicBrick --+    
                                  |    
            SCA_ISensor.SCA_ISensor --+
                                      |
                                     SCA_JoystickSensor

This sensor detects player joystick events.

Instance Methods [hide private]
integer
getIndex()
Returns the joystick index to use (from 1 to 8).
source code
 
setIndex(index)
Sets the joystick index to use.
source code
list
getAxis()
Returns the current axis this sensor reacts to.
source code
 
setAxis(axisIndex, axisDirection) source code
list
getAxisValue()
Returns the state of the joysticks axis.
source code
integer
getThreshold()
Get the axis threshold.
source code
 
setThreshold(threshold)
Set the axis threshold.
source code
integer
getButton()
Returns the button index the sensor reacts to.
source code
 
setButton(index)
Sets the button index the sensor reacts to when the "All Events" option is not set.
source code
list
getButtonValue()
Returns a list containing the indicies of the currently pressed buttons.
source code
list
getHat()
Returns the current hat direction this sensor is set to.
source code
 
setHat(index)
Sets the hat index the sensor reacts to when the "All Events" option is not set.
source code
integer
getNumAxes()
Returns the number of axes for the joystick at this index.
source code
integer
getNumButtons()
Returns the number of buttons for the joystick at this index.
source code
integer
getNumHats()
Returns the number of hats for the joystick at this index.
source code
bool
isConnected()
Returns True if a joystick is detected at this joysticks index.
source code

Inherited from SCA_ISensor.SCA_ISensor: getFrequency, getInvert, getLevel, getUseNegPulseMode, getUsePosPulseMode, isPositive, isTriggered, reset, setFrequency, setInvert, setLevel, setUseNegPulseMode, setUsePosPulseMode

Inherited from SCA_ILogicBrick.SCA_ILogicBrick: getExecutePriority, getOwner, setExecutePriority

Method Details [hide private]

setIndex(index)

source code 

Sets the joystick index to use.

Parameters:
  • index (integer) - The index of this joystick sensor, Clamped between 1 and 8.

Note: This is only useful when you have more then 1 joystick connected to your computer - multiplayer games.

getAxis()

source code 

Returns the current axis this sensor reacts to. See getAxisValue() for the current axis state.

Returns: list
2 values returned are [axisIndex, axisDirection] - see setAxis() for their purpose.

Note: When the "All Events" toggle is set, this option has no effect.

setAxis(axisIndex, axisDirection)

source code 
Parameters:
  • axisIndex (integer from 1 to 2) - Set the axis index to use when detecting axis movement.
  • axisDirection (integer from 0 to 3) - Set the axis direction used for detecting motion. 0:right, 1:up, 2:left, 3:down.

Note: When the "All Events" toggle is set, this option has no effect.

getAxisValue()

source code 

Returns the state of the joysticks axis. See differs to getAxis() returning the current state of the joystick.

Returns: list
4 values, each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.

The first 2 values are used by most joysticks and gamepads for directional control. 3rd and 4th values are only on some joysticks and can be used for arbitary controls.

left:[-32767, 0, ...], right:[32767, 0, ...], up:[0, -32767, ...], down:[0, 32767, ...]

Note: Some gamepads only set the axis on and off like a button.

getThreshold()

source code 

Get the axis threshold. See setThreshold() for details.

Returns: integer

setThreshold(threshold)

source code 

Set the axis threshold.

Parameters:
  • threshold (integer) - Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.

getButton()

source code 

Returns the button index the sensor reacts to. See getButtonValue() for a list of pressed buttons.

Returns: integer

Note: When the "All Events" toggle is set, this option has no effect.

setButton(index)

source code 

Sets the button index the sensor reacts to when the "All Events" option is not set.

Note: When the "All Events" toggle is set, this option has no effect.

getHat()

source code 

Returns the current hat direction this sensor is set to. [hatNumber, hatDirection].

Returns: list

Note: When the "All Events" toggle is set, this option has no effect.

setHat(index)

source code 

Sets the hat index the sensor reacts to when the "All Events" option is not set.

Parameters:
  • index (integer)