mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-15 16:59:18 +01:00
ControllerInterface: Minor DSU client device cleanups.
This commit is contained in:
parent
f0534cabc6
commit
2b9fa0597a
@ -42,71 +42,69 @@ const Config::ConfigInfo<int> SERVER_PORT{{Config::System::DualShockUDPClient, "
|
|||||||
// Clock type used for querying timeframes
|
// Clock type used for querying timeframes
|
||||||
using SteadyClock = std::chrono::steady_clock;
|
using SteadyClock = std::chrono::steady_clock;
|
||||||
|
|
||||||
class Device : public Core::Device
|
class Device final : public Core::Device
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
template <class T>
|
template <class T>
|
||||||
class Button : public Core::Device::Input
|
class Button final : public Input
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Button(std::string name, const T& buttons, unsigned mask)
|
Button(const char* name, const T& buttons, T mask)
|
||||||
: m_name(std::move(name)), m_buttons(buttons), m_mask(mask)
|
: m_name(name), m_buttons(buttons), m_mask(mask)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
std::string GetName() const override { return m_name; }
|
std::string GetName() const override { return m_name; }
|
||||||
ControlState GetState() const override { return (m_buttons & m_mask) != 0; }
|
ControlState GetState() const override { return (m_buttons & m_mask) != 0; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string m_name;
|
const char* const m_name;
|
||||||
const T& m_buttons;
|
const T& m_buttons;
|
||||||
unsigned m_mask;
|
const T m_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class AnalogInput : public Core::Device::Input
|
class AnalogInput : public Input
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AnalogInput(std::string name, const T& input, ControlState range, ControlState offset = 0)
|
AnalogInput(const char* name, const T& input, ControlState range, ControlState offset = 0)
|
||||||
: m_name(std::move(name)), m_input(input), m_range(range), m_offset(offset)
|
: m_name(name), m_input(input), m_range(range), m_offset(offset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
std::string GetName() const override { return m_name; }
|
std::string GetName() const final override { return m_name; }
|
||||||
ControlState GetState() const override { return (ControlState(m_input) + m_offset) / m_range; }
|
ControlState GetState() const final override
|
||||||
|
{
|
||||||
|
return (ControlState(m_input) + m_offset) / m_range;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string m_name;
|
const char* m_name;
|
||||||
const T& m_input;
|
const T& m_input;
|
||||||
const ControlState m_range;
|
const ControlState m_range;
|
||||||
const ControlState m_offset;
|
const ControlState m_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TouchInput : public AnalogInput<int>
|
class TouchInput final : public AnalogInput<int>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TouchInput(std::string name, const int& input, ControlState range)
|
using AnalogInput::AnalogInput;
|
||||||
: AnalogInput(std::move(name), input, range)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
bool IsDetectable() override { return false; }
|
bool IsDetectable() override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class AccelerometerInput : public AnalogInput<double>
|
class MotionInput final : public AnalogInput<double>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AccelerometerInput(std::string name, const double& input, ControlState range)
|
using AnalogInput::AnalogInput;
|
||||||
: AnalogInput(std::move(name), input, range)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
bool IsDetectable() override { return false; }
|
bool IsDetectable() override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
using GyroInput = AccelerometerInput;
|
using AccelerometerInput = MotionInput;
|
||||||
|
using GyroInput = MotionInput;
|
||||||
|
|
||||||
class BatteryInput final : public Input
|
class BatteryInput final : public Input
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
using BatteryState = Proto::DsBattery;
|
using BatteryState = Proto::DsBattery;
|
||||||
|
|
||||||
public:
|
|
||||||
BatteryInput(const BatteryState& battery) : m_battery(battery) {}
|
BatteryInput(const BatteryState& battery) : m_battery(battery) {}
|
||||||
|
|
||||||
std::string GetName() const override { return "Battery"; }
|
std::string GetName() const override { return "Battery"; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user