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

Source Code for Module SCA_JoystickSensor

  1  # $Id: SCA_RandomSensor.py 15444 2008-07-05 17:05:05Z lukep $ 
  2  # Documentation for SCA_RandomSensor 
  3  from SCA_ISensor import * 
  4   
5 -class SCA_JoystickSensor(SCA_ISensor):
6 """ 7 This sensor detects player joystick events. 8 """ 9
10 - def getIndex():
11 """ 12 Returns the joystick index to use (from 1 to 8). 13 @rtype: integer 14 """
15 - def setIndex(index):
16 """ 17 Sets the joystick index to use. 18 @param index: The index of this joystick sensor, Clamped between 1 and 8. 19 @type index: integer 20 @note: This is only useful when you have more then 1 joystick connected to your computer - multiplayer games. 21 """
22 - def getAxis():
23 """ 24 Returns the current axis this sensor reacts to. See L{getAxisValue()<SCA_JoystickSensor.getAxisValue>} for the current axis state. 25 @rtype: list 26 @return: 2 values returned are [axisIndex, axisDirection] - see L{setAxis()<SCA_JoystickSensor.setAxis>} for their purpose. 27 @note: When the "All Events" toggle is set, this option has no effect. 28 """
29 - def setAxis(axisIndex, axisDirection):
30 """ 31 @param axisIndex: Set the axis index to use when detecting axis movement. 32 @type axisIndex: integer from 1 to 2 33 @param axisDirection: Set the axis direction used for detecting motion. 0:right, 1:up, 2:left, 3:down. 34 @type axisDirection: integer from 0 to 3 35 @note: When the "All Events" toggle is set, this option has no effect. 36 """
37 - def getAxisValue():
38 """ 39 Returns the state of the joysticks axis. See differs to L{getAxis()<SCA_JoystickSensor.getAxis>} returning the current state of the joystick. 40 @rtype: list 41 @return: 4 values, each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing. 42 43 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. 44 45 left:[-32767, 0, ...], right:[32767, 0, ...], up:[0, -32767, ...], down:[0, 32767, ...] 46 @note: Some gamepads only set the axis on and off like a button. 47 """
48 - def getThreshold():
49 """ 50 Get the axis threshold. See L{setThreshold()<SCA_JoystickSensor.setThreshold>} for details. 51 @rtype: integer 52 """
53 - def setThreshold(threshold):
54 """ 55 Set the axis threshold. 56 @param threshold: Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive. 57 @type threshold: integer 58 """
59 - def getButton():
60 """ 61 Returns the button index the sensor reacts to. See L{getButtonValue()<SCA_JoystickSensor.getButtonValue>} for a list of pressed buttons. 62 @rtype: integer 63 @note: When the "All Events" toggle is set, this option has no effect. 64 """
65 - def setButton(index):
66 """ 67 Sets the button index the sensor reacts to when the "All Events" option is not set. 68 @note: When the "All Events" toggle is set, this option has no effect. 69 """
70 - def getButtonValue():
71 """ 72 Returns a list containing the indicies of the currently pressed buttons. 73 @rtype: list 74 """
75 - def getHat():
76 """ 77 Returns the current hat direction this sensor is set to. 78 [hatNumber, hatDirection]. 79 @rtype: list 80 @note: When the "All Events" toggle is set, this option has no effect. 81 """
82 - def setHat(index):
83 """ 84 Sets the hat index the sensor reacts to when the "All Events" option is not set. 85 @type index: integer 86 """
87 - def getNumAxes():
88 """ 89 Returns the number of axes for the joystick at this index. 90 @rtype: integer 91 """
92 - def getNumButtons():
93 """ 94 Returns the number of buttons for the joystick at this index. 95 @rtype: integer 96 """
97 - def getNumHats():
98 """ 99 Returns the number of hats for the joystick at this index. 100 @rtype: integer 101 """
102 - def isConnected():
103 """ 104 Returns True if a joystick is detected at this joysticks index. 105 @rtype: bool 106 """
107