[SDL] Mouse relative position wrong values

Alexander Chaliovski sabotage3d at gmail.com
Mon Sep 22 16:27:21 PDT 2014


Thank you for your reply.  It happend on IOS . It seems the mouse
SDL_MOUSEMOTION was including the event SDL_MOUSEBUTTONDOWN .
Do we have to check first for SDL_MOUSEBUTTONDOWN  and then listen for
SDL_MOUSEMOTION events ?

Thanks,

Alex


On Mon, Sep 22, 2014 at 11:24 PM, Jeffrey Carpenter <i8degrees at gmail.com>
wrote:

> Heya,
>
> You aren't using SDL2's "independent resolution scaling" AKA logical size
> viewport (SDL_SetLogicalSize & friends) by chance, are you? If so, perhaps
> it may be possible that it could be interfering with your results? (Pure
> speculation from me)
>
> You can see how the values are adjusted to account for the feature in
> SDL_render.c:SDL_RendererEventWatch event handling for SDL_MOUSEMOTION,
> SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP
>
> I am on Mac OS X v10.9.4 and did not appear to exhibit the odd behavior
> you describe, given your test sample. My testing sample was this file:
> http://pastebin.com/D7Sr3UJq (built off SDL2 v2.0.3 framework bundle).
>
> Cheers,
> Jeffrey Carpenter
> <i8degrees at gmail.com>
>
> On 2014/09/ 21, at 12:13, Alexander Chaliovski <sabotage3d at gmail.com>
> wrote:
>
> > 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
> > _______________________________________________
> > SDL mailing list
> > SDL at lists.libsdl.org
> > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140923/8c28deb2/attachment-0002.htm>


More information about the SDL mailing list