Skip to content

Commit

Permalink
Backends: SDL2, SDL3: SDL_EVENT_MOUSE_WHEEL event doesn't require div…
Browse files Browse the repository at this point in the history
…iding by 100.0f on Emscripten. (#4019, #6096, #1463)

Ref libsdl-org/SDL#10454 (comment)
  • Loading branch information
ocornut committed Oct 24, 2024
1 parent 062e580 commit 06092a9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion backends/imgui_impl_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2024-10-24: Emscripten: from SDL 2.30.9, SDL_EVENT_MOUSE_WHEEL event doesn't require dividing by 100.0f.
// 2024-09-09: use SDL_Vulkan_GetDrawableSize() when available. (#7967, #3190)
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
Expand Down Expand Up @@ -359,7 +360,7 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
float wheel_x = -(float)event->wheel.x;
float wheel_y = (float)event->wheel.y;
#endif
#ifdef __EMSCRIPTEN__
#if defined(__EMSCRIPTEN__) && !SDL_VERSION_ATLEAST(2,31,0)
wheel_x /= 100.0f;
#endif
io.AddMouseSourceEvent(event->wheel.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
Expand Down
4 changes: 1 addition & 3 deletions backends/imgui_impl_sdl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2024-10-24: Emscripten: SDL_EVENT_MOUSE_WHEEL event doesn't require dividing by 100.0f on Emscripten.
// 2024-09-03: Update for SDL3 api changes: SDL_GetGamepads() memory ownership revert. (#7918, #7898, #7807)
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
Expand Down Expand Up @@ -338,9 +339,6 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
//IMGUI_DEBUG_LOG("wheel %.2f %.2f, precise %.2f %.2f\n", (float)event->wheel.x, (float)event->wheel.y, event->wheel.preciseX, event->wheel.preciseY);
float wheel_x = -event->wheel.x;
float wheel_y = event->wheel.y;
#ifdef __EMSCRIPTEN__
wheel_x /= 100.0f;
#endif
io.AddMouseSourceEvent(event->wheel.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
io.AddMouseWheelEvent(wheel_x, wheel_y);
return true;
Expand Down
3 changes: 2 additions & 1 deletion docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Breaking changes:
Other changes:

- Backends: DX12: Unmap() call specify written range. The range is informational and may be used by debug tools.

- Backends: SDL3: Update for SDL3 api change: SDL_EVENT_MOUSE_WHEEL event doesn't require dividing by 100.0f
on Emscripten target. (#4019, #6096, #1463)

-----------------------------------------------------------------------
VERSION 1.91.4 (Released 2024-10-18)
Expand Down

0 comments on commit 06092a9

Please sign in to comment.