InputCommon: Rename AddAnalogInputs to AddFullAnalogSurfaceInputs.

This commit is contained in:
Jordan Woyak 2024-11-02 17:10:45 -05:00
parent 53ede795a2
commit 2f1390e9f9
8 changed files with 26 additions and 17 deletions

View File

@ -693,7 +693,7 @@ private:
negative = new AndroidAxis(source, axis, true);
if (positive && negative)
AddAnalogInputs(positive, negative);
AddFullAnalogSurfaceInputs(positive, negative);
else if (positive || negative)
AddInput(positive ? positive : negative);
}

View File

@ -164,6 +164,14 @@ bool Device::FullAnalogSurface::IsMatchingName(std::string_view name) const
return old_name == name;
}
void Device::AddFullAnalogSurfaceInputs(Input* low, Input* high)
{
AddInput(low);
AddInput(high);
AddInput(new FullAnalogSurface(low, high));
AddInput(new FullAnalogSurface(high, low));
}
void Device::AddCombinedInput(std::string name, const std::pair<std::string, std::string>& inputs)
{
AddInput(new CombinedInput(std::move(name), {FindInput(inputs.first), FindInput(inputs.second)}));

View File

@ -178,13 +178,14 @@ protected:
Input& m_high;
};
void AddAnalogInputs(Input* low, Input* high)
{
AddInput(low);
AddInput(high);
AddInput(new FullAnalogSurface(low, high));
AddInput(new FullAnalogSurface(high, low));
}
// Pass Inputs for center-neutral (- and +) directions of some axis.
// This function adds those Inputs and also a FullAnalogSurface Input for each direction.
// This is only needed when it's not known if the particular axis is neutral in the center
// or neutral on one of the extremes.
// Some e.g. DInput devices expose a trigger across the full analog surface
// but we have no way of knowing this until the user actually maps the Input,
// so both center-neutral and full-surface Inputs need to be created in that case.
void AddFullAnalogSurfaceInputs(Input* low, Input* high);
void AddCombinedInput(std::string name, const std::pair<std::string, std::string>& inputs);

View File

@ -167,7 +167,7 @@ Joystick::Joystick(const LPDIRECTINPUTDEVICE8 device) : m_device(device)
const LONG& ax = (&m_state_in.lX)[offset];
// 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));
}
}

View File

@ -129,7 +129,7 @@ void PipeDevice::AddAxis(const std::string& name, double value)
ax_lo->SetState(value);
m_axes[name + " +"] = ax_hi;
m_axes[name + " -"] = ax_lo;
AddAnalogInputs(ax_lo, ax_hi);
AddFullAnalogSurfaceInputs(ax_lo, ax_hi);
}
void PipeDevice::SetAxis(const std::string& entry, double value)

View File

@ -710,7 +710,7 @@ GameController::GameController(SDL_GameController* const gamecontroller,
const bool is_registered = registered_axes.contains(i);
// 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));
}

View File

@ -125,8 +125,7 @@ public:
u32 i = 0;
for (auto& axis : m_axes)
{
// AddAnalogInputs adds additional "FullAnalogSurface" Inputs.
AddAnalogInputs(new IndexedAxis(&axis, 0.5, +0.5, i),
AddFullAnalogSurfaceInputs(new IndexedAxis(&axis, 0.5, +0.5, i),
new IndexedAxis(&axis, 0.5, -0.5, i));
++i;
}

View File

@ -572,7 +572,8 @@ bool evdevDevice::AddNode(std::string devnode, int fd, libevdev* dev)
{
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;
}
}