From 6055034bf65c4b1e6daba8241a06ecb03408b1cf Mon Sep 17 00:00:00 2001 From: Denis Date: Sat, 6 Jan 2024 16:10:04 +0100 Subject: [PATCH] Improve dualsense output --- virt_ds5.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/virt_ds5.c b/virt_ds5.c index 3e8efa9..fa2015a 100644 --- a/virt_ds5.c +++ b/virt_ds5.c @@ -40,12 +40,12 @@ static uint8_t PS_INPUT_CRC32_SEED = 0xA1; static uint8_t PS_OUTPUT_CRC32_SEED = 0xA2; static uint8_t PS_FEATURE_CRC32_SEED = 0xA3; -#define DS5_EDGE_NAME "Sony Corp. DualSense Edge wireless controller (PS5)" +#define DS5_EDGE_NAME "Sony Interactive Entertainment DualSense Edge Wireless Controller" #define DS5_EDGE_VERSION 256 #define DS5_EDGE_VENDOR 0x054C #define DS5_EDGE_PRODUCT 0x0DF2 -#define DS5_NAME "Sony Corp. DualSense wireless controller (PS5)" +#define DS5_NAME "Sony Interactive Entertainment DualSense Wireless Controller" #define DS5_VERSION 0x8111 #define DS5_VENDOR 0x054C #define DS5_PRODUCT 0x0ce6 @@ -1458,6 +1458,8 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c const int16_t a_y = in_device_status->raw_accel[1]; // Swap Y and Z const int16_t a_z = in_device_status->raw_accel[2]; // Swap Y and Z + const int64_t contrib_x = (int64_t)127 + ((int64_t)g_y / (int64_t)4); + const int64_t contrib_y = (int64_t)127 + ((int64_t)g_x / (int64_t)4); out_buf[0] = gamepad->bluetooth ? DS_INPUT_REPORT_BT : DS_INPUT_REPORT_USB; // [00] report ID (0x01) @@ -1468,17 +1470,11 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c out_shifted_buf[4] = ((uint64_t)((int64_t)in_device_status->joystick_positions[1][1] + (int64_t)32768) >> (uint64_t)8); // R stick, Y axis if (in_device_status->join_left_analog_and_gyroscope) { - const int64_t contrib_x = (int64_t)127 + ((int64_t)g_y / (int64_t)4); - const int64_t contrib_y = (int64_t)127 + ((int64_t)g_x / (int64_t)4); - out_shifted_buf[1] = min_max_clamp((int64_t)127 + (((int64_t)out_shifted_buf[3] - (int64_t)127) + contrib_x), 0, 255); out_shifted_buf[2] = min_max_clamp((int64_t)127 + (((int64_t)out_shifted_buf[4] - (int64_t)127) + contrib_y), 0, 255); } if (in_device_status->join_right_analog_and_gyroscope) { - const int64_t contrib_x = (int64_t)g_y / (int64_t)4; - const int64_t contrib_y = (int64_t)g_x / (int64_t)4; - out_shifted_buf[3] = min_max_clamp((int64_t)127 + (((int64_t)out_shifted_buf[3] - (int64_t)127) + contrib_x), 0, 255); out_shifted_buf[4] = min_max_clamp((int64_t)127 + (((int64_t)out_shifted_buf[4] - (int64_t)127) + contrib_y), 0, 255); }