-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaoakvm.h
202 lines (157 loc) · 4.54 KB
/
aoakvm.h
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#ifndef AOA_KVM
#define AOA_KVM
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
#include <libusb-1.0/libusb.h>
#include <SDL2/SDL.h>
#include "aoakvm_log.h"
#define HID_EVENT_MOUSE_SIZE (sizeof(HID_EVENT_MOUSE) / sizeof(HID_EVENT_MOUSE[0]))
#define HID_EVENT_TOUCHPAD_SIZE (sizeof(HID_EVENT_TOUCHPAD) / sizeof(HID_EVENT_TOUCHPAD[0]))
#define HID_EVENT_KB_SIZE (sizeof(HID_EVENT_KB) / sizeof(HID_EVENT_KB[0]))
#define AOA_REGISTER_HID 54
#define AOA_UNREGISTER_HID 55
#define AOA_SET_HID_REPORT_DESC 56
#define AOA_SEND_HID_EVENT 57
#define DEFAULT_TIMEOUT 1000
/*
aoakvmMSGScreens_t
This struct holds three surfaces to show for the different states of the usb connection
Fields:
SDL_Surface *waitForDevice;
SDL_Surface *aoaInitialized;
SDL_Surface *waitForDataTransmission;
*/
struct aoakvmMSGScreens {
SDL_Surface *waitForDevice;
SDL_Surface *aoaInitialized;
SDL_Surface *waitForDataTransmission;
};
/*
aoakvmUsbConfig_t
This struct holds information for the initialization of Android Open Accessory via USB
Fields:
const char *waitForDevice;
const char *aoaInit;
const char *waitForDataTransmission;
const char *manufacturer;
const char *modelName;
const char *description;
const char *version;
const char *uri;
const char *serialNumber;
*/
struct aoakvmConfig_t {
const char *waitForDevice;
const char *aoaInit;
const char *waitForDataTransmission;
const char *manufacturer;
const char *modelName;
const char *description;
const char *version;
const char *uri;
const char *serialNumber;
};
/*
aoakvm_msgscreen_states_enum
This enum represents the three states the application can have.
Values:
WAIT_FOR_DEVICE = 1,
AOA_INITIALIZED = 2,
WAIT_FOR_DATA_TRANSMISSION = 3,
*/
enum aoakvm_msgscreen_states_enum {
/** Success (no error) */
WAIT_FOR_DEVICE = 1,
AOA_INITIALIZED = 2,
WAIT_FOR_DATA_TRANSMISSION = 3,
};
/*
aoakvmWindowProperties_t
This struct holds configuration data for the window to be created.
Fields:
const char title;
const int x; x-position to screen - Of type SDL_WINDOWPOS_xxx
const int y; y-position to screen - Of type SDL_WINDOWPOS_xxx
const int width; width of window in px - user specified
const int height; height of window in px - user specified
const Uint32 flags; Flags for the window. - Of type SDL_WINDOW_xxx.
*/
struct aoakvmWindowProperties_t {
const char *titel;
int x;
int y;
int width;
int height;
uint32_t flags;
};
/*
aoakvmAVCtx_t
This struct represents a struct type for holding the AVFormatContext
and AVCodecContext required for rendering
*/
struct aoakvmAVCtx_t {
AVFormatContext *fmt_ctx;
AVCodecContext *codec_ctx;
};
/*
aoakvm_usb_status_e
This enum represents states a usb connection can have
Entries:
NOT_CONNECTED = 0
CONNECTED = 1
*/
enum aoakvm_usb_status_e {
NOT_CONNECTED,
CONNECTED,
};
/*
aoakvmUSBConnection_t
This struct repesents a USB device and the state of the connection
*/
struct aoakvmUSBConnection_t {
libusb_device_handle *handle;
enum aoakvm_usb_status_e status;
};
extern struct aoakvmUSBConnection_t *usbCon;
/*
aoakvm_push_event
Push customizable event into the event_queue
*/
extern Uint32 DEVICE_CONNECTION_EVENT;
extern Uint32 DEVICE_DISCONNECTION_EVENT;
int aoakvm_push_event(Uint32 *eventType, void *data1, void *data2);
/*
aoakvm_wait_for_device_connection
This should be called by the event_loop when the usb device is not available yet,
or the connection has been lost
*/
int aoakvm_wait_for_device_connection();
struct usbRequest_t {
uint8_t requestType;
uint8_t request;
uint16_t value;
uint16_t index;
unsigned char *buffer;
uint16_t length;
unsigned int timeout;
};
extern SDL_Window *mainwindow;
extern SDL_Renderer *renderer;
/*
MsgScreen
*/
extern struct aoakvmMSGScreens *screens;
/*
invoke_aoakvm(struct aoakvmUsbConfig_t *cfg, int (*eventThread)());
This function invokes the whole functionality of aoakvm.
User needs to supply a pointer to aoakvmUsbConfig_t struct and a pointer to
a function which will be invoked as the event loop. Further a pointer to
*/
int invoke_aoakvm(struct aoakvmConfig_t *, struct aoakvmWindowProperties_t*, int (*fn)());
/*
exit_request
cleans up on exit
*/
void exit_request();
#endif