Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DInputSource: Ignore devices with no buttons #10155

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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