improve gyro-to-joy
This commit is contained in:
parent
ae3fac6301
commit
ee02e47df0
2 changed files with 7 additions and 15 deletions
|
|
@ -15,9 +15,7 @@ int64_t div_round_closest_i64(int64_t x, int64_t divisor) {
|
|||
int64_t min_max_clamp(int64_t value, int64_t min, int64_t max) {
|
||||
if (value <= min) {
|
||||
return min;
|
||||
}
|
||||
|
||||
if (value >= max) {
|
||||
} else if (value >= max) {
|
||||
return max;
|
||||
}
|
||||
|
||||
|
|
|
|||
18
virt_ds5.c
18
virt_ds5.c
|
|
@ -1448,22 +1448,16 @@ void virt_dualsense_compose(virt_dualsense_t *const gamepad, gamepad_status_t *c
|
|||
const int64_t contrib_x = (int64_t)127 + ((int64_t)g_x / (int64_t)4);
|
||||
const int64_t contrib_y = (int64_t)127 + ((int64_t)g_y / (int64_t)4);
|
||||
|
||||
const uint8_t analog_x_contrib = min_max_clamp(contrib_x, 0, 255);
|
||||
const uint8_t analog_y_contrib = min_max_clamp(contrib_y, 0, 255);
|
||||
|
||||
out_shifted_buf[1] = min_max_clamp((int64_t)out_shifted_buf[1] + (int64_t)analog_x_contrib, 0, 255);
|
||||
out_shifted_buf[2] = min_max_clamp((int64_t)out_shifted_buf[2] + (int64_t)analog_y_contrib, 0, 255);
|
||||
out_shifted_buf[1] = min_max_clamp((int64_t)out_shifted_buf[1] + contrib_x, 0, 255);
|
||||
out_shifted_buf[2] = min_max_clamp((int64_t)out_shifted_buf[2] + contrib_y, 0, 255);
|
||||
}
|
||||
|
||||
if (in_device_status->join_right_analog_and_gyroscope) {
|
||||
const int64_t contrib_x = (int64_t)127 + ((int64_t)g_x / (int64_t)4);
|
||||
const int64_t contrib_y = (int64_t)127 + ((int64_t)g_y / (int64_t)4);
|
||||
const int64_t contrib_x = (int64_t)g_x / (int64_t)4;
|
||||
const int64_t contrib_y = (int64_t)g_y / (int64_t)4;
|
||||
|
||||
const uint8_t analog_x_contrib = min_max_clamp(contrib_x, 0, 255);
|
||||
const uint8_t analog_y_contrib = min_max_clamp(contrib_y, 0, 255);
|
||||
|
||||
out_shifted_buf[3] = min_max_clamp((int64_t)out_shifted_buf[3] + (int64_t)analog_x_contrib, 0, 255);
|
||||
out_shifted_buf[4] = min_max_clamp((int64_t)out_shifted_buf[4] + (int64_t)analog_y_contrib, 0, 255);
|
||||
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);
|
||||
}
|
||||
|
||||
out_shifted_buf[5] = in_device_status->l2_trigger; // Z
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue