summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface
diff options
context:
space:
mode:
authorConnor McLaughlin <stenzek@gmail.com>2020-02-01 11:29:29 +1000
committerGitHub <noreply@github.com>2020-02-01 11:29:29 +1000
commit69ee15e5ef369d51681540e6714f02554e3bd8a6 (patch)
treed66fc04763d80cbb9cd45174bbeabc9f8783a69b /Source/Core/InputCommon/ControllerInterface
parentf8f9dbdec3505515e78972bdd26474ae17b1d2d7 (diff)
parent6106f780a73e74f10392171b3f20b3738f965773 (diff)
Merge pull request #8478 from jordan-woyak/dsu-client-cleanup
ControllerInterface/DSUClient: Minor cleanup.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp51
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h2
2 files changed, 21 insertions, 32 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp
index 937e1b6f16..b2258b1542 100644
--- a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp
@@ -90,7 +90,7 @@ private:
bool IsDetectable() override { return false; }
};
- class MotionInput final : public AnalogInput<double>
+ class MotionInput final : public AnalogInput<float>
{
public:
using AnalogInput::AnalogInput;
@@ -141,8 +141,6 @@ private:
const int m_index;
u32 m_client_uid = Common::Random::GenerateValue<u32>();
sf::UdpSocket m_socket;
- Common::DVec3 m_accel{};
- Common::DVec3 m_gyro{};
SteadyClock::time_point m_next_reregister = SteadyClock::time_point::min();
Proto::MessageType::PadDataResponse m_pad_data{};
Proto::Touch m_prev_touch{};
@@ -367,21 +365,25 @@ Device::Device(Proto::DsModel model, int index) : m_model{model}, m_index{index}
AddInput(new TouchInput("Touch Y-", m_touch_y, -TOUCH_Y_AXIS_MAX));
AddInput(new TouchInput("Touch Y+", m_touch_y, TOUCH_Y_AXIS_MAX));
- AddInput(new AccelerometerInput("Accel Left", m_accel.x, 1));
- AddInput(new AccelerometerInput("Accel Right", m_accel.x, -1));
- AddInput(new AccelerometerInput("Accel Backward", m_accel.y, 1));
- AddInput(new AccelerometerInput("Accel Forward", m_accel.y, -1));
- AddInput(new AccelerometerInput("Accel Up", m_accel.z, 1));
- AddInput(new AccelerometerInput("Accel Down", m_accel.z, -1));
-
- AddInput(new GyroInput("Gyro Pitch Up", m_gyro.x, -1));
- AddInput(new GyroInput("Gyro Pitch Down", m_gyro.x, 1));
- AddInput(new GyroInput("Gyro Roll Right", m_gyro.y, -1));
- AddInput(new GyroInput("Gyro Roll Left", m_gyro.y, 1));
- AddInput(new GyroInput("Gyro Yaw Right", m_gyro.z, -1));
- AddInput(new GyroInput("Gyro Yaw Left", m_gyro.z, 1));
-
- AddInput(new BatteryInput(m_pad_data.battery_status));
+ // Convert Gs to meters per second squared
+ constexpr auto accel_scale = 1.0 / GRAVITY_ACCELERATION;
+
+ AddInput(new AccelerometerInput("Accel Up", m_pad_data.accelerometer_y_g, -accel_scale));
+ AddInput(new AccelerometerInput("Accel Down", m_pad_data.accelerometer_y_g, accel_scale));
+ AddInput(new AccelerometerInput("Accel Left", m_pad_data.accelerometer_x_g, accel_scale));
+ AddInput(new AccelerometerInput("Accel Right", m_pad_data.accelerometer_x_g, -accel_scale));
+ AddInput(new AccelerometerInput("Accel Forward", m_pad_data.accelerometer_z_g, accel_scale));
+ AddInput(new AccelerometerInput("Accel Backward", m_pad_data.accelerometer_z_g, -accel_scale));
+
+ // Convert degrees per second to radians per second
+ constexpr auto gyro_scale = 360.0 / MathUtil::TAU;
+
+ AddInput(new GyroInput("Gyro Pitch Up", m_pad_data.gyro_pitch_deg_s, gyro_scale));
+ AddInput(new GyroInput("Gyro Pitch Down", m_pad_data.gyro_pitch_deg_s, -gyro_scale));
+ AddInput(new GyroInput("Gyro Roll Left", m_pad_data.gyro_roll_deg_s, -gyro_scale));
+ AddInput(new GyroInput("Gyro Roll Right", m_pad_data.gyro_roll_deg_s, gyro_scale));
+ AddInput(new GyroInput("Gyro Yaw Left", m_pad_data.gyro_yaw_deg_s, -gyro_scale));
+ AddInput(new GyroInput("Gyro Yaw Right", m_pad_data.gyro_yaw_deg_s, gyro_scale));
}
std::string Device::GetName() const
@@ -436,19 +438,6 @@ void Device::UpdateInput()
{
m_pad_data = *pad_data;
- m_accel.x = m_pad_data.accelerometer_x_g;
- m_accel.z = -m_pad_data.accelerometer_y_g;
- m_accel.y = -m_pad_data.accelerometer_z_inverted_g;
- m_gyro.x = -m_pad_data.gyro_pitch_deg_s;
- m_gyro.z = -m_pad_data.gyro_yaw_deg_s;
- m_gyro.y = -m_pad_data.gyro_roll_deg_s;
-
- // Convert Gs to meters per second squared
- m_accel = m_accel * GRAVITY_ACCELERATION;
-
- // Convert degrees per second to radians per second
- m_gyro = m_gyro * (MathUtil::TAU / 360);
-
// Update touch pad relative coordinates
if (m_pad_data.touch1.id != m_prev_touch.id)
m_prev_touch_valid = false;
diff --git a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h
index 4932c22049..5e3e9f0dde 100644
--- a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h
+++ b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h
@@ -181,7 +181,7 @@ struct PadDataResponse
u64 timestamp_us;
float accelerometer_x_g;
float accelerometer_y_g;
- float accelerometer_z_inverted_g;
+ float accelerometer_z_g;
float gyro_pitch_deg_s;
float gyro_yaw_deg_s;
float gyro_roll_deg_s;