Improve dualsense output

This commit is contained in:
Denis 2024-01-06 16:10:04 +01:00
parent 79fe2cf9dd
commit 6055034bf6
No known key found for this signature in database
GPG key ID: DD9B63F805CF5C03

View file

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