Page 1 of 1
OpenWindowedScreen glitchy mouse movement
Posted: Tue Oct 19, 2021 10:57 am
by OgreVorbis
I am making a game that requires precision mouse movement.
When using ExamineMouse() and MouseX(), MouseY() in my main Repeat ... Until loop, the mouse will occasionally jump around the screen. The movement is not completely fluid. Is there anything I can do to fix this?
Here is a basic idea. My real program has a lot more code, but nothing that's hogging the CPU enough to stop the mouse.
Code: Select all
X.w
Y.w
Repeat
ExamineMouse()
X = MouseX()
Y = MouseY()
...
...
DisplayTransparentSprite(0, X, Y,.....)
Until KeyboardPushed............
Re: OpenWindowedScreen glitchy mouse movement
Posted: Tue Oct 19, 2021 11:25 am
by STARGÅTE
What is the actual frame rate of your scene? If you have a lot of sprite or calculations this frame rate can drop rapidly.
Re: OpenWindowedScreen glitchy mouse movement
Posted: Tue Oct 19, 2021 12:29 pm
by #NULL
IIRC, you can get mouse problems (on linux i think) if your main loop is too fast, i.e. not enough load.
Anyway, if you are using a windowed screen, proper event processing is also required.
Try to reproduce it in a small code. You can simulate your game cpu load with Delay().
Re: OpenWindowedScreen glitchy mouse movement
Posted: Wed Oct 20, 2021 2:41 am
by OgreVorbis
STARGÅTE wrote: Tue Oct 19, 2021 11:25 am
What is the actual frame rate of your scene? If you have a lot of sprite or calculations this frame rate can drop rapidly.
My frame rate must be the default because I'm not using SetFrameRate. I am using FlipBuffers, which I believe makes the framerate 60 fps (or whatever the default of the monitor is). I'm almost willing to just accept it cause it only happens with rapid movement of the mouse.
Either way, my game's sprite movement is VERY fluid though. It can't be below 30, cause I would notice. They don't glitch around like the mouse.
I suspect it's simply that the game can't update the sprite position fast enough. Maybe there's a way I can more loosely tie the mouse to those variables - ie not directly assigning them, but doing some type of processing.
#NULL wrote: Tue Oct 19, 2021 12:29 pm
IIRC, you can get mouse problems (on linux i think) if your main loop is too fast, i.e. not enough load.
Anyway, if you are using a windowed screen, proper event processing is also required.
Try to reproduce it in a small code. You can simulate your game cpu load with Delay().
I'm on Windows 7 and using the default DirectX 9 sub-system. Have event processing with Event = WindowEvent()
I loaded a small example I found elsewhere and it had the same problem. It only happens if you move the mouse quickly.
Re: OpenWindowedScreen glitchy mouse movement
Posted: Wed Oct 20, 2021 8:33 am
by Mijikai
If the FPS is not set it can be anything there is no universal default framerate.
Mouse input afaik is handled through DirectInput which is very fast.
Re: OpenWindowedScreen glitchy mouse movement
Posted: Wed Oct 20, 2021 9:58 am
by #NULL
OgreVorbis wrote: Wed Oct 20, 2021 2:41 am
#NULL wrote: Tue Oct 19, 2021 12:29 pmproper event processing is also required.
Have event processing with Event = WindowEvent()
We still don't know if you have proper event processing, processing all available events per frame, not just one event per frame.
Re: OpenWindowedScreen glitchy mouse movement
Posted: Wed Oct 20, 2021 11:17 am
by OgreVorbis
#NULL wrote: Wed Oct 20, 2021 9:58 am
We still don't know if you have proper event processing, processing all available events per frame, not just one event per frame.
I don't have any events that (I think) need processing other than window close event. Everything else is a keyboard or mouse update.
I'll just post it in the feedback and discussion section soon. It's almost complete (although not perfect). It's actually pretty good.
There may be some other issues with it cause I never made a proper game outside of some development system with hand holding.
Re: OpenWindowedScreen glitchy mouse movement
Posted: Sun Oct 24, 2021 11:50 am
by OgreVorbis
I found the problem. It was the "enhance pointer precision" setting in Windows. With that turned off, it doesn't glitch (even with the sensitivity set high). I tested it on another computer and it was fine, so that's how I discovered it. I like using it, so it's a bit annoying cause it doesn't effect any other applications or games.
Re: OpenWindowedScreen glitchy mouse movement
Posted: Fri Dec 03, 2021 9:21 am
by Axeman
Bear in mind that Purebasic's mouse library has issues with mice that have a high poll rate (like my Logitech G400S). This is a fairly well known problem that has been around for years, but not one that Fred appears to take seriously - based on past interactions.
I wrote a threaded library to fix the problem. You can find the link to it below.
Threaded Mouse Library for Games
https://www.purebasic.fr/english/viewtopic.php?t=77442