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

Function sdlMouseMotionFilter

ddio/lnxmouse.cpp:397–491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395}
396
397int sdlMouseMotionFilter(SDL_Event const *event) {
398 /*
399 int oldmx, oldmy;
400 int deltamx,deltamy;
401 oldmx = DDIO_mouse_state.cx;
402 oldmy = DDIO_mouse_state.cy;
403 deltamx = deltamy = 0;
404
405 bool use_dga = false;
406
407 if(Lnx_app_obj->m_Flags&APPFLAG_DGAMOUSE)
408 use_dga = true;
409
410 if(Mouse_mode==MOUSE_STANDARD_MODE)
411 return;
412
413 while (XCheckMaskEvent(Lnx_app_obj->m_Display, PointerMotionMask | ButtonPressMask | ButtonReleaseMask, &evt))
414 {
415 switch (evt.type)
416 {
417 case MotionNotify:
418 if(use_dga)
419 {
420
421 deltamx += event->motion.x; //evt.xmotion.x_root;
422 deltamy += event->motion.y; //evt.xmotion.y_root;
423
424 }else
425 {
426 if ((evt.xmotion.x != DDIO_mouse_state.cx) && (evt.xmotion.y != DDIO_mouse_state.cy)) {
427 deltamx += (evt.xmotion.x - oldmx);
428 deltamy += (evt.xmotion.y - oldmy);
429 oldmx = evt.xmotion.x;
430 oldmy = evt.xmotion.y;
431 }
432 }
433 break;
434 case ButtonPress:
435 case ButtonRelease:
436 break;
437 }
438 }
439
440 if( (deltamx) || (deltamy) )
441 {
442 DDIO_mouse_state.dx = deltamx;
443 DDIO_mouse_state.dy = deltamy;
444 DDIO_mouse_state.x += deltamx;
445 DDIO_mouse_state.y += deltamy;
446 if (DDIO_mouse_state.x < DDIO_mouse_state.l) DDIO_mouse_state.x = DDIO_mouse_state.l;
447 if (DDIO_mouse_state.x >= DDIO_mouse_state.r) DDIO_mouse_state.x = DDIO_mouse_state.r-1;
448 if (DDIO_mouse_state.y < DDIO_mouse_state.t) DDIO_mouse_state.y = DDIO_mouse_state.t;
449 if (DDIO_mouse_state.y >= DDIO_mouse_state.b) DDIO_mouse_state.y = DDIO_mouse_state.b-1;
450
451 // warp the mouse.
452 if(!use_dga)
453 {
454 XWarpPointer(Lnx_app_obj->m_Display, None, Lnx_app_obj->m_Window,

Callers 1

d3SDLEventFilterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected