From 4ab34c4547afb68454c23bacc37f3a4c575718ca Mon Sep 17 00:00:00 2001 From: Denis Date: Sat, 6 Jan 2024 17:55:53 +0100 Subject: [PATCH] gyro-to-analog should finally work at this point --- virt_ds4.c | 6 +++--- virt_ds5.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/virt_ds4.c b/virt_ds4.c index ba27fce..3ff8b3c 100644 --- a/virt_ds4.c +++ b/virt_ds4.c @@ -794,8 +794,8 @@ void virt_dualshock_compose(virt_dualshock_t *const gamepad, gamepad_status_t *c const int16_t a_y = in_device_status->raw_accel[1]; const int16_t a_z = in_device_status->raw_accel[2]; - const int64_t contrib_x = (int64_t)127 + ((int64_t)g_y / (int64_t)gamepad->gyro_to_analog_mapping); - const int64_t contrib_y = (int64_t)127 + ((int64_t)g_x / (int64_t)gamepad->gyro_to_analog_mapping); + const int64_t contrib_x = ((int64_t)g_y / (int64_t)gamepad->gyro_to_analog_mapping); + const int64_t contrib_y = ((int64_t)g_x / (int64_t)gamepad->gyro_to_analog_mapping); out_buf[0] = gamepad->bluetooth ? DS4_INPUT_REPORT_BT : DS4_INPUT_REPORT_USB; // [00] report ID (0x01) @@ -821,7 +821,7 @@ void virt_dualshock_compose(virt_dualshock_t *const gamepad, gamepad_status_t *c (in_device_status->r1 ? 0x02 : 0x00) | (in_device_status->l1 ? 0x01 : 0x00); - if (contrib_y >= gamepad->gyro_to_analog_activation_treshold) { + if (in_device_status->join_left_analog_and_gyroscope) { if (absolute_value(contrib_x) > gamepad->gyro_to_analog_activation_treshold) { out_shifted_buf[1] = min_max_clamp((int64_t)127 + (((int64_t)out_shifted_buf[1] - (int64_t)127) + contrib_x), 0, 255); } diff --git a/virt_ds5.c b/virt_ds5.c index 060c302..0c8354e 100644 --- a/virt_ds5.c +++ b/virt_ds5.c @@ -1466,8 +1466,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]; const int16_t a_z = in_device_status->raw_accel[2]; - const int64_t contrib_x = (int64_t)127 + ((int64_t)g_y / (int64_t)gamepad->gyro_to_analog_mapping); - const int64_t contrib_y = (int64_t)127 + ((int64_t)g_x / (int64_t)gamepad->gyro_to_analog_mapping); + const int64_t contrib_x = ((int64_t)g_y / (int64_t)gamepad->gyro_to_analog_mapping); + const int64_t contrib_y = ((int64_t)g_x / (int64_t)gamepad->gyro_to_analog_mapping); out_buf[0] = gamepad->bluetooth ? DS_INPUT_REPORT_BT : DS_INPUT_REPORT_USB; // [00] report ID (0x01) @@ -1477,7 +1477,7 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c out_shifted_buf[3] = ((uint64_t)((int64_t)in_device_status->joystick_positions[1][0] + (int64_t)32768) >> (uint64_t)8); // R stick, X axis 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 (contrib_y >= gamepad->gyro_to_analog_activation_treshold) { + if (in_device_status->join_left_analog_and_gyroscope) { if (absolute_value(contrib_x) > gamepad->gyro_to_analog_activation_treshold) { out_shifted_buf[1] = min_max_clamp((int64_t)127 + (((int64_t)out_shifted_buf[1] - (int64_t)127) + contrib_x), 0, 255); }