Skip to content

Commit

Permalink
DInputSource: Ignore devices with no buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Oct 21, 2023
1 parent 0a8f71e commit f61bb99
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pcsx2/Input/DInputSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ bool DInputSource::AddDevice(ControllerData& cd, const std::string& name)
return false;
}

cd.num_buttons = caps.dwButtons;
if (caps.dwButtons == 0)
{
Console.Error("Ignoring device '%s' because it has no buttons (%u axes, %u POVs).", name.c_str(), caps.dwAxes, caps.dwPOVs);
return false;
}

static constexpr const u32 axis_offsets[] = {offsetof(DIJOYSTATE2, lX), offsetof(DIJOYSTATE2, lY), offsetof(DIJOYSTATE2, lZ),
offsetof(DIJOYSTATE2, lRz), offsetof(DIJOYSTATE2, lRx), offsetof(DIJOYSTATE2, lRy), offsetof(DIJOYSTATE2, rglSlider[0]),
Expand All @@ -232,8 +236,6 @@ bool DInputSource::AddDevice(ControllerData& cd, const std::string& name)
cd.axis_offsets.push_back(offset);
}

cd.num_hats = caps.dwPOVs;

hr = cd.device->Poll();
if (hr == DI_NOEFFECT)
cd.needs_poll = false;
Expand All @@ -244,6 +246,9 @@ bool DInputSource::AddDevice(ControllerData& cd, const std::string& name)
if (hr != DI_OK)
Console.Warning("GetDeviceState() for '%s' failed: %08X", name.c_str(), hr);

cd.num_buttons = caps.dwButtons;
cd.num_hats = caps.dwPOVs;

Console.WriteLn(
"%s has %u buttons, %u axes, %u hats", name.c_str(), cd.num_buttons, static_cast<u32>(cd.axis_offsets.size()), cd.num_hats);

Expand Down

0 comments on commit f61bb99

Please sign in to comment.