mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-16 11:09:16 +01:00
379ffc268d
My future PRs will split the UI state from the Emulation State of some of these emulated controller values and this readies the code for it.
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
// Copyright 2019 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <chrono>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#include "Common/MathUtil.h"
|
|
#include "Common/Matrix.h"
|
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
|
|
|
namespace ControllerEmu
|
|
{
|
|
class IMUGyroscope : public ControlGroup
|
|
{
|
|
public:
|
|
using StateData = Common::Vec3;
|
|
|
|
IMUGyroscope(std::string name, std::string ui_name);
|
|
|
|
StateData GetRawState() const;
|
|
// Also updates the state by default
|
|
std::optional<StateData> GetState(bool update = true);
|
|
|
|
// Value is in rad/s.
|
|
ControlState GetDeadzone() const;
|
|
|
|
bool IsCalibrating() const;
|
|
|
|
private:
|
|
using Clock = std::chrono::steady_clock;
|
|
|
|
bool AreInputsBound() const;
|
|
bool CanCalibrate() const;
|
|
void RestartCalibration();
|
|
void UpdateCalibration(const StateData&);
|
|
|
|
SettingValue<double> m_deadzone_setting;
|
|
SettingValue<double> m_calibration_period_setting;
|
|
|
|
StateData m_calibration = {};
|
|
MathUtil::RunningMean<StateData> m_running_calibration;
|
|
Clock::time_point m_calibration_period_start = Clock::now();
|
|
};
|
|
} // namespace ControllerEmu
|