Discussion:
[SDL] Why do I get so few points(SDL_MOUSEMOTION) when I move fast
sgrsgsrg
2016-09-13 15:11:11 UTC
Permalink
I think it's limited by what windows sends with its API, maybe it's locked on the main display frequency? If you want more points you'll need to interpolate between them. Like when you draw with a painting program, they all use some sort of bezier interpolation to make nice curves, otherwise it would looks like multiple segments linked to each other.
Alex Barry
2016-09-13 15:20:08 UTC
Permalink
I think most apps interpolate with curves, which isn't too bad if you have
at least 3 points. I've seen this behaviour for years, and I don't think
it's an issue with SDL.
Post by sgrsgsrg
I think it's limited by what windows sends with its API, maybe it's locked
on the main display frequency? If you want more points you'll need to
interpolate between them. Like when you draw with a painting program, they
all use some sort of bezier interpolation to make nice curves, otherwise it
would looks like multiple segments linked to each other.
_______________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Eric Wasylishen
2016-09-13 20:58:32 UTC
Permalink
Hi,
Try using relative mouse mode (SDL_SetRelativeMouseMode(SDL_True); ) -
this requests raw mouse events, with no acceleration and at the full
rate your mouse can send them. This is implemented on Windows, and I
think, Linux.

What OS / SDL version / mouse model was this on? The maximum event
rate depends on the mouse.
Eric
Post by Alex Barry
I think most apps interpolate with curves, which isn't too bad if you have
at least 3 points. I've seen this behaviour for years, and I don't think
it's an issue with SDL.
Post by sgrsgsrg
I think it's limited by what windows sends with its API, maybe it's locked
on the main display frequency? If you want more points you'll need to
interpolate between them. Like when you draw with a painting program, they
all use some sort of bezier interpolation to make nice curves, otherwise it
would looks like multiple segments linked to each other.
_______________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_______________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Ismael Serrano
2016-09-13 21:03:40 UTC
Permalink
Or you can get the current position on the update and compare with the
previous to check if there is any difference.

///--- Store the current information to the previous
m_iPreviousCoordX=m_iCurrentCoordX;
m_iPreviousCoordY=m_iCurrentCoordY;
m_uPreviousMouseState=m_uCurrentMouseState;

///--- Update the current state of the mouse
m_uCurrentMouseState=SDL_GetMouseState(&m_iCurrentCoordX,
&m_iCurrentCoordY);
Post by Eric Wasylishen
Hi,
Try using relative mouse mode (SDL_SetRelativeMouseMode(SDL_True); ) -
this requests raw mouse events, with no acceleration and at the full
rate your mouse can send them. This is implemented on Windows, and I
think, Linux.
What OS / SDL version / mouse model was this on? The maximum event
rate depends on the mouse.
Eric
Post by Alex Barry
I think most apps interpolate with curves, which isn't too bad if you
have
Post by Alex Barry
at least 3 points. I've seen this behaviour for years, and I don't think
it's an issue with SDL.
Post by sgrsgsrg
I think it's limited by what windows sends with its API, maybe it's
locked
Post by Alex Barry
Post by sgrsgsrg
on the main display frequency? If you want more points you'll need to
interpolate between them. Like when you draw with a painting program,
they
Post by Alex Barry
Post by sgrsgsrg
all use some sort of bezier interpolation to make nice curves,
otherwise it
Post by Alex Barry
Post by sgrsgsrg
would looks like multiple segments linked to each other.
_______________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_______________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_______________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Ryan C. Gordon
2016-09-15 18:19:47 UTC
Permalink
Post by Ismael Serrano
Or you can get the current position on the update and compare with the
previous to check if there is any difference.
| ||///--- Update the current state of the mouse|
| ||m_uCurrentMouseState=SDL_GetMouseState(&m_iCurrentCoordX,
&m_iCurrentCoordY);|
To be clear: SDL_GetMouseState() returns the last-known mouse positions,
based on what events the OS has previously sent. It's more convenient in
some cases than relying on SDL's event loop, but it's not any more accurate.

--ryan.
Ryan C. Gordon
2016-09-15 18:36:36 UTC
Permalink
Post by sgrsgsrg
I think it's limited by what windows sends with its API
Specifically:
https://blogs.msdn.microsoft.com/oldnewthing/20031001-00/?p=42343/

If you're getting _really_ imprecise mouse input, you probably need to
run the SDL event queue more often (is there an SDL_Delay() or something
in your program?), as mouse resolution on Windows is limited to how fast
you check for more mouse events.

(Switching on relative mouse mode in SDL might help, as I assume Win32
RAWINPUT isn't limited in this way.)

--ryan.
NetCraft
2016-09-13 21:33:25 UTC
Permalink
Thanks. I'll try to interpolate my points via Bezier curve. Hope it helps :)
NetCraft
2016-09-16 04:22:56 UTC
Permalink
I use SDL for Mac/Win/Android operating systems. So I think the solution will be different on those systems?
Loading...