Compare commits

...

2 commits

Author SHA1 Message Date
Denis
e66a91e520
steam qam and menu btn 2023-12-09 14:04:01 +01:00
Denis
4d0a2d9a6f
should work now... 2023-12-09 13:48:25 +01:00
4 changed files with 117 additions and 25 deletions

View file

@ -49,8 +49,6 @@ static int dev_hidraw_new_from_fd(int fd, dev_hidraw_t **const out_dev) {
if (res < 0) {
perror("Error getting Report Descriptor");
goto dev_hidraw_new_from_fd_err;
} else {
printf("GOT HIDIOCGRDESC %ld\n",(long) (*out_dev)->rdesc.size);
}
dev_hidraw_new_from_fd_err:

View file

@ -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;

View file

@ -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 {

View file

@ -435,19 +435,101 @@ 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*)&current_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*)&current_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*)&current_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*)&current_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*)&current_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 = {
.pid = 0x1abe,
.vid = 0x0b05,
.rdesc_size = 48,
.rdesc_size = 167, // 48 83 167
};
static input_dev_t in_iio_dev = {
@ -540,12 +622,6 @@ enum rc71l_leds_direction {
} rc71l_leds_direction_t;
static int rc71l_platform_init(void** platform_data) {
/*
GOT HIDIOCGRDESC 83 => DISCARDED: b05:1abe 83, expected b05:1abe 167
GOT HIDIOCGRDESC 48 => DISCARDED: b05:1abe 48, expected b05:1abe 167
GOT HIDIOCGRDESC 167 => taken
*/
int res = -EINVAL;
rc71l_platform_t *const platform = malloc(sizeof(rc71l_platform_t));
@ -581,12 +657,6 @@ GOT HIDIOCGRDESC 167 => taken
goto rc71l_platform_init_err;
}
if ((rdesc[7] != (uint8_t)0x85) || (rdesc[8] != (uint8_t)0x5a)) {
fprintf(stderr, "Wrong MCU endpoint selected\n");
res = -EINVAL;
goto rc71l_platform_init_err;
}
platform->platform_mode = rc71l_platform_mode_hidraw;
const int fd = dev_hidraw_get_fd(platform->platform.hidraw);
@ -599,7 +669,7 @@ GOT HIDIOCGRDESC 167 => taken
}
}
write(fd, hidraw_buf, sizeof(hidraw_buf));
//write(fd, hidraw_buf, sizeof(hidraw_buf));
printf("ROG Ally platform will be managed over hidraw. I'm sorry fluke.\n");