Monado OpenXR Runtime
Loading...
Searching...
No Matches
PlayStation Sense driver

Driver for the PlayStation Sense motion controllers. More...

Collaboration diagram for PlayStation Sense driver:

Files

file  pssense_driver.c
 PlayStation Sense controller prober and driver code.
 
file  pssense_interface.h
 Interface to PlayStation Sense driver.
 
file  pssense_protocol.h
 PlayStation Sense controller prober and driver code.
 

Data Structures

struct  pssense_input_state
 PlayStation Sense state parsed from a data packet. More...
 
struct  pssense_device
 A single PlayStation Sense Controller. More...
 

Macros

#define PSSENSE_TRACE(p, ...)   U_LOG_XDEV_IFL_T(&p->base, p->log_level, __VA_ARGS__)
 
#define PSSENSE_DEBUG(p, ...)   U_LOG_XDEV_IFL_D(&p->base, p->log_level, __VA_ARGS__)
 
#define PSSENSE_DEBUG_HEX(p, data, data_size)   U_LOG_XDEV_IFL_D_HEX(&p->base, p->log_level, data, data_size)
 
#define PSSENSE_WARN(p, ...)   U_LOG_XDEV_IFL_W(&p->base, p->log_level, __VA_ARGS__)
 
#define PSSENSE_ERROR(p, ...)   U_LOG_XDEV_IFL_E(&p->base, p->log_level, __VA_ARGS__)
 
#define SET_INPUT(NAME)   (pssense->base.inputs[PSSENSE_INDEX_##NAME].name = XRT_INPUT_PSSENSE_##NAME)
 

Enumerations

enum  pssense_input_index {
  PSSENSE_INDEX_PS_CLICK , PSSENSE_INDEX_SHARE_CLICK , PSSENSE_INDEX_OPTIONS_CLICK , PSSENSE_INDEX_SQUARE_CLICK ,
  PSSENSE_INDEX_SQUARE_TOUCH , PSSENSE_INDEX_TRIANGLE_CLICK , PSSENSE_INDEX_TRIANGLE_TOUCH , PSSENSE_INDEX_CROSS_CLICK ,
  PSSENSE_INDEX_CROSS_TOUCH , PSSENSE_INDEX_CIRCLE_CLICK , PSSENSE_INDEX_CIRCLE_TOUCH , PSSENSE_INDEX_SQUEEZE_CLICK ,
  PSSENSE_INDEX_SQUEEZE_TOUCH , PSSENSE_INDEX_SQUEEZE_PROXIMITY , PSSENSE_INDEX_SQUEEZE_PROXIMITY_FLOAT , PSSENSE_INDEX_TRIGGER_CLICK ,
  PSSENSE_INDEX_TRIGGER_TOUCH , PSSENSE_INDEX_TRIGGER_VALUE , PSSENSE_INDEX_TRIGGER_PROXIMITY , PSSENSE_INDEX_TRIGGER_PROXIMITY_FLOAT ,
  PSSENSE_INDEX_THUMBSTICK , PSSENSE_INDEX_THUMBSTICK_CLICK , PSSENSE_INDEX_THUMBSTICK_TOUCH , PSSENSE_INDEX_GRIP_POSE ,
  PSSENSE_INDEX_AIM_POSE , PSSENSE_INPUT_COUNT
}
 Indices where each input is in the input list. More...
 

Functions

static struct pssense_devicefrom_device (struct xrt_device *xdev)
 
static struct pssense_devicefrom_node (struct xrt_frame_node *node)
 
static struct pssense_devicefrom_timing_event_sink (struct t_timing_event_sink *sink)
 
static uint32_t crc32_le (uint32_t crc, uint8_t const *p, size_t len)
 
static void pssense_add_clock_offset_sample (struct pssense_device *pssense, double offset_ns)
 Update the max-tracking clock filter with a new offset sample.
 
static int pssense_read_packet_data (struct pssense_device *pssense, uint8_t *buffer, size_t size, bool check_size)
 Reads one packet from the device, handles time out, locking and checking if the thread has been told to shut down.
 
static void pssense_update_fusion (struct pssense_device *pssense)
 
static bool pssense_handle_read (struct pssense_device *pssense)
 
static int pssense_send_output_report_locked (struct pssense_device *pssense)
 
static void * pssense_run_thread (void *ptr)
 
static void pssense_get_fusion_pose (struct pssense_device *pssense, enum xrt_input_name name, int64_t at_timestamp_ns, struct xrt_space_relation *out_relation)
 
bool pssense_get_calibration_data (struct pssense_device *pssense)
 Retrieving the calibration data report will switch the Sense controller from compat mode into full mode.
 
static uint64_t saturating_add_uint64 (uint64_t a, uint64_t b)
 
static void pssense_node_break_apart (struct xrt_frame_node *node)
 
static void pssense_node_destroy (struct xrt_frame_node *node)
 
static void pssense_timing_event_sink_push (struct t_timing_event_sink *sink, const struct t_timing_event *event)
 
static void pssense_device_destroy (struct xrt_device *xdev)
 
static xrt_result_t pssense_device_update_inputs (struct xrt_device *xdev)
 
static xrt_result_t set_vibration_output (struct pssense_device *pssense, const struct xrt_output_value *value, bool *send_vibration, uint8_t *vibration_amplitude, uint8_t *vibration_mode)
 
static xrt_result_t pssense_set_output (struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value)
 
xrt_result_t pssense_get_output_limits (struct xrt_device *xdev, struct xrt_output_limits *limits)
 
static xrt_result_t pssense_get_tracked_pose (struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, struct xrt_space_relation *out_relation)
 
static xrt_result_t pssense_get_battery_status (struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge)
 
struct xrt_devicepssense_create (struct xrt_prober *xp, struct xrt_prober_device *xpdev, struct xrt_frame_context *xfctx, struct t_timing_event_sink **out_timing_sink)
 Create a PlayStation Sense controller device.
 

Variables

static struct xrt_binding_input_pair touch_inputs_pssense []
 
static struct xrt_binding_output_pair touch_outputs_pssense []
 
static struct xrt_binding_input_pair simple_inputs_pssense []
 
static struct xrt_binding_output_pair simple_outputs_pssense []
 
static struct xrt_binding_profile binding_profiles_pssense []
 
const uint32_t CRC_POLYNOMIAL = 0xedb88320
 

Detailed Description

Driver for the PlayStation Sense motion controllers.

Enumeration Type Documentation

◆ pssense_input_index

#include <drivers/pssense/pssense_driver.c>

Indices where each input is in the input list.

Function Documentation

◆ pssense_add_clock_offset_sample()

static void pssense_add_clock_offset_sample ( struct pssense_device pssense,
double  offset_ns 
)
static

#include <drivers/pssense/pssense_driver.c>

Update the max-tracking clock filter with a new offset sample.

Must be called under the controller_thread lock.

Corresponds to SenseController::AddTimestampOffsetSample in: PSVR2Toolkit/projects/psvr2_openvr_driver_ex/sense_controller.h

References CLAMP, pssense_device::filtered_offset_ns, os_monotonic_get_ns(), and pssense_device::timestamp_offset_ns.

◆ pssense_create()

◆ pssense_get_calibration_data()

bool pssense_get_calibration_data ( struct pssense_device pssense)

#include <drivers/pssense/pssense_driver.c>

Retrieving the calibration data report will switch the Sense controller from compat mode into full mode.

Referenced by pssense_create().

◆ pssense_read_packet_data()

static int pssense_read_packet_data ( struct pssense_device pssense,
uint8_t *  buffer,
size_t  size,
bool  check_size 
)
static

#include <drivers/pssense/pssense_driver.c>

Reads one packet from the device, handles time out, locking and checking if the thread has been told to shut down.

Variable Documentation

◆ binding_profiles_pssense

struct xrt_binding_profile binding_profiles_pssense[]
static

#include <drivers/pssense/pssense_driver.c>

Initial value:
= {
{
.name = XRT_DEVICE_TOUCH_CONTROLLER,
.inputs = touch_inputs_pssense,
.input_count = ARRAY_SIZE(touch_inputs_pssense),
.outputs = touch_outputs_pssense,
.output_count = ARRAY_SIZE(touch_outputs_pssense),
},
{
.name = XRT_DEVICE_SIMPLE_CONTROLLER,
.inputs = simple_inputs_pssense,
.input_count = ARRAY_SIZE(simple_inputs_pssense),
.outputs = simple_outputs_pssense,
.output_count = ARRAY_SIZE(simple_outputs_pssense),
},
}
#define ARRAY_SIZE(a)
Array size helper.
Definition xrt_compiler.h:59

◆ simple_inputs_pssense

struct xrt_binding_input_pair simple_inputs_pssense[]
static

#include <drivers/pssense/pssense_driver.c>

Initial value:
= {
{XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_PSSENSE_TRIGGER_VALUE},
{XRT_INPUT_SIMPLE_MENU_CLICK, XRT_INPUT_PSSENSE_OPTIONS_CLICK},
{XRT_INPUT_SIMPLE_GRIP_POSE, XRT_INPUT_PSSENSE_GRIP_POSE},
{XRT_INPUT_SIMPLE_AIM_POSE, XRT_INPUT_PSSENSE_AIM_POSE},
}

◆ simple_outputs_pssense

struct xrt_binding_output_pair simple_outputs_pssense[]
static

#include <drivers/pssense/pssense_driver.c>

Initial value:
= {
{XRT_OUTPUT_NAME_SIMPLE_VIBRATION, XRT_OUTPUT_NAME_PSSENSE_VIBRATION},
}

◆ touch_inputs_pssense

struct xrt_binding_input_pair touch_inputs_pssense[]
static

#include <drivers/pssense/pssense_driver.c>

Initial value:
= {
{XRT_INPUT_TOUCH_X_CLICK, XRT_INPUT_PSSENSE_SQUARE_CLICK},
{XRT_INPUT_TOUCH_X_TOUCH, XRT_INPUT_PSSENSE_SQUARE_TOUCH},
{XRT_INPUT_TOUCH_Y_CLICK, XRT_INPUT_PSSENSE_TRIANGLE_CLICK},
{XRT_INPUT_TOUCH_Y_TOUCH, XRT_INPUT_PSSENSE_TRIANGLE_TOUCH},
{XRT_INPUT_TOUCH_MENU_CLICK, XRT_INPUT_PSSENSE_PS_CLICK},
{XRT_INPUT_TOUCH_A_CLICK, XRT_INPUT_PSSENSE_CROSS_CLICK},
{XRT_INPUT_TOUCH_A_TOUCH, XRT_INPUT_PSSENSE_CROSS_TOUCH},
{XRT_INPUT_TOUCH_B_CLICK, XRT_INPUT_PSSENSE_CIRCLE_CLICK},
{XRT_INPUT_TOUCH_B_TOUCH, XRT_INPUT_PSSENSE_CIRCLE_TOUCH},
{XRT_INPUT_TOUCH_SYSTEM_CLICK, XRT_INPUT_PSSENSE_PS_CLICK},
{XRT_INPUT_TOUCH_SQUEEZE_VALUE, XRT_INPUT_PSSENSE_SQUEEZE_CLICK},
{XRT_INPUT_TOUCH_TRIGGER_TOUCH, XRT_INPUT_PSSENSE_TRIGGER_TOUCH},
{XRT_INPUT_TOUCH_TRIGGER_VALUE, XRT_INPUT_PSSENSE_TRIGGER_VALUE},
{XRT_INPUT_TOUCH_THUMBSTICK_CLICK, XRT_INPUT_PSSENSE_THUMBSTICK_CLICK},
{XRT_INPUT_TOUCH_THUMBSTICK_TOUCH, XRT_INPUT_PSSENSE_THUMBSTICK_TOUCH},
{XRT_INPUT_TOUCH_THUMBSTICK, XRT_INPUT_PSSENSE_THUMBSTICK},
{XRT_INPUT_TOUCH_GRIP_POSE, XRT_INPUT_PSSENSE_GRIP_POSE},
{XRT_INPUT_TOUCH_AIM_POSE, XRT_INPUT_PSSENSE_AIM_POSE},
{XRT_INPUT_TOUCH_TRIGGER_PROXIMITY, XRT_INPUT_PSSENSE_TRIGGER_PROXIMITY},
}

◆ touch_outputs_pssense

struct xrt_binding_output_pair touch_outputs_pssense[]
static

#include <drivers/pssense/pssense_driver.c>

Initial value:
= {
{XRT_OUTPUT_NAME_TOUCH_HAPTIC, XRT_OUTPUT_NAME_PSSENSE_VIBRATION},
}