-
Notifications
You must be signed in to change notification settings - Fork 4
/
virt_ds4.h
58 lines (45 loc) · 1.28 KB
/
virt_ds4.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
#pragma once
#include "message.h"
#include "devices_status.h"
/**
* Emulator of the DualShock4 controller at USB level using USB UHID ( https://www.kernel.org/doc/html/latest/hid/uhid.html ) kernel APIs.
*
* See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/hid/uhid.txt?id=refs/tags/v4.10-rc3
*/
typedef struct virt_dualshock {
int fd;
bool debug;
bool bluetooth;
uint32_t dt_sum;
uint8_t dt_buffer_current;
uint32_t dt_buffer[30];
uint32_t empty_reports;
int64_t last_time;
int64_t gyro_to_analog_activation_treshold;
int64_t gyro_to_analog_mapping;
} virt_dualshock_t;
int virt_dualshock_init(
virt_dualshock_t *const gamepad,
bool bluetooth,
int64_t gyro_to_analog_activation_treshold,
int64_t gyro_to_analog_mapping
);
int virt_dualshock_get_fd(
virt_dualshock_t *const gamepad
);
int virt_dualshock_event(
virt_dualshock_t *const gamepad,
gamepad_status_t *const out_device_status
);
void virt_dualshock_compose(
virt_dualshock_t *const gamepad,
gamepad_status_t *const in_device_status,
uint8_t *const out_buf
);
int virt_dualshock_send(
virt_dualshock_t *const gamepad,
uint8_t *const out_buf
);
void virt_dualshock_close(
virt_dualshock_t *const gamepad
);