| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <chrono> |
| 7 |
#include <optional> |
| 8 |
#include <string> |
| 9 |
|
| 10 |
#include "Common/MathUtil.h" |
| 11 |
#include "Common/Matrix.h" |
| 12 |
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" |
| 13 |
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" |
| 14 |
|
| 15 |
namespace ControllerEmu |
| 16 |
{ |
| 17 |
class IMUGyroscope : public ControlGroup |
| 18 |
{ |
| 19 |
public: |
| 20 |
using StateData = Common::Vec3; |
| 21 |
|
| 22 |
IMUGyroscope(std::string name, std::string ui_name); |
| 23 |
|
| 24 |
StateData GetRawState() const; |
| 25 |
|
| 26 |
std::optional<StateData> GetState(bool update = true); |
| 27 |
|
| 28 |
|
| 29 |
ControlState GetDeadzone() const; |
| 30 |
|
| 31 |
bool IsCalibrating() const; |
| 32 |
|
| 33 |
private: |
| 34 |
using Clock = std::chrono::steady_clock; |
| 35 |
|
| 36 |
bool AreInputsBound() const; |
| 37 |
bool CanCalibrate() const; |
| 38 |
void RestartCalibration(); |
| 39 |
void UpdateCalibration(const StateData&); |
| 40 |
|
| 41 |
SettingValue<double> m_deadzone_setting; |
| 42 |
SettingValue<double> m_calibration_period_setting; |
| 43 |
|
| 44 |
StateData m_calibration = {}; |
| 45 |
MathUtil::RunningMean<StateData> m_running_calibration; |
| 46 |
Clock::time_point m_calibration_period_start = Clock::now(); |
| 47 |
}; |
| 48 |
} |