blob: 70249e391eb38cc8d6045f282f2caa7053e15277 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#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... ) { char stbuff[1024]; sprintf( stbuff, x ); ctx->faultfunction( ctx, stbuff ); }
//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;
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
};
struct SurviveContext
{
//USB Subsystem
struct libusb_context* usbctx;
void(*faultfunction)( struct SurviveContext * ctx, const char * fault );
struct libusb_device_handle * udev[MAX_USB_DEVS];
struct SurviveUSBInterface uiface[MAX_INTERFACES];
};
//USB Subsystem
void survive_usb_close( struct SurviveContext * t );
int survive_usb_init( struct SurviveContext * t );
int survive_usb_poll( struct SurviveContext * ctx );
//Accept Data from backend.
void survive_data_cb( struct SurviveUSBInterface * si );
#endif
|