MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / sdlMouseWheelFilter

Function sdlMouseWheelFilter

ddio/lnxmouse.cpp:346–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344}
345
346int sdlMouseWheelFilter(SDL_Event const *event) {
347 ASSERT(event->type == SDL_MOUSEWHEEL);
348
349 const SDL_MouseWheelEvent *ev = &event->wheel;
350 t_mse_event mevt;
351
352 // !!! FIXME: this ignores horizontal wheels for now, since Descent3 doesn't currently have a concept of them
353 // !!! FIXME: (vertical mouse wheels are represented as mouse buttons 4 and 5, incorrectly, on all platforms).
354 // !!! FIXME: this will require improvements to the engine before this changes here, though.
355
356 if (ev->y > 0) { /* Mouse scroll up */
357 DDIO_mouse_state.btn_mask |= MOUSE_B5;
358 DIM_buttons.down_count[4]++;
359 DIM_buttons.time_down[4] = timer_GetTime();
360 DIM_buttons.is_down[4] = true;
361 mevt.btn = 4;
362 mevt.state = true;
363 MB_queue.send(mevt);
364
365 // send an immediate release event, as if the "button" was clicked. !!! FIXME: this also needs improvements in the engine.
366 // don't remove from btn_mask
367 DIM_buttons.up_count[4]++;
368 DIM_buttons.is_down[4] = false;
369 DIM_buttons.time_up[4] = timer_GetTime();
370 mevt.btn = 4;
371 mevt.state = false;
372 MB_queue.send(mevt);
373 // mprintf(0, "MOUSE Scrollwheel: Rolled Up\n");
374 } else if (ev->y < 0) { /* Mouse scroll down */
375 DDIO_mouse_state.btn_mask |= MOUSE_B6;
376 DIM_buttons.down_count[5]++;
377 DIM_buttons.time_down[5] = timer_GetTime();
378 DIM_buttons.is_down[5] = true;
379 mevt.btn = 5;
380 mevt.state = true;
381 MB_queue.send(mevt);
382
383 // send an immediate release event, as if the "button" was clicked. !!! FIXME: this also needs improvements in the engine.
384 // don't remove from btn_mask
385 DIM_buttons.up_count[5]++;
386 DIM_buttons.is_down[5] = false;
387 DIM_buttons.time_up[5] = timer_GetTime();
388 mevt.btn = 5;
389 mevt.state = false;
390 MB_queue.send(mevt);
391 // mprintf(0, "MOUSE Scrollwheel: Rolled Down\n");
392 }
393
394 return 0;
395}
396
397int sdlMouseMotionFilter(SDL_Event const *event) {
398 /*

Callers 1

d3SDLEventFilterFunction · 0.85

Calls 1

sendMethod · 0.45

Tested by

no test coverage detected