catch out of range buttons

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
slowriot 2026-03-31 16:28:20 +01:00 committed by GitHub
parent 426bff6aed
commit 416d85c9e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -179,7 +179,7 @@ constexpr ImGuiMouseButton translate_mousebutton(unsigned short emscripten_butto
// Translate an emscripten-provided integer describing a mouse button to an imgui mouse button
if (emscripten_button == 1) return ImGuiMouseButton_Middle; // 1 = middle mouse button
if (emscripten_button == 2) return ImGuiMouseButton_Right; // 2 = right mouse button
if (emscripten_button > ImGuiMouseButton_COUNT) return ImGuiMouseButton_Middle; // treat any weird clicks on unexpected buttons (button 6 upwards) as middle mouse
if (emscripten_button >= ImGuiMouseButton_COUNT) return ImGuiMouseButton_Middle; // treat any weird clicks on unexpected buttons (button 6 upwards) as middle mouse
return emscripten_button; // any other button translates 1:1
}