diff options
author | cnlohr <lohr85@gmail.com> | 2016-11-29 03:03:34 -0500 |
---|---|---|
committer | cnlohr <lohr85@gmail.com> | 2016-11-29 03:03:34 -0500 |
commit | 8388ca81fbc6c0a840e81f6fd805b897d378556b (patch) | |
tree | a267870139b2269ec734813e979ef95302398409 /src/survive_internal.h | |
parent | 570309192b066ae1a440988c2a51dc0a17fa2b1a (diff) | |
download | libsurvive-8388ca81fbc6c0a840e81f6fd805b897d378556b.tar.gz libsurvive-8388ca81fbc6c0a840e81f6fd805b897d378556b.tar.bz2 |
Add a basic vive driver. Gotta figure out how to turn it on.
Diffstat (limited to 'src/survive_internal.h')
-rw-r--r-- | src/survive_internal.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/survive_internal.h b/src/survive_internal.h new file mode 100644 index 0000000..b29b25b --- /dev/null +++ b/src/survive_internal.h @@ -0,0 +1,63 @@ +#ifndef _SURVIVE_INTERNAL_H +#define _SURVIVE_INTERNAL_H + +#include <stdlib.h> +#include <stdio.h> +#include <stdint.h> +#include <libusb-1.0/libusb.h> + +#define SV_INFO( x... ) printf( x ) +#define SV_ERROR( x... ) fprintf( stderr, x ) + +//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 + +struct SurviveContext; +struct SurviveUSBInterface; + + +//XXX TODO: Roll this into the main structure. + +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; + const char * hname; //human names +}; + +struct SurviveContext +{ + struct libusb_context* usbctx; + struct libusb_device_handle * udev[MAX_USB_DEVS]; + struct SurviveUSBInterface uiface[MAX_INTERFACES]; +}; + +void survive_usb_close( struct SurviveContext * t ); +int survive_usb_init( struct SurviveContext * t ); +int survive_usb_poll( struct SurviveContext * ctx ); + +#endif + + |