mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-13 15:59:23 +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
|
||||
using SteadyClock = std::chrono::steady_clock;
|
||||
|
||||
class Device : public Core::Device
|
||||
class Device final : public Core::Device
|
||||
{
|
||||
private:
|
||||
template <class T>
|
||||
class Button : public Core::Device::Input
|
||||
class Button final : public Input
|
||||
{
|
||||
public:
|
||||
Button(std::string name, const T& buttons, unsigned mask)
|
||||
: m_name(std::move(name)), m_buttons(buttons), m_mask(mask)
|
||||
Button(const char* name, const T& buttons, T mask)
|
||||
: m_name(name), m_buttons(buttons), m_mask(mask)
|
||||
{
|
||||
}
|
||||
std::string GetName() const override { return m_name; }
|
||||
ControlState GetState() const override { return (m_buttons & m_mask) != 0; }
|
||||
|
||||
private:
|
||||
const std::string m_name;
|
||||
const char* const m_name;
|
||||
const T& m_buttons;
|
||||
unsigned m_mask;
|
||||
const T m_mask;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class AnalogInput : public Core::Device::Input
|
||||
class AnalogInput : public Input
|
||||
{
|
||||
public:
|
||||
AnalogInput(std::string name, const T& input, ControlState range, ControlState offset = 0)
|
||||
: m_name(std::move(name)), m_input(input), m_range(range), m_offset(offset)
|
||||
AnalogInput(const char* name, const T& input, ControlState range, ControlState offset = 0)
|
||||
: m_name(name), m_input(input), m_range(range), m_offset(offset)
|
||||
{
|
||||
}
|
||||
std::string GetName() const override { return m_name; }
|
||||
ControlState GetState() const override { return (ControlState(m_input) + m_offset) / m_range; }
|
||||
std::string GetName() const final override { return m_name; }
|
||||
ControlState GetState() const final override
|
||||
{
|
||||
return (ControlState(m_input) + m_offset) / m_range;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string m_name;
|
||||
const char* m_name;
|
||||
const T& m_input;
|
||||
const ControlState m_range;
|
||||
const ControlState m_offset;
|
||||
};
|
||||
|
||||
class TouchInput : public AnalogInput<int>
|
||||
class TouchInput final : public AnalogInput<int>
|
||||
{
|
||||
public:
|
||||
TouchInput(std::string name, const int& input, ControlState range)
|
||||
: AnalogInput(std::move(name), input, range)
|
||||
{
|
||||
}
|
||||
using AnalogInput::AnalogInput;
|
||||
bool IsDetectable() override { return false; }
|
||||
};
|
||||
|
||||
class AccelerometerInput : public AnalogInput<double>
|
||||
class MotionInput final : public AnalogInput<double>
|
||||
{
|
||||
public:
|
||||
AccelerometerInput(std::string name, const double& input, ControlState range)
|
||||
: AnalogInput(std::move(name), input, range)
|
||||
{
|
||||
}
|
||||
using AnalogInput::AnalogInput;
|
||||
bool IsDetectable() override { return false; }
|
||||
};
|
||||
|
||||
using GyroInput = AccelerometerInput;
|
||||
using AccelerometerInput = MotionInput;
|
||||
using GyroInput = MotionInput;
|
||||
|
||||
class BatteryInput final : public Input
|
||||
{
|
||||
public:
|
||||
using BatteryState = Proto::DsBattery;
|
||||
|
||||
public:
|
||||
BatteryInput(const BatteryState& battery) : m_battery(battery) {}
|
||||
|
||||
std::string GetName() const override { return "Battery"; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user