Remove RealMotionDevice
This commit is contained in:
parent
8e18b61972
commit
0774b17846
7 changed files with 41 additions and 35 deletions
|
@ -56,7 +56,7 @@ public:
|
|||
is_tilting = false;
|
||||
}
|
||||
|
||||
std::tuple<Common::Vec3<float>, Common::Vec3<float>> GetStatus() {
|
||||
Input::MotionStatus GetStatus() {
|
||||
std::lock_guard guard{status_mutex};
|
||||
return status;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ private:
|
|||
|
||||
Common::Event shutdown_event;
|
||||
|
||||
std::tuple<Common::Vec3<float>, Common::Vec3<float>> status;
|
||||
Input::MotionStatus status;
|
||||
std::mutex status_mutex;
|
||||
|
||||
// Note: always keep the thread declaration at the end so that other objects are initialized
|
||||
|
@ -113,10 +113,19 @@ private:
|
|||
gravity = QuaternionRotate(inv_q, gravity);
|
||||
angular_rate = QuaternionRotate(inv_q, angular_rate);
|
||||
|
||||
// TODO: Calculate the correct rotation vector and orientation matrix
|
||||
const auto matrix4x4 = q.ToMatrix();
|
||||
const auto rotation = Common::MakeVec(0.0f, 0.0f, 0.0f);
|
||||
const std::array orientation{
|
||||
Common::Vec3f(matrix4x4[0], matrix4x4[1], -matrix4x4[2]),
|
||||
Common::Vec3f(matrix4x4[4], matrix4x4[5], -matrix4x4[6]),
|
||||
Common::Vec3f(-matrix4x4[8], -matrix4x4[9], matrix4x4[10]),
|
||||
};
|
||||
|
||||
// Update the sensor state
|
||||
{
|
||||
std::lock_guard guard{status_mutex};
|
||||
status = std::make_tuple(gravity, angular_rate);
|
||||
status = std::make_tuple(gravity, angular_rate, rotation, orientation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +140,7 @@ public:
|
|||
device = std::make_shared<MotionEmuDevice>(update_millisecond, sensitivity);
|
||||
}
|
||||
|
||||
std::tuple<Common::Vec3<float>, Common::Vec3<float>> GetStatus() const override {
|
||||
Input::MotionStatus GetStatus() const override {
|
||||
return device->GetStatus();
|
||||
}
|
||||
|
||||
|
|
|
@ -170,10 +170,18 @@ void Client::OnPadData(Response::PadData data) {
|
|||
// directions correspond to the ones of the Switch
|
||||
Common::Vec3f accel = Common::MakeVec<float>(data.accel.x, data.accel.y, data.accel.z);
|
||||
Common::Vec3f gyro = Common::MakeVec<float>(data.gyro.pitch, data.gyro.yaw, data.gyro.roll);
|
||||
|
||||
// TODO: Calculate the correct rotation vector and orientation matrix
|
||||
const auto rotation = Common::MakeVec(0.0f, 0.0f, 0.0f);
|
||||
const std::array orientation{
|
||||
Common::Vec3f(1.0f, 0.0f, 0.0f),
|
||||
Common::Vec3f(0.0f, 1.0f, 0.0f),
|
||||
Common::Vec3f(0.0f, 0.0f, 1.0f),
|
||||
};
|
||||
{
|
||||
std::lock_guard guard(status->update_mutex);
|
||||
|
||||
status->motion_status = {accel, gyro};
|
||||
status->motion_status = {accel, gyro, rotation, orientation};
|
||||
|
||||
// TODO: add a setting for "click" touch. Click touch refers to a device that differentiates
|
||||
// between a simple "tap" and a hard press that causes the touch screen to click.
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "common/common_types.h"
|
||||
#include "common/thread.h"
|
||||
#include "common/vector_math.h"
|
||||
#include "core/frontend/input.h"
|
||||
|
||||
namespace InputCommon::CemuhookUDP {
|
||||
|
||||
|
@ -30,7 +31,7 @@ struct Version;
|
|||
|
||||
struct DeviceStatus {
|
||||
std::mutex update_mutex;
|
||||
std::tuple<Common::Vec3<float>, Common::Vec3<float>> motion_status;
|
||||
Input::MotionStatus motion_status;
|
||||
std::tuple<float, float, bool> touch_status;
|
||||
|
||||
// calibration data for scaling the device's touch area to 3ds
|
||||
|
|
|
@ -29,7 +29,7 @@ private:
|
|||
class UDPMotionDevice final : public Input::MotionDevice {
|
||||
public:
|
||||
explicit UDPMotionDevice(std::shared_ptr<DeviceStatus> status_) : status(std::move(status_)) {}
|
||||
std::tuple<Common::Vec3<float>, Common::Vec3<float>> GetStatus() const override {
|
||||
Input::MotionStatus GetStatus() const override {
|
||||
std::lock_guard guard(status->update_mutex);
|
||||
return status->motion_status;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue