From f92f5dc93cbb53a99da51984541a7e4a70605639 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 25 Feb 2017 13:29:07 -0500 Subject: Update files, working lhfind whithin libsurvive. --- src/survive_internal.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/survive_internal.h') diff --git a/src/survive_internal.h b/src/survive_internal.h index 0d0b8a4..19aa956 100644 --- a/src/survive_internal.h +++ b/src/survive_internal.h @@ -67,16 +67,16 @@ struct SurviveCalData; struct BaseStationData { uint8_t PositionSet:1; - float Position[3]; - float Quaternion[4]; + FLT Position[3]; + FLT Quaternion[4]; uint8_t OOTXSet:1; uint32_t BaseStationID; - float fcalphase[2]; - float fcaltilt[2]; - float fcalcurve[2]; - float fcalgibpha[2]; - float fcalgibmag[2]; + FLT fcalphase[2]; + FLT fcaltilt[2]; + FLT fcalcurve[2]; + FLT fcalgibpha[2]; + FLT fcalgibmag[2]; }; struct SurviveContext -- cgit v1.2.3 From 55cedfc6a6b035d6eb54457782818fef61cae500 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 25 Feb 2017 23:52:48 -0500 Subject: Huge shift: Put HTC vive into its own file, to free up the rest of the system for libsurvive. --- src/survive_internal.h | 65 ++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 42 deletions(-) (limited to 'src/survive_internal.h') diff --git a/src/survive_internal.h b/src/survive_internal.h index 19aa956..3dc471a 100644 --- a/src/survive_internal.h +++ b/src/survive_internal.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include "survive_driverman.h" #include #include @@ -27,39 +27,12 @@ //XXX TODO This one needs to be rewritten. #define SV_KILL() exit(0) -#define USB_DEV_HMD 0 -#define USB_DEV_LIGHTHOUSE 1 -#define USB_DEV_WATCHMAN1 2 -#define USB_DEV_WATCHMAN2 3 -#define MAX_USB_DEVS 4 - - -#define USB_IF_HMD 0 -#define USB_IF_LIGHTHOUSE 1 -#define USB_IF_WATCHMAN1 2 -#define USB_IF_WATCHMAN2 3 -#define USB_IF_LIGHTCAP 4 -#define MAX_INTERFACES 5 - #define INTBUFFSIZE 64 #define SENSORS_PER_OBJECT 32 struct SurviveContext; struct SurviveUSBInterface; -typedef void (*usb_callback)( struct SurviveUSBInterface * ti ); - -struct SurviveUSBInterface -{ - struct libusb_transfer * transfer; - struct SurviveContext * ctx; - int actual_len; - uint8_t buffer[INTBUFFSIZE]; - usb_callback cb; - int which_interface_am_i; //for indexing into uiface - const char * hname; //human-readable names -}; - //This is defined in survive.h struct SurviveObject; struct SurviveCalData; @@ -81,35 +54,43 @@ struct BaseStationData struct SurviveContext { - //USB Subsystem - struct libusb_context* usbctx; - struct libusb_device_handle * udev[MAX_USB_DEVS]; - struct SurviveUSBInterface uiface[MAX_INTERFACES]; - text_feedback_func faultfunction; text_feedback_func notefunction; light_process_func lightproc; imu_process_func imuproc; angle_process_func angleproc; - //Calibration data: struct BaseStationData bsd[NUM_LIGHTHOUSES]; struct SurviveCalData * calptr; //If and only if the calibration subsystem is attached. - //Data Subsystem. These should be last, as there may be additional surviveobjects. - struct SurviveObject headset; - struct SurviveObject watchman[2]; //Currently only two supported watchmen. + struct SurviveObject ** objs; + int objs_ct; + void ** drivers; + DeviceDriverCb * driverpolls; + DeviceDriverCb * drivercloses; + DeviceDriverMagicCb * drivermagics; + int driver_ct; }; +int survive_add_object( struct SurviveContext * ctx, struct SurviveObject * obj ); + +void survive_add_driver( struct SurviveContext * ctx, void * payload, DeviceDriverCb poll, DeviceDriverCb close, DeviceDriverMagicCb magic ); + +//For lightcap, etc. Don't change this structure at all. Regular vive is dependent on it being exactly as-is. +struct LightcapElement +{ + uint8_t sensor_id; + uint8_t type; + uint16_t length; + uint32_t timestamp; +} __attribute__((packed)); + +//This is the disambiguator function, for taking light timing and figuring out place-in-sweep for a given photodiode. +void handle_lightcap( struct SurviveObject * so, struct LightcapElement * le ); -//USB Subsystem -void survive_usb_close( struct SurviveContext * t ); -int survive_usb_init( struct SurviveContext * t ); -int survive_usb_poll( struct SurviveContext * ctx ); -int survive_get_config( char ** config, struct SurviveContext * ctx, int devno, int interface, int send_extra_magic ); //Accept Data from backend. void survive_data_cb( struct SurviveUSBInterface * si ); -- cgit v1.2.3 From 51751d4a9f407f526de2b626d44e14690fbef004 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 26 Feb 2017 10:28:56 -0500 Subject: cleanup --- src/survive_internal.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/survive_internal.h') diff --git a/src/survive_internal.h b/src/survive_internal.h index 3dc471a..5962623 100644 --- a/src/survive_internal.h +++ b/src/survive_internal.h @@ -33,6 +33,10 @@ struct SurviveContext; struct SurviveUSBInterface; +typedef int (*DeviceDriverCb)( struct SurviveContext * ctx, void * driver ); +typedef int (*DeviceDriverMagicCb)( struct SurviveContext * ctx, void * driver, int magic_code, void * data, int datalen ); + + //This is defined in survive.h struct SurviveObject; struct SurviveCalData; -- cgit v1.2.3