mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Merge pull request #13165 from jordan-woyak/FullAnalogSurface-rename
InputCommon: Rename AddAnalogInputs to AddFullAnalogSurfaceInputs.
This commit is contained in:
commit
b8823457c1
@ -693,7 +693,7 @@ private:
|
|||||||
negative = new AndroidAxis(source, axis, true);
|
negative = new AndroidAxis(source, axis, true);
|
||||||
|
|
||||||
if (positive && negative)
|
if (positive && negative)
|
||||||
AddAnalogInputs(positive, negative);
|
AddFullAnalogSurfaceInputs(positive, negative);
|
||||||
else if (positive || negative)
|
else if (positive || negative)
|
||||||
AddInput(positive ? positive : negative);
|
AddInput(positive ? positive : negative);
|
||||||
}
|
}
|
||||||
|
@ -130,38 +130,50 @@ bool Device::Control::IsHidden() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState Device::FullAnalogSurface::GetState() const
|
class FullAnalogSurface final : public Device::Input
|
||||||
{
|
{
|
||||||
return (1 + std::max(0.0, m_high.GetState()) - std::max(0.0, m_low.GetState())) / 2;
|
public:
|
||||||
}
|
FullAnalogSurface(Input* low, Input* high) : m_low(*low), m_high(*high) {}
|
||||||
|
|
||||||
std::string Device::FullAnalogSurface::GetName() const
|
ControlState GetState() const override
|
||||||
|
{
|
||||||
|
return (1 + std::max(0.0, m_high.GetState()) - std::max(0.0, m_low.GetState())) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetName() const override
|
||||||
|
{
|
||||||
|
// E.g. "Full Axis X+"
|
||||||
|
return "Full " + m_high.GetName();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsDetectable() const override { return m_low.IsDetectable() && m_high.IsDetectable(); }
|
||||||
|
|
||||||
|
bool IsHidden() const override { return m_low.IsHidden() && m_high.IsHidden(); }
|
||||||
|
|
||||||
|
bool IsMatchingName(std::string_view name) const override
|
||||||
|
{
|
||||||
|
if (Control::IsMatchingName(name))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Old naming scheme was "Axis X-+" which is too visually similar to "Axis X+".
|
||||||
|
// This has caused countless problems for users with mysterious misconfigurations.
|
||||||
|
// We match this old name to support old configurations.
|
||||||
|
const auto old_name = m_low.GetName() + *m_high.GetName().rbegin();
|
||||||
|
|
||||||
|
return old_name == name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Input& m_low;
|
||||||
|
Input& m_high;
|
||||||
|
};
|
||||||
|
|
||||||
|
void Device::AddFullAnalogSurfaceInputs(Input* low, Input* high)
|
||||||
{
|
{
|
||||||
// E.g. "Full Axis X+"
|
AddInput(low);
|
||||||
return "Full " + m_high.GetName();
|
AddInput(high);
|
||||||
}
|
AddInput(new FullAnalogSurface(low, high));
|
||||||
|
AddInput(new FullAnalogSurface(high, low));
|
||||||
bool Device::FullAnalogSurface::IsDetectable() const
|
|
||||||
{
|
|
||||||
return m_low.IsDetectable() && m_high.IsDetectable();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Device::FullAnalogSurface::IsHidden() const
|
|
||||||
{
|
|
||||||
return m_low.IsHidden() && m_high.IsHidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Device::FullAnalogSurface::IsMatchingName(std::string_view name) const
|
|
||||||
{
|
|
||||||
if (Control::IsMatchingName(name))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Old naming scheme was "Axis X-+" which is too visually similar to "Axis X+".
|
|
||||||
// This has caused countless problems for users with mysterious misconfigurations.
|
|
||||||
// We match this old name to support old configurations.
|
|
||||||
const auto old_name = m_low.GetName() + *m_high.GetName().rbegin();
|
|
||||||
|
|
||||||
return old_name == name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::AddCombinedInput(std::string name, const std::pair<std::string, std::string>& inputs)
|
void Device::AddCombinedInput(std::string name, const std::pair<std::string, std::string>& inputs)
|
||||||
|
@ -163,28 +163,14 @@ protected:
|
|||||||
void AddInput(Input* const i);
|
void AddInput(Input* const i);
|
||||||
void AddOutput(Output* const o);
|
void AddOutput(Output* const o);
|
||||||
|
|
||||||
class FullAnalogSurface final : public Input
|
// Pass Inputs for center-neutral (- and +) directions of some axis.
|
||||||
{
|
// This function adds those Inputs and also a FullAnalogSurface Input for each direction.
|
||||||
public:
|
// This is only needed when it's not known if the particular axis is neutral in the center
|
||||||
FullAnalogSurface(Input* low, Input* high) : m_low(*low), m_high(*high) {}
|
// or neutral on one of the extremes.
|
||||||
ControlState GetState() const override;
|
// Some e.g. DInput devices expose a trigger across the full analog surface
|
||||||
std::string GetName() const override;
|
// but we have no way of knowing this until the user actually maps the Input,
|
||||||
bool IsDetectable() const override;
|
// so both center-neutral and full-surface Inputs need to be created in that case.
|
||||||
bool IsHidden() const override;
|
void AddFullAnalogSurfaceInputs(Input* low, Input* high);
|
||||||
bool IsMatchingName(std::string_view name) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Input& m_low;
|
|
||||||
Input& m_high;
|
|
||||||
};
|
|
||||||
|
|
||||||
void AddAnalogInputs(Input* low, Input* high)
|
|
||||||
{
|
|
||||||
AddInput(low);
|
|
||||||
AddInput(high);
|
|
||||||
AddInput(new FullAnalogSurface(low, high));
|
|
||||||
AddInput(new FullAnalogSurface(high, low));
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddCombinedInput(std::string name, const std::pair<std::string, std::string>& inputs);
|
void AddCombinedInput(std::string name, const std::pair<std::string, std::string>& inputs);
|
||||||
|
|
||||||
|
@ -167,8 +167,8 @@ Joystick::Joystick(const LPDIRECTINPUTDEVICE8 device) : m_device(device)
|
|||||||
const LONG& ax = (&m_state_in.lX)[offset];
|
const LONG& ax = (&m_state_in.lX)[offset];
|
||||||
|
|
||||||
// each axis gets a negative and a positive input instance associated with it
|
// each axis gets a negative and a positive input instance associated with it
|
||||||
AddAnalogInputs(new Axis(offset, ax, base, range.lMin - base),
|
AddFullAnalogSurfaceInputs(new Axis(offset, ax, base, range.lMin - base),
|
||||||
new Axis(offset, ax, base, range.lMax - base));
|
new Axis(offset, ax, base, range.lMax - base));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ void PipeDevice::AddAxis(const std::string& name, double value)
|
|||||||
ax_lo->SetState(value);
|
ax_lo->SetState(value);
|
||||||
m_axes[name + " +"] = ax_hi;
|
m_axes[name + " +"] = ax_hi;
|
||||||
m_axes[name + " -"] = ax_lo;
|
m_axes[name + " -"] = ax_lo;
|
||||||
AddAnalogInputs(ax_lo, ax_hi);
|
AddFullAnalogSurfaceInputs(ax_lo, ax_hi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PipeDevice::SetAxis(const std::string& entry, double value)
|
void PipeDevice::SetAxis(const std::string& entry, double value)
|
||||||
|
@ -710,8 +710,8 @@ GameController::GameController(SDL_GameController* const gamecontroller,
|
|||||||
const bool is_registered = registered_axes.contains(i);
|
const bool is_registered = registered_axes.contains(i);
|
||||||
|
|
||||||
// each axis gets a negative and a positive input instance associated with it
|
// each axis gets a negative and a positive input instance associated with it
|
||||||
AddAnalogInputs(new LegacyAxis(m_joystick, i, -32768, is_registered),
|
AddFullAnalogSurfaceInputs(new LegacyAxis(m_joystick, i, -32768, is_registered),
|
||||||
new LegacyAxis(m_joystick, i, 32767, is_registered));
|
new LegacyAxis(m_joystick, i, 32767, is_registered));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hats
|
// Hats
|
||||||
|
@ -125,9 +125,8 @@ public:
|
|||||||
u32 i = 0;
|
u32 i = 0;
|
||||||
for (auto& axis : m_axes)
|
for (auto& axis : m_axes)
|
||||||
{
|
{
|
||||||
// AddAnalogInputs adds additional "FullAnalogSurface" Inputs.
|
AddFullAnalogSurfaceInputs(new IndexedAxis(&axis, 0.5, +0.5, i),
|
||||||
AddAnalogInputs(new IndexedAxis(&axis, 0.5, +0.5, i),
|
new IndexedAxis(&axis, 0.5, -0.5, i));
|
||||||
new IndexedAxis(&axis, 0.5, -0.5, i));
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -572,7 +572,8 @@ bool evdevDevice::AddNode(std::string devnode, int fd, libevdev* dev)
|
|||||||
{
|
{
|
||||||
if (libevdev_has_event_code(dev, EV_ABS, axis))
|
if (libevdev_has_event_code(dev, EV_ABS, axis))
|
||||||
{
|
{
|
||||||
AddAnalogInputs(new Axis(num_axis, axis, false, dev), new Axis(num_axis, axis, true, dev));
|
AddFullAnalogSurfaceInputs(new Axis(num_axis, axis, false, dev),
|
||||||
|
new Axis(num_axis, axis, true, dev));
|
||||||
++num_axis;
|
++num_axis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user