OpenWindowedScreen glitchy mouse movement

Advanced game related topics
OgreVorbis
User
User
Posts: 35
Joined: Thu Jan 16, 2020 10:47 pm

OpenWindowedScreen glitchy mouse movement

Post 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............
My blog/software site: http://dosaidsoft.com/
User avatar
STARGÅTE
Addict
Addict
Posts: 1652
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: OpenWindowedScreen glitchy mouse movement

Post 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.
PB 5.73 ― Win 10, 20H2 ― Ryzen 9 3900X ― Radeon RX 5600 XT ITX ― Vivaldi 4.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
#NULL
Addict
Addict
Posts: 1380
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: OpenWindowedScreen glitchy mouse movement

Post 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().
OgreVorbis
User
User
Posts: 35
Joined: Thu Jan 16, 2020 10:47 pm

Re: OpenWindowedScreen glitchy mouse movement

Post 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.
My blog/software site: http://dosaidsoft.com/
User avatar
Mijikai
Addict
Addict
Posts: 1032
Joined: Sun Sep 11, 2016 2:17 pm

Re: OpenWindowedScreen glitchy mouse movement

Post 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.
#NULL
Addict
Addict
Posts: 1380
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: OpenWindowedScreen glitchy mouse movement

Post 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.
OgreVorbis
User
User
Posts: 35
Joined: Thu Jan 16, 2020 10:47 pm

Re: OpenWindowedScreen glitchy mouse movement

Post 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.
My blog/software site: http://dosaidsoft.com/
OgreVorbis
User
User
Posts: 35
Joined: Thu Jan 16, 2020 10:47 pm

Re: OpenWindowedScreen glitchy mouse movement

Post 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.
My blog/software site: http://dosaidsoft.com/
Post Reply