@@ -99,6 +99,7 @@ void SDL3SystemAPI::tick() {
99
99
case SDL_EVENT_MOUSE_MOTION:
100
100
case SDL_EVENT_MOUSE_BUTTON_DOWN:
101
101
case SDL_EVENT_MOUSE_BUTTON_UP:
102
+ case SDL_EVENT_MOUSE_WHEEL:
102
103
if (scene_focused) {
103
104
handleMouseEvent (event);
104
105
}
@@ -222,8 +223,19 @@ void SDL3SystemAPI::handleMouseEvent(SDL_Event& event) {
222
223
SDL_Window* window = SDL_GetWindowFromID (event.motion .windowID );
223
224
SDL_GetWindowSize (window, &window_w, &window_h);
224
225
SDL_GetWindowSizeInPixels (window, &display_w, &display_h);
225
- int x = event.motion .x * (display_w / (float )window_w);
226
- int y = event.motion .y * (display_h / (float )window_h);
226
+
227
+ int x = event.motion .x ;
228
+ int y = event.motion .y ;
229
+ float scroll_x = 0 ;
230
+ float scroll_y = 0 ;
231
+ if (event.type == SDL_EVENT_MOUSE_WHEEL) {
232
+ x = event.wheel .mouse_x ;
233
+ y = event.wheel .mouse_y ;
234
+ scroll_x = -event.wheel .x ;
235
+ scroll_y = event.wheel .y ;
236
+ }
237
+ x *= display_w / (float )window_w;
238
+ y *= display_h / (float )window_h;
227
239
228
240
#ifdef GROWL_IMGUI
229
241
if (api.imguiVisible ()) {
@@ -246,6 +258,9 @@ void SDL3SystemAPI::handleMouseEvent(SDL_Event& event) {
246
258
case SDL_EVENT_MOUSE_MOTION:
247
259
event_type = PointerEventType::Move;
248
260
break ;
261
+ case SDL_EVENT_MOUSE_WHEEL:
262
+ event_type = PointerEventType::Scroll;
263
+ break ;
249
264
}
250
265
251
266
MouseButton mouse_button = MouseButton::Unknown;
@@ -263,7 +278,8 @@ void SDL3SystemAPI::handleMouseEvent(SDL_Event& event) {
263
278
264
279
InputEvent e (
265
280
InputEventType::Mouse,
266
- InputMouseEvent{event_type, mouse_button, x, y});
281
+ InputMouseEvent{
282
+ event_type, mouse_button, x, y, scroll_x, scroll_y});
267
283
inputProcessor->onEvent (e);
268
284
}
269
285
}
0 commit comments