Monado OpenXR Runtime
Loading...
Searching...
No Matches
pssense_driver.c File Reference

PlayStation Sense controller prober and driver code. More...

#include "xrt/xrt_prober.h"
#include "os/os_threading.h"
#include "os/os_hid.h"
#include "os/os_time.h"
#include "math/m_api.h"
#include "tracking/t_imu.h"
#include "util/u_var.h"
#include "util/u_debug.h"
#include "util/u_device.h"
#include "util/u_logging.h"
#include "util/u_trace_marker.h"
#include "util/u_linux.h"
#include "util/u_resampler.h"
#include "math/m_mathinclude.h"
#include "math/m_space.h"
#include "math/m_imu_3dof.h"
#include "pssense_interface.h"
#include "pssense_protocol.h"
#include <stdio.h>
#include <errno.h>
Include dependency graph for pssense_driver.c:

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_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_FLOAT , PSSENSE_INDEX_TRIGGER_CLICK , PSSENSE_INDEX_TRIGGER_TOUCH ,
  PSSENSE_INDEX_TRIGGER_VALUE , PSSENSE_INDEX_TRIGGER_PROXIMITY_FLOAT , PSSENSE_INDEX_THUMBSTICK , PSSENSE_INDEX_THUMBSTICK_CLICK ,
  PSSENSE_INDEX_THUMBSTICK_TOUCH , PSSENSE_INDEX_GRIP_POSE , PSSENSE_INDEX_AIM_POSE
}
 Indices where each input is in the input list. More...
 

Functions

static uint32_t crc32_le (uint32_t crc, uint8_t const *p, size_t len)
 
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_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)
 Create a PlayStation Sense controller device.
 
int pssense_found (struct xrt_prober *xp, struct xrt_prober_device **devices, size_t device_count, size_t index, cJSON *attached_data, struct xrt_device **out_xdevs)
 Probing function for PlayStation Sense devices.
 

Variables

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

Detailed Description

PlayStation Sense controller prober and driver code.

Author
Jarett Millard jaret.nosp@m.t.mi.nosp@m.llard.nosp@m.@gma.nosp@m.il.co.nosp@m.m