| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <string> |
| 7 |
|
| 8 |
#include "Common/Matrix.h" |
| 9 |
#include "InputCommon/ControllerEmu/StickGate.h" |
| 10 |
#include "InputCommon/ControllerInterface/CoreDevice.h" |
| 11 |
|
| 12 |
namespace ControllerEmu |
| 13 |
{ |
| 14 |
class EmulatedController; |
| 15 |
} |
| 16 |
|
| 17 |
namespace ciface::MappingCommon |
| 18 |
{ |
| 19 |
enum class Quote |
| 20 |
{ |
| 21 |
On, |
| 22 |
Off |
| 23 |
}; |
| 24 |
|
| 25 |
std::string GetExpressionForControl(const std::string& control_name, |
| 26 |
const Core::DeviceQualifier& control_device, |
| 27 |
const Core::DeviceQualifier& default_device, |
| 28 |
Quote quote = Quote::On); |
| 29 |
|
| 30 |
std::string BuildExpression(const Core::InputDetector::Results&, |
| 31 |
const Core::DeviceQualifier& default_device, Quote quote); |
| 32 |
|
| 33 |
void RemoveSpuriousTriggerCombinations(Core::InputDetector::Results*); |
| 34 |
void RemoveDetectionsAfterTimePoint(Core::InputDetector::Results*, Clock::time_point after); |
| 35 |
bool ContainsCompleteDetection(const Core::InputDetector::Results&); |
| 36 |
|
| 37 |
|
| 38 |
class ReshapableInputMapper |
| 39 |
{ |
| 40 |
public: |
| 41 |
|
| 42 |
static constexpr std::size_t REQUIRED_INPUT_COUNT = 4; |
| 43 |
|
| 44 |
|
| 45 |
ReshapableInputMapper(const Core::DeviceContainer& container, |
| 46 |
std::span<const std::string> device_strings); |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
bool Update(); |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
float GetCurrentAngle() const; |
| 58 |
|
| 59 |
|
| 60 |
bool IsComplete() const; |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
bool IsCalibrationNeeded() const; |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
bool ApplyResults(ControllerEmu::EmulatedController*, ControllerEmu::ReshapableInput* stick); |
| 70 |
|
| 71 |
private: |
| 72 |
Core::InputDetector m_input_detector; |
| 73 |
}; |
| 74 |
|
| 75 |
class CalibrationBuilder |
| 76 |
{ |
| 77 |
public: |
| 78 |
|
| 79 |
explicit CalibrationBuilder(std::optional<Common::DVec2> center = Common::DVec2{}); |
| 80 |
|
| 81 |
|
| 82 |
void Update(Common::DVec2 point); |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
bool IsCalibrationDataSensible() const; |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
bool IsComplete() const; |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
ControlState GetCalibrationRadiusAtAngle(double angle) const; |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
void ApplyResults(ControllerEmu::ReshapableInput* stick); |
| 99 |
|
| 100 |
Common::DVec2 GetCenter() const; |
| 101 |
|
| 102 |
private: |
| 103 |
ControllerEmu::ReshapableInput::CalibrationData m_calibration_data; |
| 104 |
|
| 105 |
std::optional<Common::DVec2> m_center = std::nullopt; |
| 106 |
|
| 107 |
Common::DVec2 m_prev_point{}; |
| 108 |
}; |
| 109 |
|
| 110 |
} |