diff --git a/dev_out.c b/dev_out.c index 9bfd2db..4288875 100644 --- a/dev_out.c +++ b/dev_out.c @@ -1,5 +1,6 @@ #include "dev_out.h" +#include "devices_status.h" #include "virt_ds4.h" #include "virt_ds5.h" @@ -7,9 +8,11 @@ static void handle_incoming_message_gamepad_action( const in_message_gamepad_action_t *const msg_payload, gamepad_status_t *const inout_gamepad ) { - if (msg_payload == GAMEPAD_ACTION_PRESS_AND_RELEASE_CENTER) { + if (*msg_payload == GAMEPAD_ACTION_PRESS_AND_RELEASE_CENTER) { inout_gamepad->flags |= GAMEPAD_STATUS_FLAGS_PRESS_AND_REALEASE_CENTER; - } + } else if (*msg_payload == GAMEPAD_ACTION_OPEN_STEAM_QAM) { + inout_gamepad->flags |= GAMEPAD_STATUS_FLAGS_OPEN_STEAM_QAM; + } } static void handle_incoming_message_gamepad_set( @@ -65,6 +68,22 @@ static void handle_incoming_message_gamepad_set( inout_gamepad->r3 = msg_payload->status.btn; break; } + case GAMEPAD_BTN_L4: { + inout_gamepad->l4 = msg_payload->status.btn; + break; + } + case GAMEPAD_BTN_R4: { + inout_gamepad->r4 = msg_payload->status.btn; + break; + } + case GAMEPAD_BTN_L5: { + inout_gamepad->l5 = msg_payload->status.btn; + break; + } + case GAMEPAD_BTN_R5: { + inout_gamepad->r5 = msg_payload->status.btn; + break; + } case GAMEPAD_BTN_TOUCHPAD: { inout_gamepad->touchpad_press = msg_payload->status.btn; break; diff --git a/message.h b/message.h index 210b435..91bc3b2 100644 --- a/message.h +++ b/message.h @@ -19,6 +19,10 @@ typedef enum in_message_gamepad_btn { GAMEPAD_BTN_R2_TRIGGER, GAMEPAD_BTN_L3, GAMEPAD_BTN_R3, + GAMEPAD_BTN_L4, + GAMEPAD_BTN_R4, + GAMEPAD_BTN_L5, + GAMEPAD_BTN_R5, GAMEPAD_BTN_TOUCHPAD, GAMEPAD_LEFT_JOYSTICK_X, @@ -41,6 +45,7 @@ typedef struct in_message_gamepad_set_element { typedef enum in_message_gamepad_action { GAMEPAD_ACTION_PRESS_AND_RELEASE_CENTER, + GAMEPAD_ACTION_OPEN_STEAM_QAM, } in_message_gamepad_action_t; typedef enum in_in_message_type { diff --git a/rog_ally.c b/rog_ally.c index bb0284f..d9cef3a 100644 --- a/rog_ally.c +++ b/rog_ally.c @@ -435,13 +435,95 @@ static const uint8_t rc71l_mode_switch_commands[][23][64] = { void asus_kbd_ev_map(const evdev_collected_t *const e, int in_messages_pipe_fd, void* user_data) { in_message_t current_message; - - /* - const ssize_t in_message_pipe_write_res = write(in_messages_pipe_fd, (void*)¤t_message, sizeof(in_message_t)); - if (in_message_pipe_write_res != sizeof(in_message_t)) { - fprintf(stderr, "Unable to write data to the in_message pipe: %zu\n", in_message_pipe_write_res); - } - */ + if ( // this is what happens at release of the left-screen button of the ROG Ally + (e->ev_count == 2) && + (e->ev[0].type == EV_MSC) && + (e->ev[0].code == MSC_SCAN) && + (e->ev[0].value == -13565786) && + (e->ev[1].type == EV_KEY) && + (e->ev[1].code == KEY_F16) && + (e->ev[1].value == 1) + ) { + in_message_t current_message = { + .type = GAMEPAD_ACTION, + .data = { + .action = GAMEPAD_ACTION_PRESS_AND_RELEASE_CENTER, + } + }; + + const ssize_t in_message_pipe_write_res = write(in_messages_pipe_fd, (void*)¤t_message, sizeof(in_message_t)); + if (in_message_pipe_write_res != sizeof(in_message_t)) { + fprintf(stderr, "Unable to write data for MENU to the in_message pipe: %zu\n", in_message_pipe_write_res); + } + } else if ( // this is what happens at release of the right-screen button of the ROG Ally + (e->ev_count == 2) && + (e->ev[0].type == EV_MSC) && + (e->ev[0].code == MSC_SCAN) && + (e->ev[0].value == -13565896) && + (e->ev[1].type == EV_KEY) && + (e->ev[1].code == KEY_PROG1) && + (e->ev[1].value == 1) + ) { + in_message_t current_message = { + .type = GAMEPAD_ACTION, + .data = { + .action = GAMEPAD_ACTION_OPEN_STEAM_QAM, + } + }; + + const ssize_t in_message_pipe_write_res = write(in_messages_pipe_fd, (void*)¤t_message, sizeof(in_message_t)); + if (in_message_pipe_write_res != sizeof(in_message_t)) { + fprintf(stderr, "Unable to write data for QAM to the in_message pipe: %zu\n", in_message_pipe_write_res); + } + } else if ( + (e->ev_count == 2) && + (e->ev[0].type == EV_MSC) && + (e->ev[0].code == MSC_SCAN) && + (e->ev[0].value == 458860) && + (e->ev[1].type == EV_KEY) && + (e->ev[1].code == KEY_F17) + ) { + in_message_t current_message = { + .type = GAMEPAD_SET_ELEMENT, + .data = { + .gamepad_set = { + .element = GAMEPAD_BTN_L4, + .status = { + .btn = e->ev[1].code, + } + } + } + }; + + const ssize_t in_message_pipe_write_res = write(in_messages_pipe_fd, (void*)¤t_message, sizeof(in_message_t)); + if (in_message_pipe_write_res != sizeof(in_message_t)) { + fprintf(stderr, "Unable to write data for L4 to the in_message pipe: %zu\n", in_message_pipe_write_res); + } + } else if ( + (e->ev_count == 2) && + (e->ev[0].type == EV_MSC) && + (e->ev[0].code == MSC_SCAN) && + (e->ev[0].value == 458861) && + (e->ev[1].type == EV_KEY) && + (e->ev[1].code == KEY_F18) + ) { + in_message_t current_message = { + .type = GAMEPAD_SET_ELEMENT, + .data = { + .gamepad_set = { + .element = GAMEPAD_BTN_R4, + .status = { + .btn = e->ev[1].code, + } + } + } + }; + + const ssize_t in_message_pipe_write_res = write(in_messages_pipe_fd, (void*)¤t_message, sizeof(in_message_t)); + if (in_message_pipe_write_res != sizeof(in_message_t)) { + fprintf(stderr, "Unable to write data for R4 to the in_message pipe: %zu\n", in_message_pipe_write_res); + } + } } static hidraw_filters_t n_key_hidraw_filters = {