From 37d643c7d3055c40ebaca920f7efa34a6337379b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 2 Aug 2019 10:16:26 -0400 Subject: [PATCH] InputCommon/DInputJoystick: Correct force-feedback flag testing Introduced in a995e2f5ba3bb55b4245675428bbdc3d34cb7355 We need to be performing a bitwise AND on the flags and not a logical AND, otherwise we could end up counting device objects that don't support forced feedback. --- .../ControllerInterface/DInput/DInputJoystick.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp index bba6b87ae6..ff27eedf44 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp @@ -164,9 +164,8 @@ Joystick::Joystick(/*const LPCDIDEVICEINSTANCE lpddi, */ const LPDIRECTINPUTDEVI if (SUCCEEDED(m_device->EnumObjects(DIEnumDeviceObjectsCallback, (LPVOID)&objects, DIDFT_AXIS))) { const int num_ff_axes = - std::count_if(std::begin(objects), std::end(objects), [](DIDEVICEOBJECTINSTANCE& pdidoi) { - return pdidoi.dwFlags && DIDOI_FFACTUATOR; - }); + std::count_if(std::begin(objects), std::end(objects), + [](const auto& pdidoi) { return (pdidoi.dwFlags & DIDOI_FFACTUATOR) != 0; }); InitForceFeedback(m_device, num_ff_axes); }