[SDL] Mouse relative position wrong values

Alexander Chaliovski sabotage3d at gmail.com
Sun Sep 21 10:13:10 PDT 2014


Hello ,

I am getting weird mouse relative position with SDL 2.0.3 .
The first mouse motion after the mouse click gives huge values after that
the relative coords are correct is there a workaround or I have to
calculate relative mouse coordinates myself ?
I am testing the code under OSX and IOS . Or if there is a way to ignore
the first event.

This is example code:

int x;
int y;

SDL_Event evt;
while(SDL_PollEvent(&evt))
{
    switch(evt.type)
    {

        case SDL_MOUSEMOTION:
               x = evt.motion.xrel
               y = evt.motion.yrel
            break;
    }
}

First two clicks on the screen.

INFO: x: -22, y: -354
INFO: x: -184, y: 808

Thanks,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140921/655faed6/attachment.htm>


More information about the SDL mailing list