From a015a5bc3631f813281c5af85a29b9d84a3eb924 Mon Sep 17 00:00:00 2001 From: Mike Turvey Date: Tue, 19 Dec 2017 23:30:52 -0700 Subject: Add support for using only 1 lighthouse Change adds a config option for the number of "active" lighthouses, which can be 1. Calibrate will run with a single lighthouse if the new config option LighthouseCount is set to 1. --- include/libsurvive/survive.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/libsurvive/survive.h') diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index 1532d62..c4b2abe 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -102,6 +102,7 @@ struct SurviveContext struct config_group* lh_config; //lighthouse configs //Calibration data: + int activeLighthouses; BaseStationData bsd[NUM_LIGHTHOUSES]; SurviveCalData * calptr; //If and only if the calibration subsystem is attached. -- cgit v1.2.3 From 04e44b9f1c1b65198ea1ac883dcd9f153933413d Mon Sep 17 00:00:00 2001 From: Mike Turvey Date: Tue, 2 Jan 2018 21:37:57 -0700 Subject: Capturing Button Inputs Currently only working on Windows over USB interface Inputs are only printed out, still need to propagate them up the stack. Buttons are placed in a queue, and "processed" on a different thread to avoid starvation. --- include/libsurvive/survive.h | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'include/libsurvive/survive.h') diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index c4b2abe..f3a17c8 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -4,6 +4,7 @@ #include #include "survive_types.h" #include "poser.h" +#include "os_generic.h" #ifdef __cplusplus extern "C" { @@ -18,7 +19,7 @@ struct SurviveObject char codename[4]; //3 letters, null-terminated. Currently HMD, WM0, WM1. char drivername[4]; //3 letters for driver. Currently "HTC" - int16_t buttonmask; + int32_t buttonmask; int16_t axis1; int16_t axis2; @@ -90,6 +91,37 @@ struct BaseStationData struct config_group; +#define BUTTON_QUEUE_MAX_LEN 32 + +#define BUTTON_EVENT_BUTTON_NONE 0 +#define BUTTON_EVENT_BUTTON_DOWN 1 +#define BUTTON_EVENT_BUTTON_UP 2 +#define BUTTON_EVENT_AXIS_CHANGED 3 + +// note: buttonId and axisId are 1-indexed values. +// a value of 0 for an id means that no data is present in that value +// additionally, when x and y values are both present in axis data, +// axis1 will be x, axis2 will be y. +typedef struct +{ + uint8_t isPopulated; //probably can remove this given the semaphore in the parent struct. helps with debugging + uint8_t eventType; + uint8_t buttonId; + uint8_t axis1Id; + uint16_t axis1Val; + uint8_t axis2Id; + uint16_t axis2Val; + SurviveObject *so; +} ButtonQueueEntry; + +typedef struct +{ + uint8_t nextReadIndex; //init to 0 + uint8_t nextWriteIndex; // init to 0 + og_sema_t buttonservicesem; + ButtonQueueEntry entry[BUTTON_QUEUE_MAX_LEN]; +} ButtonQueue; + struct SurviveContext { text_feedback_func faultfunction; @@ -114,6 +146,12 @@ struct SurviveContext DeviceDriverCb * drivercloses; DeviceDriverMagicCb * drivermagics; int driver_ct; + + uint8_t isClosing; // flag to indicate if threads should terminate themselves + + og_thread_t buttonservicethread; + ButtonQueue buttonQueue; + }; SurviveContext * survive_init( int headless ); -- cgit v1.2.3 From f183aa480c549695ac5b481fade04e62f71d1e0a Mon Sep 17 00:00:00 2001 From: Mike Turvey Date: Wed, 3 Jan 2018 18:58:43 -0700 Subject: Controller Buttons Fully Implemented Fully plumbed support for controller buttons Also, commented haptic call because it messed with the vive_magic calls, given where I had it. --- include/libsurvive/survive.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include/libsurvive/survive.h') diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index f3a17c8..e4afadf 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -93,10 +93,7 @@ struct config_group; #define BUTTON_QUEUE_MAX_LEN 32 -#define BUTTON_EVENT_BUTTON_NONE 0 -#define BUTTON_EVENT_BUTTON_DOWN 1 -#define BUTTON_EVENT_BUTTON_UP 2 -#define BUTTON_EVENT_AXIS_CHANGED 3 + // note: buttonId and axisId are 1-indexed values. // a value of 0 for an id means that no data is present in that value @@ -129,6 +126,7 @@ struct SurviveContext light_process_func lightproc; imu_process_func imuproc; angle_process_func angleproc; + button_process_func buttonproc; struct config_group* global_config_values; struct config_group* lh_config; //lighthouse configs @@ -163,6 +161,7 @@ void survive_install_error_fn( SurviveContext * ctx, text_feedback_func fbp ); void survive_install_light_fn( SurviveContext * ctx, light_process_func fbp ); void survive_install_imu_fn( SurviveContext * ctx, imu_process_func fbp ); void survive_install_angle_fn( SurviveContext * ctx, angle_process_func fbp ); +void survive_install_button_fn( SurviveContext * ctx, button_process_func fbp ); void survive_close( SurviveContext * ctx ); int survive_poll( SurviveContext * ctx ); @@ -185,6 +184,7 @@ int survive_cal_get_status( struct SurviveContext * ctx, char * description, int void survive_default_light_process( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length , uint32_t lh); void survive_default_imu_process( SurviveObject * so, int mode, FLT * accelgyro, uint32_t timecode, int id ); void survive_default_angle_process( SurviveObject * so, int sensor_id, int acode, uint32_t timecode, FLT length, FLT angle, uint32_t lh ); +void survive_default_button_process(SurviveObject * so, uint8_t eventType, uint8_t buttonId, uint8_t axis1Id, uint16_t axis1Val, uint8_t axis2Id, uint16_t axis2Val); ////////////////////// Survive Drivers //////////////////////////// -- cgit v1.2.3 From 499b80ae7b538f8e66f5ec8bfa60c7136a3babf5 Mon Sep 17 00:00:00 2001 From: Mike Turvey Date: Thu, 4 Jan 2018 08:47:42 -0700 Subject: Haptic Call Plumbed The plumbing is now in place for the haptic call. Left in place a "demo" where haptic is called when a controller's trigger is pulled --- include/libsurvive/survive.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/libsurvive/survive.h') diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index e4afadf..0cfab1f 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -19,6 +19,7 @@ struct SurviveObject char codename[4]; //3 letters, null-terminated. Currently HMD, WM0, WM1. char drivername[4]; //3 letters for driver. Currently "HTC" + void *driver; int32_t buttonmask; int16_t axis1; @@ -68,6 +69,7 @@ struct SurviveObject FLT* gyro_bias; // size is FLT*3. contains x,y,z FLT* gyro_scale; // size is FLT*3. contains x,y,z + haptic_func haptic; //Debug int tsl; @@ -179,6 +181,9 @@ void survive_cal_install( SurviveContext * ctx ); //XXX This will be removed if // Read back a human-readable string description of the calibration status int survive_cal_get_status( struct SurviveContext * ctx, char * description, int description_length ); +// Induce haptic feedback +int survive_haptic(SurviveObject * so, uint8_t reserved, uint16_t pulseHigh, uint16_t pulseLow, uint16_t repeatCount); + //Call these from your callback if overridden. //Accept higher-level data. void survive_default_light_process( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length , uint32_t lh); -- cgit v1.2.3 From 735a8bd11070b0c563e891ff8b70ce297a52a367 Mon Sep 17 00:00:00 2001 From: Mike Turvey Date: Fri, 5 Jan 2018 03:54:29 -0700 Subject: Add standard output mechanism for posers Added a raw pose output/ callback that the posers can call when they have calculated a pose. --- include/libsurvive/survive.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include/libsurvive/survive.h') diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index 0cfab1f..4821e63 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -129,6 +129,7 @@ struct SurviveContext imu_process_func imuproc; angle_process_func angleproc; button_process_func buttonproc; + raw_pose_func rawposeproc; struct config_group* global_config_values; struct config_group* lh_config; //lighthouse configs @@ -163,7 +164,8 @@ void survive_install_error_fn( SurviveContext * ctx, text_feedback_func fbp ); void survive_install_light_fn( SurviveContext * ctx, light_process_func fbp ); void survive_install_imu_fn( SurviveContext * ctx, imu_process_func fbp ); void survive_install_angle_fn( SurviveContext * ctx, angle_process_func fbp ); -void survive_install_button_fn( SurviveContext * ctx, button_process_func fbp ); +void survive_install_button_fn(SurviveContext * ctx, button_process_func fbp); +void survive_install_raw_pose_fn(SurviveContext * ctx, raw_pose_func fbp); void survive_close( SurviveContext * ctx ); int survive_poll( SurviveContext * ctx ); @@ -190,6 +192,7 @@ void survive_default_light_process( SurviveObject * so, int sensor_id, int acode void survive_default_imu_process( SurviveObject * so, int mode, FLT * accelgyro, uint32_t timecode, int id ); void survive_default_angle_process( SurviveObject * so, int sensor_id, int acode, uint32_t timecode, FLT length, FLT angle, uint32_t lh ); void survive_default_button_process(SurviveObject * so, uint8_t eventType, uint8_t buttonId, uint8_t axis1Id, uint16_t axis1Val, uint8_t axis2Id, uint16_t axis2Val); +void survive_default_raw_pose_process(SurviveObject * so, uint8_t lighthouse, FLT *position, FLT *quaternion); ////////////////////// Survive Drivers //////////////////////////// -- cgit v1.2.3 From 7817da63526f35d10d6d4f6b3d9c02280719e023 Mon Sep 17 00:00:00 2001 From: Mike Turvey Date: Mon, 15 Jan 2018 21:50:10 -0700 Subject: Fix compiler warnings --- include/libsurvive/survive.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include/libsurvive/survive.h') diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index 4821e63..3d0d472 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -4,7 +4,6 @@ #include #include "survive_types.h" #include "poser.h" -#include "os_generic.h" #ifdef __cplusplus extern "C" { @@ -117,7 +116,7 @@ typedef struct { uint8_t nextReadIndex; //init to 0 uint8_t nextWriteIndex; // init to 0 - og_sema_t buttonservicesem; + void* buttonservicesem; ButtonQueueEntry entry[BUTTON_QUEUE_MAX_LEN]; } ButtonQueue; @@ -150,7 +149,7 @@ struct SurviveContext uint8_t isClosing; // flag to indicate if threads should terminate themselves - og_thread_t buttonservicethread; + void* buttonservicethread; ButtonQueue buttonQueue; }; -- cgit v1.2.3 From c9fec03986e23958e0dee3f0d1749fa8f5769ba7 Mon Sep 17 00:00:00 2001 From: Mike Turvey Date: Tue, 16 Jan 2018 20:37:56 -0700 Subject: Add user pointer to survive context --- include/libsurvive/survive.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/libsurvive/survive.h') diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index 3d0d472..30f5817 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -152,6 +152,8 @@ struct SurviveContext void* buttonservicethread; ButtonQueue buttonQueue; + void *user_ptr; + }; SurviveContext * survive_init( int headless ); -- cgit v1.2.3 From 728f6f9e7f0a99aa584e7f35ade387e852b5fa83 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Wed, 7 Mar 2018 22:41:10 -0700 Subject: Added a check at init that makes sure the user agrees with what FLT is --- include/libsurvive/survive.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include/libsurvive/survive.h') diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index 30f5817..d9b5f08 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -156,7 +156,15 @@ struct SurviveContext }; -SurviveContext * survive_init( int headless ); +SurviveContext * survive_init_internal( int headless ); + +// Baked in size of FLT to verify users of the library have the correct setting. +void survive_verify_FLT_size(uint32_t user_size); + +static inline SurviveContext * survive_init( int headless ) { + survive_verify_FLT_size(sizeof(FLT)); + return survive_init_internal( headless ); +} //For any of these, you may pass in 0 for the function pointer to use default behavior. //In general unless you are doing wacky things like recording or playing back data, you won't need to use this. -- cgit v1.2.3