diff --git a/src/duckstation-qt/inputbindingdialog.cpp b/src/duckstation-qt/inputbindingdialog.cpp index da5bd12a8..f80225fb7 100644 --- a/src/duckstation-qt/inputbindingdialog.cpp +++ b/src/duckstation-qt/inputbindingdialog.cpp @@ -54,9 +54,8 @@ bool InputBindingDialog::eventFilter(QObject* watched, QEvent* event) else if (event_type == QEvent::MouseButtonPress || event_type == QEvent::MouseButtonDblClick) { // double clicks get triggered if we click bind, then click again quickly. - unsigned long button_index; - if (_BitScanForward(&button_index, static_cast(static_cast(event)->button()))) - m_new_bindings.push_back(InputManager::MakePointerButtonKey(0, button_index)); + unsigned button_index = CountTrailingZeros(static_cast(static_cast(event)->button())); + m_new_bindings.push_back(InputManager::MakePointerButtonKey(0, button_index)); return true; } else if (event_type == QEvent::Wheel) diff --git a/src/duckstation-qt/inputbindingwidgets.cpp b/src/duckstation-qt/inputbindingwidgets.cpp index a1a9ac749..c4aceda53 100644 --- a/src/duckstation-qt/inputbindingwidgets.cpp +++ b/src/duckstation-qt/inputbindingwidgets.cpp @@ -111,9 +111,8 @@ bool InputBindingWidget::eventFilter(QObject* watched, QEvent* event) else if (event_type == QEvent::MouseButtonPress || event_type == QEvent::MouseButtonDblClick) { // double clicks get triggered if we click bind, then click again quickly. - unsigned long button_index; - if (_BitScanForward(&button_index, static_cast(static_cast(event)->button()))) - m_new_bindings.push_back(InputManager::MakePointerButtonKey(0, button_index)); + const u32 button_index = CountTrailingZeros(static_cast(static_cast(event)->button())); + m_new_bindings.push_back(InputManager::MakePointerButtonKey(0, button_index)); return true; } else if (event_type == QEvent::Wheel) diff --git a/src/frontend-common/sdl_input_source.cpp b/src/frontend-common/sdl_input_source.cpp index bc7d2ffa0..4ce09d84d 100644 --- a/src/frontend-common/sdl_input_source.cpp +++ b/src/frontend-common/sdl_input_source.cpp @@ -3,6 +3,7 @@ #include "sdl_input_source.h" #include "common/assert.h" +#include "common/bitutils.h" #include "common/log.h" #include "common/string_util.h" #include "core/host.h" @@ -718,8 +719,7 @@ bool SDLInputSource::HandleJoystickHatEvent(const SDL_JoyHatEvent* ev) unsigned long changed_direction = last_direction ^ ev->value; while (changed_direction != 0) { - unsigned long pos; - _BitScanForward(&pos, changed_direction); + const u32 pos = CountTrailingZeros(changed_direction); const unsigned long mask = (1u << pos); changed_direction &= ~mask;