From a755e2a18c6112a67835a74032a2eb83f51a6073 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 2 Jan 2024 21:04:09 +0100 Subject: [PATCH 01/12] default to touchpad button for m1 and m2 buttons --- config.cfg.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.cfg.default b/config.cfg.default index f6dd94b..2297cb6 100644 --- a/config.cfg.default +++ b/config.cfg.default @@ -5,4 +5,4 @@ default_gamepad = 1; rumble_on_mode_switch = true; gamepad_rumble_control = true; gamepad_leds_control = true; -m1m2_mode = 0; \ No newline at end of file +m1m2_mode = 1; \ No newline at end of file From c400ee7d22367ac2d9a8a9c436a05db87b71e91f Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 2 Jan 2024 21:08:08 +0100 Subject: [PATCH 02/12] let's fix X alone --- virt_ds5.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virt_ds5.c b/virt_ds5.c index aaad393..7536cd4 100644 --- a/virt_ds5.c +++ b/virt_ds5.c @@ -1325,8 +1325,8 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c // point of contact number 0 out_shifted_buf[33] = in_device_status->touchpad_touch_num == -1 ? 0x80 : 0x7F; //contact out_shifted_buf[34] = in_device_status->touchpad_x & (int16_t)0x00FF; //x_lo - out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)8) | ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)); // x_hi:4 y_lo:4 - out_shifted_buf[36] = ((in_device_status->touchpad_y & (int16_t)0x0FF0) >> (int16_t)4); //y_hi + out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)8) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 + out_shifted_buf[36] = 0 /*((in_device_status->touchpad_y & (int16_t)0x0FF0) >> (int16_t)4)*/; //y_hi // point of contact number 1 out_shifted_buf[37] = 0x80; //contact From 922dd9083150ed6d72279ab2c42574c9ec341a36 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 2 Jan 2024 21:11:00 +0100 Subject: [PATCH 03/12] let's exclude the other part of X too --- virt_ds5.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virt_ds5.c b/virt_ds5.c index 7536cd4..3b9bb36 100644 --- a/virt_ds5.c +++ b/virt_ds5.c @@ -1324,8 +1324,8 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c // point of contact number 0 out_shifted_buf[33] = in_device_status->touchpad_touch_num == -1 ? 0x80 : 0x7F; //contact - out_shifted_buf[34] = in_device_status->touchpad_x & (int16_t)0x00FF; //x_lo - out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)8) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 + out_shifted_buf[34] = 0/*in_device_status->touchpad_x & (int16_t)0x00FF*/; //x_lo + out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)4) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 out_shifted_buf[36] = 0 /*((in_device_status->touchpad_y & (int16_t)0x0FF0) >> (int16_t)4)*/; //y_hi // point of contact number 1 From c668a9406ce6708d62d44148d63823d2a698c5de Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 2 Jan 2024 21:16:53 +0100 Subject: [PATCH 04/12] what about this? --- virt_ds5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt_ds5.c b/virt_ds5.c index 3b9bb36..99e08ec 100644 --- a/virt_ds5.c +++ b/virt_ds5.c @@ -1325,7 +1325,7 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c // point of contact number 0 out_shifted_buf[33] = in_device_status->touchpad_touch_num == -1 ? 0x80 : 0x7F; //contact out_shifted_buf[34] = 0/*in_device_status->touchpad_x & (int16_t)0x00FF*/; //x_lo - out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)4) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 + out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)8) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 out_shifted_buf[36] = 0 /*((in_device_status->touchpad_y & (int16_t)0x0FF0) >> (int16_t)4)*/; //y_hi // point of contact number 1 From 58d7d7c5539fdd12e57eecbc98f9c97ad3d83548 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 2 Jan 2024 21:20:07 +0100 Subject: [PATCH 05/12] better? --- rog_ally.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rog_ally.c b/rog_ally.c index 1357c3d..03d2e0a 100644 --- a/rog_ally.c +++ b/rog_ally.c @@ -991,8 +991,8 @@ static int touchscreen_ev_map( .gamepad_set = { .element = GAMEPAD_TOUCHPAD_X, .status = { - .touchpad_active = { - .status = e->ev[i].value, + .touchpad_x = { + .value = e->ev[i].value, } } } @@ -1007,8 +1007,8 @@ static int touchscreen_ev_map( .gamepad_set = { .element = GAMEPAD_TOUCHPAD_Y, .status = { - .touchpad_active = { - .status = e->ev[i].value, + .touchpad_y = { + .value = e->ev[i].value, } } } From 782865dbb6f61c4b350797b867294d28bf6c9ae2 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 2 Jan 2024 21:24:12 +0100 Subject: [PATCH 06/12] no idea... --- virt_ds5.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/virt_ds5.c b/virt_ds5.c index 99e08ec..81f58ca 100644 --- a/virt_ds5.c +++ b/virt_ds5.c @@ -1325,9 +1325,11 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c // point of contact number 0 out_shifted_buf[33] = in_device_status->touchpad_touch_num == -1 ? 0x80 : 0x7F; //contact out_shifted_buf[34] = 0/*in_device_status->touchpad_x & (int16_t)0x00FF*/; //x_lo - out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)8) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 + out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)4) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 out_shifted_buf[36] = 0 /*((in_device_status->touchpad_y & (int16_t)0x0FF0) >> (int16_t)4)*/; //y_hi + sprintf(stderr, "%d -> %d\n", (int)in_device_status->touchpad_x, (int)out_shifted_buf[35]); + // point of contact number 1 out_shifted_buf[37] = 0x80; //contact out_shifted_buf[38] = 0x00; //x_lo From 42832e0b0d7eb007bd2bb982a658c8d85e82d04f Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 2 Jan 2024 21:30:49 +0100 Subject: [PATCH 07/12] dafuq? --- virt_ds5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt_ds5.c b/virt_ds5.c index 81f58ca..1bfd7c3 100644 --- a/virt_ds5.c +++ b/virt_ds5.c @@ -1328,7 +1328,7 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)4) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 out_shifted_buf[36] = 0 /*((in_device_status->touchpad_y & (int16_t)0x0FF0) >> (int16_t)4)*/; //y_hi - sprintf(stderr, "%d -> %d\n", (int)in_device_status->touchpad_x, (int)out_shifted_buf[35]); + printf("%d -> %d\n", (int)in_device_status->touchpad_x, (int)out_shifted_buf[35]); // point of contact number 1 out_shifted_buf[37] = 0x80; //contact From f3ac4dc285eea5f9c1fbc57653ad659516800b5e Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 2 Jan 2024 21:35:54 +0100 Subject: [PATCH 08/12] I have finished messages --- virt_ds5.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/virt_ds5.c b/virt_ds5.c index 1bfd7c3..4625258 100644 --- a/virt_ds5.c +++ b/virt_ds5.c @@ -1325,10 +1325,12 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c // point of contact number 0 out_shifted_buf[33] = in_device_status->touchpad_touch_num == -1 ? 0x80 : 0x7F; //contact out_shifted_buf[34] = 0/*in_device_status->touchpad_x & (int16_t)0x00FF*/; //x_lo - out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)4) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 + out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)8) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 out_shifted_buf[36] = 0 /*((in_device_status->touchpad_y & (int16_t)0x0FF0) >> (int16_t)4)*/; //y_hi - printf("%d -> %d\n", (int)in_device_status->touchpad_x, (int)out_shifted_buf[35]); + if (in_device_status->touchpad_touch_num != -1) { + printf("%d -> %d\n", (int)in_device_status->touchpad_x, (int)out_shifted_buf[35]); + } // point of contact number 1 out_shifted_buf[37] = 0x80; //contact From e85322e38ccf382d675ae6311fa12c0b7a184da1 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 2 Jan 2024 21:47:35 +0100 Subject: [PATCH 09/12] debug --- virt_ds5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt_ds5.c b/virt_ds5.c index 4625258..aae82cf 100644 --- a/virt_ds5.c +++ b/virt_ds5.c @@ -1329,7 +1329,7 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c out_shifted_buf[36] = 0 /*((in_device_status->touchpad_y & (int16_t)0x0FF0) >> (int16_t)4)*/; //y_hi if (in_device_status->touchpad_touch_num != -1) { - printf("%d -> %d\n", (int)in_device_status->touchpad_x, (int)out_shifted_buf[35]); + printf("%4x -> %2x\n", (int)in_device_status->touchpad_x, (int)out_shifted_buf[35]); } // point of contact number 1 From 1c401c9dbf42ecf3967e3875a17ee7bec2e6ad15 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 2 Jan 2024 21:51:41 +0100 Subject: [PATCH 10/12] debug --- virt_ds5.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virt_ds5.c b/virt_ds5.c index aae82cf..c1e363d 100644 --- a/virt_ds5.c +++ b/virt_ds5.c @@ -1324,8 +1324,8 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c // point of contact number 0 out_shifted_buf[33] = in_device_status->touchpad_touch_num == -1 ? 0x80 : 0x7F; //contact - out_shifted_buf[34] = 0/*in_device_status->touchpad_x & (int16_t)0x00FF*/; //x_lo - out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)8) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 + out_shifted_buf[34] = 0x7F/*in_device_status->touchpad_x & (int16_t)0x00FF*/; //x_lo + out_shifted_buf[35] = ((((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)8) << (int16_t)4) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 out_shifted_buf[36] = 0 /*((in_device_status->touchpad_y & (int16_t)0x0FF0) >> (int16_t)4)*/; //y_hi if (in_device_status->touchpad_touch_num != -1) { From 9cf162681e9c1bc718a1d152f94c481925a51088 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 2 Jan 2024 21:58:21 +0100 Subject: [PATCH 11/12] I do have no words to express how stupid I am --- virt_ds5.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/virt_ds5.c b/virt_ds5.c index c1e363d..703d3cf 100644 --- a/virt_ds5.c +++ b/virt_ds5.c @@ -1338,16 +1338,6 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c out_shifted_buf[39] = 0x00; //x_hi:4 y_lo:4 out_shifted_buf[40] = 0x00; //y_hi -/* - buf[30] = 0x1b; // no headset attached -*/ - out_shifted_buf[62] = 0x80; // IDK... it seems constant... - out_shifted_buf[57] = 0x80; // IDK... it seems constant... - out_shifted_buf[53] = 0x80; // IDK... it seems constant... - out_shifted_buf[48] = 0x80; // IDK... it seems constant... - out_shifted_buf[35] = 0x80; // IDK... it seems constant... - out_shifted_buf[44] = 0x80; // IDK... it seems constant... - if (gamepad->bluetooth) { uint32_t crc = crc32_le(0xFFFFFFFFU, (const uint8_t*)&PS_FEATURE_CRC32_SEED, sizeof(PS_FEATURE_CRC32_SEED)); crc = ~crc32_le(crc, (const Bytef *)&out_shifted_buf[0], DS_INPUT_REPORT_BT_SIZE - 4); From c68ddd85b8187ac45fce98cd89a0521ff20f5985 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 2 Jan 2024 22:03:11 +0100 Subject: [PATCH 12/12] I have no idea... --- virt_ds5.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/virt_ds5.c b/virt_ds5.c index 703d3cf..da896e6 100644 --- a/virt_ds5.c +++ b/virt_ds5.c @@ -1325,13 +1325,9 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c // point of contact number 0 out_shifted_buf[33] = in_device_status->touchpad_touch_num == -1 ? 0x80 : 0x7F; //contact out_shifted_buf[34] = 0x7F/*in_device_status->touchpad_x & (int16_t)0x00FF*/; //x_lo - out_shifted_buf[35] = ((((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)8) << (int16_t)4) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 + out_shifted_buf[35] = (((in_device_status->touchpad_x & (int16_t)0x0F00) >> (int16_t)8) /*| ((in_device_status->touchpad_y & (int16_t)0x000F) << (int16_t)4)*/); // x_hi:4 y_lo:4 out_shifted_buf[36] = 0 /*((in_device_status->touchpad_y & (int16_t)0x0FF0) >> (int16_t)4)*/; //y_hi - if (in_device_status->touchpad_touch_num != -1) { - printf("%4x -> %2x\n", (int)in_device_status->touchpad_x, (int)out_shifted_buf[35]); - } - // point of contact number 1 out_shifted_buf[37] = 0x80; //contact out_shifted_buf[38] = 0x00; //x_lo @@ -1343,6 +1339,10 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c crc = ~crc32_le(crc, (const Bytef *)&out_shifted_buf[0], DS_INPUT_REPORT_BT_SIZE - 4); memcpy(&out_shifted_buf[DS_INPUT_REPORT_BT_SIZE - sizeof(crc)], &crc, sizeof(crc)); } + + if (in_device_status->touchpad_touch_num != -1) { + printf("%4x -> %2x @\n", (int)in_device_status->touchpad_x, (int)out_shifted_buf[35]); + } } int virt_dualsense_send(virt_dualsense_t *const gamepad, uint8_t *const out_shifted_buf) {