forked from grayver/mi-vigem
-
Notifications
You must be signed in to change notification settings - Fork 13
/
stadia.h
78 lines (60 loc) · 1.97 KB
/
stadia.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
/*
* stadia.h -- Routines for interacting with a Stadia controller.
*/
#ifndef STADIA_H
#define STADIA_H
#include <wtypes.h>
#define STADIA_ERROR_VIBRATION_INIT_FAILURE 0x1
#define STADIA_ERROR_THREAD_CREATE_FAILURE 0x2
#define STADIA_USB_HW_VENDOR_ID 0x18D1
#define STADIA_USB_HW_PRODUCT_ID 0x9400
#define STADIA_USB_HW_FILTER TEXT("VID_18D1&PID_9400")
#define STADIA_BLT_HW_VENDOR_ID 0x18D1
#define STADIA_BLT_HW_PRODUCT_ID 0x9400
#define STADIA_BLT_HW_FILTER TEXT("vid&0218d1_pid&9400")
#define STADIA_BUTTON_NONE 0x00000000
#define STADIA_BUTTON_A 0x00000001
#define STADIA_BUTTON_B 0x00000002
#define STADIA_BUTTON_X 0x00000004
#define STADIA_BUTTON_Y 0x00000008
#define STADIA_BUTTON_LB 0x00000010
#define STADIA_BUTTON_RB 0x00000020
#define STADIA_BUTTON_LS 0x00000040
#define STADIA_BUTTON_RS 0x00000080
#define STADIA_BUTTON_UP 0x00000100
#define STADIA_BUTTON_DOWN 0x00000200
#define STADIA_BUTTON_LEFT 0x00000400
#define STADIA_BUTTON_RIGHT 0x00000800
#define STADIA_BUTTON_OPTIONS 0x00001000
#define STADIA_BUTTON_MENU 0x00002000
#define STADIA_BUTTON_STADIA_BTN 0x00004000
struct stadia_state
{
DWORD buttons;
BYTE left_stick_x;
BYTE left_stick_y;
BYTE right_stick_x;
BYTE right_stick_y;
BYTE left_trigger;
BYTE right_trigger;
};
struct stadia_controller
{
struct hid_device *device;
SRWLOCK state_lock;
struct stadia_state state;
BOOL active;
HANDLE stopping_event;
HANDLE output_event;
SRWLOCK vibration_lock;
BYTE small_motor;
BYTE big_motor;
HANDLE input_thread;
HANDLE output_thread;
};
void (*stadia_update_callback)(struct stadia_controller *, struct stadia_state *);
void (*stadia_destroy_callback)(struct stadia_controller *);
struct stadia_controller *stadia_controller_create(struct hid_device *device);
void stadia_controller_set_vibration(struct stadia_controller *controller, BYTE small_motor, BYTE big_motor);
void stadia_controller_destroy(struct stadia_controller *controller);
#endif // STADIA_H