switch back output device after exiting lizard mode
This commit is contained in:
parent
2ea9211b86
commit
5a06754bcc
3 changed files with 8 additions and 0 deletions
2
logic.c
2
logic.c
|
|
@ -42,6 +42,8 @@ int logic_create(logic_t *const logic) {
|
|||
logic->gamepad_output = GAMEPAD_OUTPUT_DS4;
|
||||
}
|
||||
|
||||
logic->restore_to = logic->gamepad_output;
|
||||
|
||||
if (queue_init_res < 0) {
|
||||
fprintf(stderr, "Unable to create queue: %d\n", queue_init_res);
|
||||
return queue_init_res;
|
||||
|
|
|
|||
2
logic.h
2
logic.h
|
|
@ -67,6 +67,8 @@ typedef struct logic {
|
|||
// the mutex is not needed if only one thread is writing this and others are checking with equality
|
||||
//pthread_mutex_t gamepad_output_mutex;
|
||||
gamepad_output_t gamepad_output;
|
||||
|
||||
gamepad_output_t restore_to;
|
||||
} logic_t;
|
||||
|
||||
int logic_create(logic_t *const logic);
|
||||
|
|
|
|||
|
|
@ -569,6 +569,7 @@ static void decode_ev(output_dev_t *const out_dev, message_t *const msg) {
|
|||
if (msg->data.event.ev[1].value == 1) {
|
||||
printf("Detected mode switch command, switching mode...\n");
|
||||
|
||||
const int was_mouse_mode = is_mouse_mode(&out_dev->logic->platform);
|
||||
const int new_mode = cycle_mode(&out_dev->logic->platform);
|
||||
|
||||
if (new_mode < 0) {
|
||||
|
|
@ -577,8 +578,11 @@ static void decode_ev(output_dev_t *const out_dev, message_t *const msg) {
|
|||
printf("Mode correctly switched to %d\n", new_mode);
|
||||
|
||||
if (new_mode == 1) {
|
||||
out_dev->logic->restore_to = out_dev->logic->gamepad_output;
|
||||
printf("Mode switched to virtual evdev for lizard mode.\n");
|
||||
out_dev->logic->gamepad_output = GAMEPAD_OUTPUT_EVDEV;
|
||||
} else if (was_mouse_mode) {
|
||||
out_dev->logic->gamepad_output = out_dev->logic->restore_to;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue