Properly support mouse
This commit is contained in:
parent
5c576d810b
commit
19e2bfa537
6 changed files with 96 additions and 63 deletions
12
input_dev.c
12
input_dev.c
|
|
@ -19,6 +19,10 @@
|
||||||
static const char *input_path = "/dev/input/";
|
static const char *input_path = "/dev/input/";
|
||||||
static const char *iio_path = "/sys/bus/iio/devices/";
|
static const char *iio_path = "/sys/bus/iio/devices/";
|
||||||
|
|
||||||
|
uint32_t input_filter_imu_identity(struct input_event* events, size_t* size, uint32_t* count) {
|
||||||
|
return INPUT_FILTER_FLAGS_PRESERVE_TIME | INPUT_FILTER_FLAGS_IMU;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t input_filter_identity(struct input_event* events, size_t* size, uint32_t* count) {
|
uint32_t input_filter_identity(struct input_event* events, size_t* size, uint32_t* count) {
|
||||||
return INPUT_FILTER_FLAGS_NONE;
|
return INPUT_FILTER_FLAGS_NONE;
|
||||||
}
|
}
|
||||||
|
|
@ -26,6 +30,14 @@ uint32_t input_filter_identity(struct input_event* events, size_t* size, uint32_
|
||||||
uint32_t input_filter_asus_kb(struct input_event* events, size_t* size, uint32_t* count) {
|
uint32_t input_filter_asus_kb(struct input_event* events, size_t* size, uint32_t* count) {
|
||||||
static int F15_status = 0;
|
static int F15_status = 0;
|
||||||
|
|
||||||
|
if (events[0].type == EV_REL) {
|
||||||
|
return INPUT_FILTER_FLAGS_MOUSE;
|
||||||
|
} else if (events[0].type == EV_KEY) {
|
||||||
|
if ((events[0].code == BTN_MIDDLE) || (events[0].code == BTN_LEFT) || (events[0].code == BTN_RIGHT)) {
|
||||||
|
return INPUT_FILTER_FLAGS_MOUSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((*count >= 2) && (events[0].type == EV_MSC) && (events[0].code == MSC_SCAN)) {
|
if ((*count >= 2) && (events[0].type == EV_MSC) && (events[0].code == MSC_SCAN)) {
|
||||||
if ((events[0].value == -13565784) && (events[1].type == EV_KEY) && (events[1].code == KEY_F18)) {
|
if ((events[0].value == -13565784) && (events[1].type == EV_KEY) && (events[1].code == KEY_F18)) {
|
||||||
if (events[1].value == 1) {
|
if (events[1].value == 1) {
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ void *input_dev_thread_func(void *ptr);
|
||||||
|
|
||||||
int open_and_hide_input();
|
int open_and_hide_input();
|
||||||
|
|
||||||
|
uint32_t input_filter_imu_identity(struct input_event* events, size_t* size, uint32_t* count);
|
||||||
|
|
||||||
uint32_t input_filter_identity(struct input_event* events, size_t* size, uint32_t* count);
|
uint32_t input_filter_identity(struct input_event* events, size_t* size, uint32_t* count);
|
||||||
|
|
||||||
uint32_t input_filter_asus_kb(struct input_event*, size_t*, uint32_t*);
|
uint32_t input_filter_asus_kb(struct input_event*, size_t*, uint32_t*);
|
||||||
61
main.c
61
main.c
|
|
@ -4,17 +4,12 @@
|
||||||
#include "output_dev.h"
|
#include "output_dev.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
queue_t imu_ev;
|
|
||||||
queue_t gamepad_ev;
|
queue_t gamepad_ev;
|
||||||
|
|
||||||
static output_dev_t out_imu_dev = {
|
|
||||||
.fd = -1,
|
|
||||||
.crtl_flags = 0x00000000U,
|
|
||||||
.queue = &imu_ev,
|
|
||||||
};
|
|
||||||
|
|
||||||
static output_dev_t out_gamepadd_dev = {
|
static output_dev_t out_gamepadd_dev = {
|
||||||
.fd = -1,
|
.gamepad_fd = -1,
|
||||||
|
.imu_fd = -1,
|
||||||
.crtl_flags = 0x00000000U,
|
.crtl_flags = 0x00000000U,
|
||||||
.queue = &gamepad_ev,
|
.queue = &gamepad_ev,
|
||||||
};
|
};
|
||||||
|
|
@ -27,8 +22,8 @@ static input_dev_t in_iio_dev = {
|
||||||
.dev_type = input_dev_type_iio,
|
.dev_type = input_dev_type_iio,
|
||||||
.crtl_flags = 0x00000000U,
|
.crtl_flags = 0x00000000U,
|
||||||
.iio_filters = &in_iio_filters,
|
.iio_filters = &in_iio_filters,
|
||||||
.queue = &imu_ev,
|
.queue = &gamepad_ev,
|
||||||
.input_filter_fn = input_filter_identity,
|
.input_filter_fn = input_filter_imu_identity,
|
||||||
};
|
};
|
||||||
|
|
||||||
static uinput_filters_t in_asus_kb_1_filters = {
|
static uinput_filters_t in_asus_kb_1_filters = {
|
||||||
|
|
@ -80,7 +75,6 @@ static input_dev_t in_xbox_dev = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void request_termination() {
|
void request_termination() {
|
||||||
out_imu_dev.crtl_flags |= OUTPUT_DEV_CTRL_FLAG_EXIT;
|
|
||||||
out_gamepadd_dev.crtl_flags |= OUTPUT_DEV_CTRL_FLAG_EXIT;
|
out_gamepadd_dev.crtl_flags |= OUTPUT_DEV_CTRL_FLAG_EXIT;
|
||||||
|
|
||||||
in_xbox_dev.crtl_flags |= INPUT_DEV_CTRL_FLAG_EXIT;
|
in_xbox_dev.crtl_flags |= INPUT_DEV_CTRL_FLAG_EXIT;
|
||||||
|
|
@ -101,25 +95,32 @@ int main(int argc, char ** argv) {
|
||||||
init_global_mode();
|
init_global_mode();
|
||||||
|
|
||||||
queue_init(&gamepad_ev, 32);
|
queue_init(&gamepad_ev, 32);
|
||||||
queue_init(&imu_ev, 32);
|
|
||||||
|
|
||||||
out_imu_dev.fd = create_output_dev("/dev/uinput", OUTPUT_DEV_NAME /*" - IMU"*/, output_dev_imu);
|
int imu_fd = create_output_dev("/dev/uinput", output_dev_imu);
|
||||||
if (out_imu_dev.fd < 0) {
|
if (imu_fd < 0) {
|
||||||
// TODO: free(imu_dev.events_list);
|
|
||||||
// TODO: free(gamepadd_dev.events_list);
|
|
||||||
fprintf(stderr, "Unable to create IMU virtual device\n");
|
fprintf(stderr, "Unable to create IMU virtual device\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
out_gamepadd_dev.fd = create_output_dev("/dev/uinput", OUTPUT_DEV_NAME /*" - GamePad"*/, output_dev_gamepad);
|
int gamepad_fd = create_output_dev("/dev/uinput", output_dev_gamepad);
|
||||||
if (out_gamepadd_dev.fd < 0) {
|
if (gamepad_fd < 0) {
|
||||||
close(out_imu_dev.fd);
|
close(imu_fd);
|
||||||
// TODO: free(imu_dev.events_list);
|
|
||||||
// TODO: free(gamepadd_dev.events_list);
|
|
||||||
fprintf(stderr, "Unable to create gamepad virtual device\n");
|
fprintf(stderr, "Unable to create gamepad virtual device\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mouse_fd = create_output_dev("/dev/uinput", output_dev_mouse);
|
||||||
|
if (mouse_fd < 0) {
|
||||||
|
close(gamepad_fd);
|
||||||
|
close(imu_fd);
|
||||||
|
fprintf(stderr, "Unable to create mouse virtual device\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
out_gamepadd_dev.gamepad_fd = gamepad_fd;
|
||||||
|
out_gamepadd_dev.imu_fd = imu_fd;
|
||||||
|
out_gamepadd_dev.mouse_fd = mouse_fd;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
__sighandler_t sigint_hndl = signal(SIGINT, sig_handler);
|
__sighandler_t sigint_hndl = signal(SIGINT, sig_handler);
|
||||||
if (sigint_hndl == SIG_ERR) {
|
if (sigint_hndl == SIG_ERR) {
|
||||||
|
|
@ -130,16 +131,8 @@ int main(int argc, char ** argv) {
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
pthread_t imu_thread, gamepad_thread;
|
pthread_t gamepad_thread;
|
||||||
pthread_t xbox_thread, asus_kb_1_thread, asus_kb_2_thread, asus_kb_3_thread, iio_thread;
|
pthread_t xbox_thread, asus_kb_1_thread, asus_kb_2_thread, asus_kb_3_thread, iio_thread;
|
||||||
|
|
||||||
const int imu_thread_creation = pthread_create(&imu_thread, NULL, output_dev_thread_func, (void*)(&out_imu_dev));
|
|
||||||
if (imu_thread_creation != 0) {
|
|
||||||
fprintf(stderr, "Error creating IMU output thread: %d\n", imu_thread_creation);
|
|
||||||
ret = -1;
|
|
||||||
request_termination();
|
|
||||||
goto imu_thread_err;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int gamepad_thread_creation = pthread_create(&gamepad_thread, NULL, output_dev_thread_func, (void*)(&out_gamepadd_dev));
|
const int gamepad_thread_creation = pthread_create(&gamepad_thread, NULL, output_dev_thread_func, (void*)(&out_gamepadd_dev));
|
||||||
if (gamepad_thread_creation != 0) {
|
if (gamepad_thread_creation != 0) {
|
||||||
|
|
@ -207,14 +200,8 @@ xbox_drv_thread_err:
|
||||||
pthread_join(gamepad_thread, NULL);
|
pthread_join(gamepad_thread, NULL);
|
||||||
|
|
||||||
gamepad_thread_err:
|
gamepad_thread_err:
|
||||||
pthread_join(imu_thread, NULL);
|
ioctl(gamepad_fd, UI_DEV_DESTROY);
|
||||||
|
close(gamepad_fd);
|
||||||
imu_thread_err:
|
|
||||||
if (!(out_gamepadd_dev.fd < 0))
|
|
||||||
close(out_gamepadd_dev.fd);
|
|
||||||
|
|
||||||
if (!(out_imu_dev.fd < 0))
|
|
||||||
close(out_imu_dev.fd);
|
|
||||||
|
|
||||||
// TODO: free(imu_dev.events_list);
|
// TODO: free(imu_dev.events_list);
|
||||||
// TODO: free(gamepadd_dev.events_list);
|
// TODO: free(gamepadd_dev.events_list);
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,7 @@ typedef struct message {
|
||||||
#define INPUT_FILTER_FLAGS_NONE 0x00000000U
|
#define INPUT_FILTER_FLAGS_NONE 0x00000000U
|
||||||
#define INPUT_FILTER_FLAGS_DO_NOT_EMIT 0x00000001U
|
#define INPUT_FILTER_FLAGS_DO_NOT_EMIT 0x00000001U
|
||||||
#define INPUT_FILTER_FLAGS_PRESERVE_TIME 0x00000002U
|
#define INPUT_FILTER_FLAGS_PRESERVE_TIME 0x00000002U
|
||||||
|
#define INPUT_FILTER_FLAGS_IMU 0x00000004U
|
||||||
|
#define INPUT_FILTER_FLAGS_MOUSE 0x00000008U
|
||||||
|
|
||||||
typedef uint32_t (*input_filter_t)(struct input_event*, size_t*, uint32_t*);
|
typedef uint32_t (*input_filter_t)(struct input_event*, size_t*, uint32_t*);
|
||||||
75
output_dev.c
75
output_dev.c
|
|
@ -4,7 +4,7 @@
|
||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int create_output_dev(const char* uinput_path, const char* name, output_dev_type_t type) {
|
int create_output_dev(const char* uinput_path, output_dev_type_t type) {
|
||||||
int fd = open(uinput_path, O_WRONLY | O_NONBLOCK);
|
int fd = open(uinput_path, O_WRONLY | O_NONBLOCK);
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
fd = -1;
|
fd = -1;
|
||||||
|
|
@ -13,11 +13,8 @@ int create_output_dev(const char* uinput_path, const char* name, output_dev_type
|
||||||
}
|
}
|
||||||
|
|
||||||
struct uinput_setup dev = {0};
|
struct uinput_setup dev = {0};
|
||||||
if (strlen(name) < UINPUT_MAX_NAME_SIZE) {
|
strncpy(dev.name, OUTPUT_DEV_NAME, UINPUT_MAX_NAME_SIZE-1);
|
||||||
strcpy(dev.name, name);
|
|
||||||
} else {
|
|
||||||
strncpy(dev.name, name, UINPUT_MAX_NAME_SIZE-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(OUTPUT_DEV_BUS_TYPE)
|
#if defined(OUTPUT_DEV_BUS_TYPE)
|
||||||
dev.id.bustype = OUTPUT_DEV_BUS_TYPE;
|
dev.id.bustype = OUTPUT_DEV_BUS_TYPE;
|
||||||
|
|
@ -39,9 +36,10 @@ int create_output_dev(const char* uinput_path, const char* name, output_dev_type
|
||||||
case output_dev_imu: {
|
case output_dev_imu: {
|
||||||
ioctl(fd, UI_SET_PROPBIT, INPUT_PROP_ACCELEROMETER);
|
ioctl(fd, UI_SET_PROPBIT, INPUT_PROP_ACCELEROMETER);
|
||||||
ioctl(fd, UI_SET_EVBIT, EV_ABS);
|
ioctl(fd, UI_SET_EVBIT, EV_ABS);
|
||||||
//ioctl(fd, UI_SET_EVBIT, EV_KEY);
|
#if defined(INCLUDE_TIMESTAMP)
|
||||||
ioctl(fd, UI_SET_EVBIT, EV_MSC);
|
ioctl(fd, UI_SET_EVBIT, EV_MSC);
|
||||||
ioctl(fd, UI_SET_MSCBIT, MSC_TIMESTAMP);
|
ioctl(fd, UI_SET_MSCBIT, MSC_TIMESTAMP);
|
||||||
|
#endif
|
||||||
|
|
||||||
ioctl(fd, UI_SET_ABSBIT, ABS_X);
|
ioctl(fd, UI_SET_ABSBIT, ABS_X);
|
||||||
ioctl(fd, UI_SET_ABSBIT, ABS_Y);
|
ioctl(fd, UI_SET_ABSBIT, ABS_Y);
|
||||||
|
|
@ -149,11 +147,10 @@ int create_output_dev(const char* uinput_path, const char* name, output_dev_type
|
||||||
case output_dev_gamepad: {
|
case output_dev_gamepad: {
|
||||||
//ioctl(fd, UI_SET_PROPBIT, INPUT_PROP_BUTTONPAD);
|
//ioctl(fd, UI_SET_PROPBIT, INPUT_PROP_BUTTONPAD);
|
||||||
ioctl(fd, UI_SET_EVBIT, EV_ABS);
|
ioctl(fd, UI_SET_EVBIT, EV_ABS);
|
||||||
ioctl(fd, UI_SET_EVBIT, EV_REL);
|
|
||||||
ioctl(fd, UI_SET_EVBIT, EV_KEY);
|
ioctl(fd, UI_SET_EVBIT, EV_KEY);
|
||||||
ioctl(fd, UI_SET_EVBIT, EV_MSC);
|
|
||||||
ioctl(fd, UI_SET_EVBIT, EV_SYN);
|
ioctl(fd, UI_SET_EVBIT, EV_SYN);
|
||||||
#if defined(INCLUDE_TIMESTAMP)
|
#if defined(INCLUDE_TIMESTAMP)
|
||||||
|
ioctl(fd, UI_SET_EVBIT, EV_MSC);
|
||||||
ioctl(fd, UI_SET_MSCBIT, MSC_TIMESTAMP);
|
ioctl(fd, UI_SET_MSCBIT, MSC_TIMESTAMP);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -181,6 +178,8 @@ int create_output_dev(const char* uinput_path, const char* name, output_dev_type
|
||||||
ioctl(fd, UI_SET_KEYBIT, BTN_MODE);
|
ioctl(fd, UI_SET_KEYBIT, BTN_MODE);
|
||||||
ioctl(fd, UI_SET_KEYBIT, BTN_THUMBL);
|
ioctl(fd, UI_SET_KEYBIT, BTN_THUMBL);
|
||||||
ioctl(fd, UI_SET_KEYBIT, BTN_THUMBR);
|
ioctl(fd, UI_SET_KEYBIT, BTN_THUMBR);
|
||||||
|
ioctl(fd, UI_SET_KEYBIT, BTN_THUMB);
|
||||||
|
ioctl(fd, UI_SET_KEYBIT, BTN_THUMB2);
|
||||||
ioctl(fd, UI_SET_KEYBIT, BTN_GEAR_DOWN);
|
ioctl(fd, UI_SET_KEYBIT, BTN_GEAR_DOWN);
|
||||||
ioctl(fd, UI_SET_KEYBIT, BTN_GEAR_UP);
|
ioctl(fd, UI_SET_KEYBIT, BTN_GEAR_UP);
|
||||||
ioctl(fd, UI_SET_KEYBIT, BTN_DPAD_UP);
|
ioctl(fd, UI_SET_KEYBIT, BTN_DPAD_UP);
|
||||||
|
|
@ -188,16 +187,7 @@ int create_output_dev(const char* uinput_path, const char* name, output_dev_type
|
||||||
ioctl(fd, UI_SET_KEYBIT, BTN_DPAD_LEFT);
|
ioctl(fd, UI_SET_KEYBIT, BTN_DPAD_LEFT);
|
||||||
ioctl(fd, UI_SET_KEYBIT, BTN_DPAD_RIGHT);
|
ioctl(fd, UI_SET_KEYBIT, BTN_DPAD_RIGHT);
|
||||||
|
|
||||||
// mouse buttons
|
//ioctl(fd, UI_SET_KEYBIT, KEY_F12);
|
||||||
ioctl(fd, UI_SET_KEYBIT, BTN_LEFT);
|
|
||||||
ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE);
|
|
||||||
ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT);
|
|
||||||
ioctl(fd, UI_SET_RELBIT, REL_X);
|
|
||||||
ioctl(fd, UI_SET_RELBIT, REL_Y);
|
|
||||||
ioctl(fd, UI_SET_RELBIT, REL_WHEEL);
|
|
||||||
ioctl(fd, UI_SET_RELBIT, REL_WHEEL_HI_RES);
|
|
||||||
|
|
||||||
ioctl(fd, UI_SET_KEYBIT, KEY_F12);
|
|
||||||
//ioctl(fd, UI_SET_KEYBIT, KEY_F15);
|
//ioctl(fd, UI_SET_KEYBIT, KEY_F15);
|
||||||
//ioctl(fd, UI_SET_KEYBIT, KEY_F16);
|
//ioctl(fd, UI_SET_KEYBIT, KEY_F16);
|
||||||
//ioctl(fd, UI_SET_KEYBIT, KEY_F17);
|
//ioctl(fd, UI_SET_KEYBIT, KEY_F17);
|
||||||
|
|
@ -392,6 +382,41 @@ int create_output_dev(const char* uinput_path, const char* name, output_dev_type
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case output_dev_mouse: {
|
||||||
|
ioctl(fd, UI_SET_EVBIT, EV_REL);
|
||||||
|
ioctl(fd, UI_SET_EVBIT, EV_KEY);
|
||||||
|
ioctl(fd, UI_SET_EVBIT, EV_MSC);
|
||||||
|
ioctl(fd, UI_SET_EVBIT, EV_SYN);
|
||||||
|
#if defined(INCLUDE_TIMESTAMP)
|
||||||
|
ioctl(fd, UI_SET_MSCBIT, MSC_TIMESTAMP);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ioctl(fd, UI_SET_KEYBIT, BTN_LEFT);
|
||||||
|
ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE);
|
||||||
|
ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT);
|
||||||
|
//ioctl(fd, UI_SET_KEYBIT, BTN_SIDE);
|
||||||
|
//ioctl(fd, UI_SET_KEYBIT, BTN_EXTRA);
|
||||||
|
|
||||||
|
ioctl(fd, UI_SET_RELBIT, REL_X);
|
||||||
|
ioctl(fd, UI_SET_RELBIT, REL_Y);
|
||||||
|
ioctl(fd, UI_SET_RELBIT, REL_WHEEL);
|
||||||
|
ioctl(fd, UI_SET_RELBIT, REL_WHEEL_HI_RES);
|
||||||
|
|
||||||
|
if(ioctl(fd, UI_DEV_SETUP, &dev) < 0) {
|
||||||
|
fd = -1;
|
||||||
|
close(fd);
|
||||||
|
goto create_output_dev_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ioctl(fd, UI_DEV_CREATE) < 0) {
|
||||||
|
fd = -1;
|
||||||
|
close(fd);
|
||||||
|
goto create_output_dev_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// error
|
// error
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
@ -407,8 +432,6 @@ void *output_dev_thread_func(void *ptr) {
|
||||||
output_dev_t *out_dev = (output_dev_t*)ptr;
|
output_dev_t *out_dev = (output_dev_t*)ptr;
|
||||||
struct timeval now = {0};
|
struct timeval now = {0};
|
||||||
|
|
||||||
const int fd = out_dev->fd;
|
|
||||||
|
|
||||||
#if defined(INCLUDE_TIMESTAMP)
|
#if defined(INCLUDE_TIMESTAMP)
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
__time_t secAtInit = now.tv_sec;
|
__time_t secAtInit = now.tv_sec;
|
||||||
|
|
@ -421,6 +444,13 @@ void *output_dev_thread_func(void *ptr) {
|
||||||
if (pop_res == 0) {
|
if (pop_res == 0) {
|
||||||
message_t *const msg = (message_t*)raw_ev;
|
message_t *const msg = (message_t*)raw_ev;
|
||||||
|
|
||||||
|
int fd = out_dev->gamepad_fd;
|
||||||
|
if ((msg->flags & INPUT_FILTER_FLAGS_IMU) != 0) {
|
||||||
|
fd = out_dev->imu_fd;
|
||||||
|
} else if ((msg->flags & INPUT_FILTER_FLAGS_MOUSE) != 0) {
|
||||||
|
fd = out_dev->mouse_fd;
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < msg->ev_count; ++i) {
|
for (uint32_t i = 0; i < msg->ev_count; ++i) {
|
||||||
struct input_event ev = {
|
struct input_event ev = {
|
||||||
.code = msg->ev[i].code,
|
.code = msg->ev[i].code,
|
||||||
|
|
@ -505,8 +535,5 @@ void *output_dev_thread_func(void *ptr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ioctl(fd, UI_DEV_DESTROY);
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,16 +52,19 @@
|
||||||
typedef enum output_dev_type {
|
typedef enum output_dev_type {
|
||||||
output_dev_gamepad,
|
output_dev_gamepad,
|
||||||
output_dev_imu,
|
output_dev_imu,
|
||||||
|
output_dev_mouse,
|
||||||
} output_dev_type_t;
|
} output_dev_type_t;
|
||||||
|
|
||||||
typedef struct output_dev {
|
typedef struct output_dev {
|
||||||
int fd;
|
int gamepad_fd;
|
||||||
|
int imu_fd;
|
||||||
|
int mouse_fd;
|
||||||
|
|
||||||
volatile uint32_t crtl_flags;
|
volatile uint32_t crtl_flags;
|
||||||
|
|
||||||
queue_t *queue;
|
queue_t *queue;
|
||||||
} output_dev_t;
|
} output_dev_t;
|
||||||
|
|
||||||
int create_output_dev(const char* uinput_path, const char* name, output_dev_type_t type);
|
int create_output_dev(const char* uinput_path, output_dev_type_t type);
|
||||||
|
|
||||||
void *output_dev_thread_func(void *ptr);
|
void *output_dev_thread_func(void *ptr);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue