The PySixense.pyd file is the Python Module you'll want to import:
import PySixense
In general, your code will look somewhat like this:
import PySixense
if PySixense.Init() != PySixense.Constants.Success:
print("Error initializing Sixense SDK")
else:
# code goes here
# ...
# exit properly
assert(PySixense.Deinit() == PySixense.Constants.Success)
When you query controller data using GetData(), GetAllData(), GetNewestData() or GetAllNewestData() you get the data as this structure. Here's what it contains:
pos
- list of 3 numbers describing the controller's 3D position (X, Y, Z)rot_mat
- A list of 3 lists of 3 numbers each representing the matrix describing the controller's rotationjoystick_x
- The analogue stick's horizontal position, with -1 being left, 0 the center and 1 rightjoystick_y
- The analogue stick's vertical position, with -1 being down, 0 the center and 1 uptrigger
- The position of the analogue trigger, with 0 being unpressed and 1 fully pressedbuttons
- Bitflags containing the state of each button, do a bitwise and with the corresponding button mask to retrieve the state. There are the following button constants:PySixense.Constants.Button1
PySixense.Constants.Button2
PySixense.Constants.Button3
PySixense.Constants.Button4
PySixense.Constants.ButtonStart
PySixense.Constants.ButtonBumper
PySixense.Constants.ButtonJoystick
sequence_number
- The read values are numbered from 0 - 255, which each subsequent datapoint getting one more. (The update rate is 60Hz.)rot_quat
- List of 4 numbers representing a quaternion describing the controller's rotationfirmware_revision
- Current firmware revisionhardware_revision
- Current hardware revisionpacket_type
- Type of data packet, currently always 1magnetic_frequency
- Unusedenabled
- Whether this controller is enabled (True or False)controller_index
- Hardware index of the controller this data packet is foris_docked
- Whether the controller is currently in the dock (True or False)which_hand
- The first time the controller is docket, the hand gets set based on the side used. 0 = not docked yet, 1 = left, 2 = right
PySixense.Constants contains a couple of constants used - the Button Bitmasks listed above and the following:
PySixense.Constants.Success
- Returned when functions succeedPySixense.Constants.Failure
- Returned when functions fail
Note that not all functions return their status.
Initializes the SDK. Must be successfully called before using any other function.
Returns status.
Must be called once you're done with the SDK if you called Init()
Returns status.
Returns the maximum number of supported bases, currently 4.
Sets the base of the given index active (i.e. all base-related functions calls will apply to this one)
Returns status
Returns whether the base of the given index is currently connected to the PC. (False or True)
Returns the maximum number of controllers supported (per base?)
Returns the number of active controlles of the active base. Use IsControllerEnabled() to find out which ones are the active ones.
Returns whether the controller of the given index is enabled (False or True)
Returns status and a list containing 4 PySixense.ControllerData (one for each PySixense.GetMaxControllers()) with the newest data.
Returns status and a list containing 4 PySixense.ControllerData (one for each PySixense.GetMaxControllers()) with the data from index_back polls ago (in range [0, PySixense.GetHistorySize() - 1])
Returns status and a PySixense.ControllerData with the newest data for the given controller
Returns status and a PySixense.ControllerData with the data from index_back polls ago (in range [0, PySixense.GetHistorySize() - 1]) for the given controller
How much previous ControllerData is available - usually 10.
Enables or disabled filtering. (i.e. mapping movements to a certain range)
Returns success.
Returns status and whether filtering is enabled (True or False)
Please refer to the Sixense SDK Reference
Please refer to the Sixense SDK Reference. Returns a 5-tuple.
On controllers that support it (not the Razer Hydra), this triggers a vibration lasting duration_100ms deciseconds. pattern_id is currently ignored.
Returns status.
Deprecated, refer to the Sixense SDK Reference if you really need it.
Only for wireless devices. Refer to the Sixense SDK Reference if you need it.
Only for wireless devices. Refer to the Sixense SDK Reference if you need it. Returns a 2-tuple.
Only available on the Wireless Devkits. Refer to the Sixense SDK Reference if you need it.
Only available on the Wireless Devkits. Refer to the Sixense SDK Reference if you need it. Returns a 4-tuple