Package: py-oculus-touch
What is it?This is a python library that allows you to interface with your Oculus Touch controllers and headset. It is a wrapper for theauto_oculus_touchproject.With it, you can read the current state of the controllers and headset, send button presses to the controller, or move the thumbsticks.Installationpipinstallpy_oculus_touchExample UsageBelow is a short program that will vibrate both controllers for 1 second whenever the X button is pressed while the headset is being worn.frompy_oculus_touchimportOculusTouch,OculusTouchControllerEnumoculus=OculusTouch()whileTrue:print("\n")wearing=oculus.Wearing()print(f"Headset is{'ON'ifwearingelse'OFF'}your head")x=oculus.GetPositionX(OculusTouchControllerEnum.Head)y=oculus.GetPositionY(OculusTouchControllerEnum.Head)z=oculus.GetPositionZ(OculusTouchControllerEnum.Head)yaw=oculus.GetYaw(OculusTouchControllerEnum.Head)pitch=oculus.GetPitch(OculusTouchControllerEnum.Head)roll=oculus.GetRoll(OculusTouchControllerEnum.Head)print(f"Headset Position: ({x},{y},{z}), Yaw:{yaw}, Pitch:{pitch}, Roll:{roll}")buttons_down:list=oculus.GetButtonsDownList()# Get a list of buttons that are currently held downsensors_touched:list=oculus.GetTouchDownList()# Get a list of capacitive sensors that are currently being touchedprint(f"These buttons are down:{buttons_down}")print(f"These sensors are touched:{sensors_touched}")print("Here's a vibration for fun")oculus.Vibrate(OculusTouchControllerEnum.Left)# Vibrate the left controlleroculus.Vibrate(OculusTouchControllerEnum.Right)# Vibrate the right controlleroculus.PollAndSleep(1.0)# Poll and wait for 1 secondThis is a smaple output from the above program:Headset is ON your head
Headset Position: (0.002324591390788555, 0.0881958156824112, -0.02958393096923828), Yaw: 0.26628559827804565, Pitch: 32.98610305786133, Roll: -2.244016647338867
These buttons are down: []
These sensors are touched: []
Here's a vibration for fun


Headset is ON your head
Headset Position: (0.0005310606211423874, 0.09536674618721008, 0.0015068724751472473), Yaw: -0.9234217405319214, Pitch: 35.654449462890625, Roll: -3.4883065223693848
These buttons are down: []
These sensors are touched: [<OculusTouchButtonEnum.RThumb: 4>, <OculusTouchButtonEnum.LThumb: 1024>]
Here's a vibration for fun


Headset is ON your head
Headset Position: (3.6899931728839874e-05, 0.09039056301116943, -0.018536627292633057), Yaw: 3.5531980991363525, Pitch: 33.512542724609375, Roll: -5.120441913604736
These buttons are down: [<OculusTouchButtonEnum.RThumb: 4>, <OculusTouchButtonEnum.LThumb: 1024>]
These sensors are touched: [<OculusTouchButtonEnum.RThumb: 4>, <OculusTouchButtonEnum.LThumb: 1024>]
Here's a vibration for fun


Headset is ON your head
Headset Position: (0.009187383577227592, 0.0899086445569992, -0.02320261299610138), Yaw: 5.528964042663574, Pitch: 33.527103424072266, Roll: -5.911553382873535
These buttons are down: []
These sensors are touched: [<OculusTouchButtonEnum.A: 1>, <OculusTouchButtonEnum.B: 2>, <OculusTouchButtonEnum.X: 256>, <OculusTouchButtonEnum.Y: 512>, <OculusTouchButtonEnum.LThumb: 1024>]
Here's a vibration for funAPI ReferenceInitOculusInitialize the Oculus API.Parameterspoll: boolean(Optional): If true, polls the Oculus API after initializing. Defaults to true.Returnsnumber: Return code from the initialization process.PollPolls the Oculus Touch API for state updates.ParametersNoneReturnsNoneSleepBlocks the runtime and waits for the specified length. Useful for sleeping between polls.Parameterslength: number(Optional): Length of time to sleep in seconds. Defaults to 0.1.ReturnsPromise<void>: A Promise that resolves after the specified length of time.PollAndSleepCombines thePoll()andSleep()functions.Parameterslength: number(Optional): Length of time to sleep in seconds. Defaults to 0.1.ReturnsPromise<void>: A Promise that resolves after the specified length of time.WearingChecks if the user is wearing the headset.ParametersNoneReturnsboolean: True if the user is wearing the headset, false otherwise.IsPressedChecks if the specified button was pressed in the current poll. "Pressed" and "Down" are not the same thing.Parametersbutton: OculusTouchButtonEnum: The button to check.Returnsboolean: True if the button was pressed, false otherwise.IsReleasedChecks if the specified button was released in the current poll.Parametersbutton: OculusTouchButtonEnum: The button to check.Returnsboolean: True if the button was released, false otherwise.IsDownChecks if the specified button is currently held down. "Pressed" and "Down" are not the same thing.Parametersbutton: OculusTouchButtonEnum: The button to check.Returnsboolean: True if the button is held down, false otherwise.IsTouchPressedChecks if the specified button's capacitor was touched in the current poll. "Pressed" and "Down" are not the same thing.Parameterssensor: OculusTouchSensorEnum: The sensor to check.Returnsboolean: True if the button's capacitor was touched, false otherwise.IsTouchReleasedChecks if the specified button's capacitor was released in the current poll.Parameterssensor: OculusTouchSensorEnum: The sensor to check.Returnsboolean: True if the button's capacitor was released, false otherwise.IsTouchDownChecks if the specified button's capacitor is currently being touched. "Pressed" and "Down" are not the same thing.Parameterssensor: OculusTouchSensorEnum: The sensor to check.Returnsboolean: True if the button's capacitor is being touched, false otherwise.ReachedChecks whether a specified axis has reached a specified threshold value in between the last poll.Parametersaxis: OculusTouchAxisEnum: The axis to check.value: number: The threshold value to check against.Returnsnumber: Return code indicating if the axis has reached the threshold. 0 if the threshold wasn't crossed. 1 if the threshold was crossed in the positive direction. -1 if it was crossed in the negative direction.GetAxisReturns the value of the specified axis.Parametersaxis: OculusTouchAxisEnum: The axis to query.Returnsnumber: The current value of the specified axis.GetButtonsDownReturns a bitmask of all buttons currently held down. "Pressed" and "Down" are not the same thing.ParametersNoneReturnsnumber: Bitmask representing buttons currently held down.GetButtonsDownListReturns a list of all buttons currently held down. "Pressed" and "Down" are not the same thing.ParametersNoneReturnsOculusTouchButtonEnum[]: List of buttons currently held down.GetButtonsReleasedReturns a bitmask of all buttons released in the current poll.ParametersNoneReturnsnumber: Bitmask representing buttons released in the current poll.GetButtonsReleasedListReturns a list of all buttons released in the current poll.ParametersNoneReturnsOculusTouchButtonEnum[]: List of buttons released in the current poll.GetButtonsPressedReturns a bitmask of all buttons pressed in the current poll. "Pressed" and "Down" are not the same thing.ParametersNoneReturnsnumber: Bitmask representing buttons pressed in the current poll.GetButtonsPressedListReturns a list of all buttons pressed in the current poll. "Pressed" and "Down" are not the same thing.ParametersNoneReturnsOculusTouchButtonEnum[]: List of buttons pressed in the current poll.GetTouchDownReturns a bitmask of all buttons whose capacitors are currently being touched. "Pressed" and "Down" are not the same thing.ParametersNoneReturnsnumber: Bitmask representing buttons whose capacitors are currently being touched.GetTouchDownListReturns a list of all buttons whose capacitors are currently being touched. "Pressed" and "Down" are not the same thing.ParametersNoneReturnsOculusTouchSensorEnum[]: List of buttons whose capacitors are currently being touched.GetTouchPressedReturns a bitmask of all buttons whose capacitors were touched in the current poll. "Pressed" and "Down" are not the same thing.ParametersNoneReturnsnumber: Bitmask representing buttons whose capacitors were touched in the current poll.GetTouchPressedListReturns a list of all buttons whose capacitors were touched in the current poll. "Pressed" and "Down" are not the same thing.ParametersNoneReturnsOculusTouchSensorEnum[]: List of buttons whose capacitors were touched in the current poll.GetTouchReleasedReturns a bitmask of all buttons whose capacitors were released in the current poll.ParametersNoneReturnsnumber: Bitmask representing buttons whose capacitors were released in the current poll.GetTouchReleasedListReturns a list of all buttons whose capacitors were released in the current poll.ParametersNoneReturnsOculusTouchSensorEnum[]: List of buttons whose capacitors were released in the current poll.GetTriggerReturns the value of a specified trigger.Parametershand: OculusTouchHandEnum: The hand (left or right) of the trigger.trigger: OculusTouchTriggerEnum: The trigger (index or hand) to query.Returnsnumber: The value of the specified trigger.GetThumbStickReturns the value of a specified thumbstick's axis.Parametershand: OculusTouchHandEnum: The hand (left or right) of the thumbstick.axis: OculusTouchAxisEnum: The axis (x or y) of the thumbstick to query.Returnsnumber: The value of the specified thumbstick's axis.VibrateVibrates a specified controller.Parameterscontroller: OculusTouchControllerEnum: The controller to vibrate.frequency: OculusTouchVibrationFrequencyEnum(Optional): The vibration frequency. Default isOculusTouchVibrationFrequencyEnum.Medium.amplitude: number(Optional): The amplitude of the vibration, range [0, 255]. Default is 128.length: number(Optional): The length of the vibration in seconds, 0 for infinite. Default is 1.0.ThrowsError: If the amplitude is not in the range [0, 255].ReturnsNoneGetYawReturns the yaw of a specified controller. Yaw is rotation around the y-axis.Parameterscontroller: OculusTouchControllerEnum: The controller to query.Returnsnumber: The yaw (rotation around the y-axis) of the specified controller.GetPitchReturns the pitch of a specified controller. Pitch is rotation around the x-axis.Parameterscontroller: OculusTouchControllerEnum: The controller to query.Returnsnumber: The pitch (rotation around the x-axis) of the specified controller.GetRollReturns the roll of a specified controller. Roll is rotation around the z-axis.Parameterscontroller: OculusTouchControllerEnum: The controller to query.Returnsnumber: The roll (rotation around the z-axis) of the specified controller.GetPositionXReturns the x position of a specified controller.Parameterscontroller: OculusTouchControllerEnum: The controller to query.Returnsnumber: The x position of the specified controller.GetPositionYReturns the y position of a specified controller.Parameterscontroller: OculusTouchControllerEnum: The controller to query.Returnsnumber: The y position of the specified controller.GetPositionZReturns the z position of a specified controller.Parameterscontroller: OculusTouchControllerEnum: The controller to query.Returnsnumber: The z position of the specified controller.SetTrackingOriginSets the tracking origin of the headset. This is the point in space that the headset will consider to be the origin (0, 0, 0).Parametersorigin: OculusTouchTrackingOriginEnum: The tracking origin to set.ReturnsNoneResetFacingResets the yaw of a specified controller. Yaw is rotation around the y-axis.Parameterscontroller: OculusTouchControllerEnum: The controller for which to reset the yaw.ReturnsNoneInitvJoyInitializes the vJoy driver. This must be called before any vJoy functions can be used.Parametersdevice: number: The vJoy device number to initialize.ThrowsError: If there is an error during initialization.ReturnsNoneSetvJoyAxisSets the value of a specified vJoy axis.Parametersaxis: OculusTouchvJoyDeviceEnum: The vJoy axis to set.value: number: The value to set, range [0.0, 1.0].ReturnsNoneSetvJoyAxisUSets the value of a specified vJoy axis using a different range.Parametersaxis: OculusTouchvJoyDeviceEnum: The vJoy axis to set.value: number: The value to set, range [0.0, 1.0], mapped to [-1.0, 1.0].ReturnsNoneSetvJoyButtonSets the value of a specified vJoy button.Parametersbutton: OculusTouchButtonEnum: The vJoy button to set.value: number: The value to set, range [0, 1].ReturnsNoneSendRawMouseMoveSends a raw mouse move event to the host computer.Parametersx: number: The relative movement in the x direction.y: number: The relative movement in the y direction.z: number: The relative movement in the z direction.ReturnsNoneSendRawMouseButtonDownSends a raw mouse button down event to the host computer.Parametersbutton: OculusTouchRawMouseButtonEnum: The button to press.ReturnsNoneSendRawMouseButtonUpSends a raw mouse button up event to the host computer.Parametersbutton: OculusTouchRawMouseButtonEnum: The button to release.ReturnsNone