NoGUI: Map mouse buttons to match Qt

This commit is contained in:
Connor McLaughlin 2021-07-11 21:44:10 +10:00
parent 1405ba8a6b
commit 134056bb93
1 changed files with 4 additions and 2 deletions

View File

@ -371,9 +371,11 @@ void SDLHostInterface::HandleSDLEvent(const SDL_Event* event)
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
{
if (!ImGui::GetIO().WantCaptureMouse)
// map left -> 0, right -> 1, middle -> 2 to match with qt
static constexpr std::array<s32, 5> mouse_mapping = {{1, 3, 2, 4, 5}};
if (!ImGui::GetIO().WantCaptureMouse && event->button.button > 0 && event->button.button <= mouse_mapping.size())
{
const s32 button = static_cast<s32>(ZeroExtend32(event->button.button));
const s32 button = mouse_mapping[event->button.button - 1];
const bool pressed = (event->type == SDL_MOUSEBUTTONDOWN);
HandleHostMouseEvent(button, pressed);
}