aboutsummaryrefslogtreecommitdiff
path: root/src/survive_internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/survive_internal.h')
-rw-r--r--src/survive_internal.h79
1 files changed, 32 insertions, 47 deletions
diff --git a/src/survive_internal.h b/src/survive_internal.h
index 0d0b8a4..5962623 100644
--- a/src/survive_internal.h
+++ b/src/survive_internal.h
@@ -17,7 +17,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
-#include <libusb-1.0/libusb.h>
+#include "survive_driverman.h"
#include <zlib.h>
#include <survive.h>
@@ -27,38 +27,15 @@
//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 );
+typedef int (*DeviceDriverCb)( struct SurviveContext * ctx, void * driver );
+typedef int (*DeviceDriverMagicCb)( struct SurviveContext * ctx, void * driver, int magic_code, void * data, int datalen );
-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;
@@ -67,49 +44,57 @@ 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
{
- //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 );