mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-06 06:55:09 +00:00
fake move: add gyro support
This commit is contained in:
parent
92d0707291
commit
415c2d0795
21 changed files with 458 additions and 187 deletions
|
|
@ -90,6 +90,7 @@ dualsense_pad_handler::dualsense_pad_handler()
|
|||
b_has_player_led = true;
|
||||
b_has_battery = true;
|
||||
b_has_battery_led = true;
|
||||
b_has_orientation = true;
|
||||
|
||||
m_name_string = "DualSense Pad #";
|
||||
m_max_devices = CELL_PAD_MAX_PORT_NUM;
|
||||
|
|
@ -252,6 +253,7 @@ void dualsense_pad_handler::init_config(cfg_pad* cfg)
|
|||
|
||||
cfg->pressure_intensity_button.def = ::at32(button_list, DualSenseKeyCodes::None);
|
||||
cfg->analog_limiter_button.def = ::at32(button_list, DualSenseKeyCodes::None);
|
||||
cfg->orientation_reset_button.def = ::at32(button_list, DualSenseKeyCodes::None);
|
||||
|
||||
// Set default misc variables
|
||||
cfg->lstick_anti_deadzone.def = static_cast<u32>(0.13 * thumb_max); // 13%
|
||||
|
|
@ -614,28 +616,27 @@ void dualsense_pad_handler::get_extended_info(const pad_ensemble& binding)
|
|||
|
||||
// these values come already calibrated, all we need to do is convert to ds3 range
|
||||
|
||||
// gyroY is yaw, which is all that we need
|
||||
//f32 gyroX = static_cast<s16>(input.gyro[0]) / static_cast<f32>(DUALSENSE_GYRO_RES_PER_DEG_S) * -1.f;
|
||||
f32 gyroY = static_cast<s16>(input.gyro[1]) / static_cast<f32>(DUALSENSE_GYRO_RES_PER_DEG_S) * -1.f;
|
||||
//f32 gyroZ = static_cast<s16>(input.gyro[2]) / static_cast<f32>(DUALSENSE_GYRO_RES_PER_DEG_S) * -1.f;
|
||||
// gyro (angular velocity in degree/s)
|
||||
const f32 gyro_x = static_cast<s16>(input.gyro[0]) / static_cast<f32>(DUALSENSE_GYRO_RES_PER_DEG_S) * -1.f;
|
||||
const f32 gyro_y = static_cast<s16>(input.gyro[1]) / static_cast<f32>(DUALSENSE_GYRO_RES_PER_DEG_S) * -1.f;
|
||||
const f32 gyro_z = static_cast<s16>(input.gyro[2]) / static_cast<f32>(DUALSENSE_GYRO_RES_PER_DEG_S) * -1.f;
|
||||
|
||||
// accel
|
||||
f32 accelX = static_cast<s16>(input.accel[0]) / static_cast<f32>(DUALSENSE_ACC_RES_PER_G) * -1;
|
||||
f32 accelY = static_cast<s16>(input.accel[1]) / static_cast<f32>(DUALSENSE_ACC_RES_PER_G) * -1;
|
||||
f32 accelZ = static_cast<s16>(input.accel[2]) / static_cast<f32>(DUALSENSE_ACC_RES_PER_G) * -1;
|
||||
// acceleration (linear velocity in m/s²)
|
||||
const f32 accel_x = static_cast<s16>(input.accel[0]) / static_cast<f32>(DUALSENSE_ACC_RES_PER_G) * -1;
|
||||
const f32 accel_y = static_cast<s16>(input.accel[1]) / static_cast<f32>(DUALSENSE_ACC_RES_PER_G) * -1;
|
||||
const f32 accel_z = static_cast<s16>(input.accel[2]) / static_cast<f32>(DUALSENSE_ACC_RES_PER_G) * -1;
|
||||
|
||||
// now just use formula from ds3
|
||||
accelX = accelX * 113 + 512;
|
||||
accelY = accelY * 113 + 512;
|
||||
accelZ = accelZ * 113 + 512;
|
||||
pad->m_sensors[0].m_value = Clamp0To1023(accel_x * MOTION_ONE_G + 512);
|
||||
pad->m_sensors[1].m_value = Clamp0To1023(accel_y * MOTION_ONE_G + 512);
|
||||
pad->m_sensors[2].m_value = Clamp0To1023(accel_z * MOTION_ONE_G + 512);
|
||||
|
||||
// gyro_y is yaw, which is all that we need
|
||||
// Convert to ds3. The ds3 resolution is 123/90°/sec.
|
||||
gyroY = gyroY * (123.f / 90.f) + 512;
|
||||
pad->m_sensors[3].m_value = Clamp0To1023(gyro_y * (123.f / 90.f) + 512);
|
||||
|
||||
pad->m_sensors[0].m_value = Clamp0To1023(accelX);
|
||||
pad->m_sensors[1].m_value = Clamp0To1023(accelY);
|
||||
pad->m_sensors[2].m_value = Clamp0To1023(accelZ);
|
||||
pad->m_sensors[3].m_value = Clamp0To1023(gyroY);
|
||||
// Set raw orientation
|
||||
set_raw_orientation(pad->move_data, accel_x, accel_y, accel_z, gyro_x, gyro_y, gyro_z);
|
||||
}
|
||||
|
||||
std::unordered_map<u64, u16> dualsense_pad_handler::get_button_values(const std::shared_ptr<PadDevice>& device)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue