Joystick Sensor Axis: index

index
  • gets/sets which joystick is being used
     
  • Up to 8 joysticks can be connected

Type: 
  • integer

Range:

  • 0 - 7
Joystick Axis Sensor:
  • Moving the joystick in the selected Axis Direction sends a positive pulse to the connected controller(s).
  • Returning the joystick to the center sends a negative pulse to the connected controller(s).
Sample Code


################  Get the index number of the joystick that is being used

# import bge module
import bge

# get the controller
controller = bge.logic.getCurrentController()

# get the sensor attached to the controller
# my sensor is named Turn

sen = controller.sensors["Turn"]

# index number of joystick being used
jStick = sen.index
 
Sample Code


################  Use index number to select a connected joystick

# import bge module
import bge

# get the controller
controller = bge.logic.getCurrentController()

# get the sensor attached to the controller
# my sensor is named Turn

sen = controller.sensors["Turn"]

# Use index number to select a connected joystick
sen.index = 1