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