mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-14 10:21:21 +00:00
cellGem: try to map accelerometer and gyro
This commit is contained in:
parent
13cd461a1f
commit
3d11b6efa3
@ -1109,6 +1109,11 @@ static void ps_move_pos_to_gem_state(u32 gem_num, const gem_config::gem_controll
|
||||
|
||||
if constexpr (std::is_same_v<T, vm::ptr<CellGemState>>)
|
||||
{
|
||||
gem_state->temperature = pad->move_data.temperature;
|
||||
gem_state->accel[0] = pad->move_data.accelerometer_x * 1000; // linear velocity in mm/s²
|
||||
gem_state->accel[1] = pad->move_data.accelerometer_y * 1000; // linear velocity in mm/s²
|
||||
gem_state->accel[2] = pad->move_data.accelerometer_z * 1000; // linear velocity in mm/s²
|
||||
|
||||
pos_to_gem_state(gem_num, controller, gem_state, info.x_pos, info.y_pos, info.x_max, info.y_max);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, vm::ptr<CellGemImageState>>)
|
||||
@ -1866,7 +1871,7 @@ error_code cellGemGetInertialState(u32 gem_num, u32 state_flag, u64 timestamp, v
|
||||
{
|
||||
case move_handler::real:
|
||||
{
|
||||
// Get temperature
|
||||
// Get temperature and sensor data
|
||||
{
|
||||
std::lock_guard lock(pad::g_pad_mutex);
|
||||
|
||||
@ -1876,6 +1881,12 @@ error_code cellGemGetInertialState(u32 gem_num, u32 state_flag, u64 timestamp, v
|
||||
if (pad && pad->m_pad_handler == pad_handler::move && (pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
|
||||
{
|
||||
inertial_state->temperature = pad->move_data.temperature;
|
||||
inertial_state->accelerometer[0] = pad->move_data.accelerometer_x;
|
||||
inertial_state->accelerometer[1] = pad->move_data.accelerometer_y;
|
||||
inertial_state->accelerometer[2] = pad->move_data.accelerometer_z;
|
||||
inertial_state->gyro[0] = pad->move_data.gyro_x;
|
||||
inertial_state->gyro[1] = pad->move_data.gyro_y;
|
||||
inertial_state->gyro[2] = pad->move_data.gyro_z;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -466,12 +466,12 @@ struct ps_move_data
|
||||
bool external_device_read_requested = false;
|
||||
bool external_device_write_requested = false;
|
||||
|
||||
s16 accelerometer_x = 0;
|
||||
s16 accelerometer_y = 0;
|
||||
s16 accelerometer_z = 0;
|
||||
s16 gyro_x = 0;
|
||||
s16 gyro_y = 0;
|
||||
s16 gyro_z = 0;
|
||||
f32 accelerometer_x = 0; // linear velocity in m/s²
|
||||
f32 accelerometer_y = 0; // linear velocity in m/s²
|
||||
f32 accelerometer_z = 0; // linear velocity in m/s²
|
||||
f32 gyro_x = 0; // linear velocity in m/s²
|
||||
f32 gyro_y = 0; // linear velocity in m/s²
|
||||
f32 gyro_z = 0; // linear velocity in m/s²
|
||||
s16 temperature = 0;
|
||||
};
|
||||
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
void operator()();
|
||||
|
||||
PadInfo& GetInfo() { return m_info; }
|
||||
auto& GetPads() { return m_pads; }
|
||||
std::array<std::shared_ptr<Pad>, CELL_PAD_MAX_PORT_NUM>& GetPads() { return m_pads; }
|
||||
void SetRumble(const u32 pad, u8 large_motor, bool small_motor);
|
||||
void SetIntercepted(bool intercepted);
|
||||
|
||||
|
@ -642,19 +642,19 @@ void ps_move_handler::get_extended_info(const pad_ensemble& binding)
|
||||
gyro_z -= zero_shift;
|
||||
}
|
||||
|
||||
pad->m_sensors[0].m_value = Clamp0To1023(512.0f + (MOTION_ONE_G * (accel_x / MOVE_ONE_G) * -1.0f));
|
||||
pad->m_sensors[1].m_value = Clamp0To1023(512.0f + (MOTION_ONE_G * (accel_z / MOVE_ONE_G) * -1.0f));
|
||||
pad->m_sensors[2].m_value = Clamp0To1023(512.0f + (MOTION_ONE_G * (accel_y / MOVE_ONE_G)));
|
||||
pad->m_sensors[3].m_value = Clamp0To1023(512.0f + (MOTION_ONE_G * (gyro_z / MOVE_ONE_G) * -1.0f));
|
||||
|
||||
pad->move_data.accelerometer_x = accel_x;
|
||||
pad->move_data.accelerometer_y = accel_y;
|
||||
pad->move_data.accelerometer_z = accel_z;
|
||||
pad->move_data.gyro_x = gyro_x;
|
||||
pad->move_data.gyro_y = gyro_y;
|
||||
pad->move_data.gyro_z = gyro_z;
|
||||
pad->move_data.accelerometer_x = accel_x / MOVE_ONE_G;
|
||||
pad->move_data.accelerometer_y = accel_y / MOVE_ONE_G;
|
||||
pad->move_data.accelerometer_z = accel_z / MOVE_ONE_G;
|
||||
pad->move_data.gyro_x = accel_x / MOVE_ONE_G;
|
||||
pad->move_data.gyro_y = accel_y / MOVE_ONE_G;
|
||||
pad->move_data.gyro_z = accel_z / MOVE_ONE_G;
|
||||
pad->move_data.temperature = ((input.temperature << 4) | ((input.magnetometer_x & 0xF0) >> 4));
|
||||
|
||||
pad->m_sensors[0].m_value = Clamp0To1023(512.0f + (MOTION_ONE_G * pad->move_data.accelerometer_x * -1.0f));
|
||||
pad->m_sensors[1].m_value = Clamp0To1023(512.0f + (MOTION_ONE_G * pad->move_data.accelerometer_y * -1.0f));
|
||||
pad->m_sensors[2].m_value = Clamp0To1023(512.0f + (MOTION_ONE_G * pad->move_data.accelerometer_z));
|
||||
pad->m_sensors[3].m_value = Clamp0To1023(512.0f + (MOTION_ONE_G * pad->move_data.gyro_z * -1.0f));
|
||||
|
||||
handle_external_device(binding);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user