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

Class SCA_JoystickSensor

source code

PyObjectPlus --+            
               |            
          CValue --+        
                   |        
     SCA_ILogicBrick --+    
                       |    
             SCA_ISensor --+
                           |
                          SCA_JoystickSensor

This sensor detects player joystick events.

Properties:

Instance Methods [hide private]
list
getButtonActiveList()
Returns a list containing the indicies of the currently pressed buttons.
source code
bool
getButtonStatus(buttonIndex)
Returns a bool of the current pressed state of the specified button.
source code
    Deprecated
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, direction)
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
 
reset()
Reset sensor internal state, effect depends on the type of sensor and settings.
source code
integer
getFrequency()
The frequency for pulse mode sensors.
source code
 
getInvert()
True if this sensor activates on negative events.
source code
boolean
getLevel()
Returns whether this sensor is a level detector or a edge detector.
source code
 
getUseNegPulseMode()
True if the sensor is in negative pulse mode.
source code
 
getUsePosPulseMode()
True if the sensor is in positive pulse mode.
source code
 
isPositive()
True if this sensor brick is in a positive state.
source code
 
isTriggered()
True if this sensor brick has triggered the current controller.
source code
 
setFrequency(freq)
Sets the frequency for pulse mode sensors.
source code
 
setInvert(invert)
Sets if this sensor activates on positive or negative events.
source code
 
setLevel(level)
Set whether to detect level or edge transition when entering a state.
source code
 
setUseNegPulseMode(pulse)
Sets negative pulse mode.
source code
 
setUsePosPulseMode(pulse)
Sets positive pulse mode.
source code
    Inherited from SCA_ILogicBrick
integer
getExecutePriority()
Gets the execution priority of this logic brick.
source code
KX_GameObject
getOwner()
Gets the game object associated with this logic brick.
source code
 
setExecutePriority(priority)
Sets the priority of this logic brick.
source code
    Inherited from CValue
string
getName()
Returns the name of the CValue.
source code
    Inherited from PyObjectPlus
bool
isA(game_type)
Check if this is a type or a subtype game_type.
source code
Instance Variables [hide private]
[integer, integer] axis
The axis this sensor reacts to, as a list of two values [axisIndex, axisDirection] axisIndex: the axis index to use when detecting axis movement, 1=primary directional control, 2=secondary directional control.
int axisSingle
(read-only) like axisValues but returns a single axis value that is set by the sensor.
list of ints axisValues
(read-only) The state of the joysticks axis as a list of values numAxis long.
integer button
The button index the sensor reacts to (first button = 0).
boolean connected
(read-only) True if a joystick is connected at this joysticks index.
[integer, integer] hat
The hat the sensor reacts to, as a list of two values: [hatIndex, hatDirection] hatIndex: the hat index to use when detecting hat movement, 1=primary hat, 2=secondary hat (4 max).
int hatSingle
(read-only) like hatValues but returns a single hat direction value that is set by the sensor.
list of ints hatValues
(read-only) The state of the joysticks hats as a list of values numHats long.
integer index
The joystick index to use (from 0 to 7).
integer numAxis
(read-only) The number of axes for the joystick at this index.
integer numButtons
(read-only) The number of buttons for the joystick at this index.
integer numHats
(read-only) The number of hats for the joystick at this index.
integer threshold
Axis threshold.
    Inherited from SCA_ISensor
int frequency
The frequency for pulse mode sensors.
boolean invert
Flag to set if this sensor activates on positive or negative events.
boolean level
Option whether to detect level or edge transition when entering a state.
boolean positive
True if this sensor brick is in a positive state.
boolean tap
When enabled only sensors that are just activated will send a positive event, after this they will be detected as negative by the controllers.
boolean triggered
True if this sensor brick is in a positive state.
boolean useNegPulseMode
Flag to turn negative pulse mode on and off.
boolean usePosPulseMode
Flag to turn positive pulse mode on and off.
    Inherited from SCA_ILogicBrick
int executePriority
This determines the order controllers are evaluated, and actuators are activated (lower priority is executed first).
string name
The name of this CValue derived object (read-only).
KX_GameObject or None in exceptional cases. owner
The game object this logic brick is attached to (read-only).
    Inherited from PyObjectPlus
bool invalid
Test if the object has been freed by the game engine and is no longer valid.
Method Details [hide private]

getButtonStatus(buttonIndex)

source code 
Returns a bool of the current pressed state of the specified button.
Parameters:
  • buttonIndex (integer) - the button index, 0=first button
Returns: bool

getIndex()

source code 
Returns the joystick index to use (from 1 to 8).
Returns: integer

Deprecated: Use the index attribute instead.

setIndex(index)

source code 
Sets the joystick index to use.
Parameters:
  • index (integer) - The index of this joystick sensor, Clamped between 1 and 8.

Deprecated: Use the index attribute instead.

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.

Deprecated: Use the axis attribute instead.

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.

Deprecated: Use the axis attribute instead.

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, ...]

Deprecated: Use the axisValues attribute instead.

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

Deprecated: Use the threshold attribute instead.

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.

Deprecated: Use the threshold attribute instead.

getButton()

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

Deprecated: Use the button attribute instead.

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.

Deprecated: Use the button attribute instead.

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

getButtonValue()

source code 
Returns a list containing the indicies of the currently pressed buttons.
Returns: list

Deprecated: Use the getButtonActiveList method instead.

getHat()

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

Deprecated: Use the hat attribute instead.

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

setHat(index, direction)

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

Deprecated: Use the hat attribute instead.

getNumAxes()

source code 
Returns the number of axes for the joystick at this index.
Returns: integer

Deprecated: Use the numAxis attribute instead.

getNumButtons()

source code 
Returns the number of buttons for the joystick at this index.
Returns: integer

Deprecated: Use the numButtons attribute instead.

getNumHats()

source code 
Returns the number of hats for the joystick at this index.
Returns: integer

Deprecated: Use the numHats attribute instead.

isConnected()

source code 
Returns True if a joystick is detected at this joysticks index.
Returns: bool

Deprecated: Use the connected attribute instead.


Instance Variable Details [hide private]

axis

The axis this sensor reacts to, as a list of two values [axisIndex, axisDirection] axisIndex: the axis index to use when detecting axis movement, 1=primary directional control, 2=secondary directional control. axisDirection: 0=right, 1=up, 2=left, 3=down
Type:
[integer, integer]

axisSingle

(read-only) like axisValues but returns a single axis value that is set by the sensor. Only use this for "Single Axis" type sensors otherwise it will raise an error.
Type:
int

axisValues

(read-only) The state of the joysticks axis as a list of values numAxis long. 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, ...]
Type:
list of ints

button

The button index the sensor reacts to (first button = 0). When the "All Events" toggle is set, this option has no effect.
Type:
integer

hat

The hat the sensor reacts to, as a list of two values: [hatIndex, hatDirection] hatIndex: the hat index to use when detecting hat movement, 1=primary hat, 2=secondary hat (4 max). hatDirection: 1-12
Type:
[integer, integer]

hatValues

(read-only) The state of the joysticks hats as a list of values numHats long. each spesifying the direction of the hat from 1 to 12, 0 when inactive. Hat directions are as follows...
  • 0:None
  • 1:Up
  • 2:Right
  • 4:Down
  • 8:Left
  • 3:Up - Right
  • 6:Down - Right
  • 12:Down - Left
  • 9:Up - Left
Type:
list of ints

index

The joystick index to use (from 0 to 7). The first joystick is always 0.
Type:
integer

threshold

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