MouseX/MouseY Input Lag??

BlitzMax Forums/BlitzMax Beginners Area/MouseX/MouseY Input Lag??

Aeronux(Posted 2007) [#1]
Hello. In my little RTS game project, I use MouseX() and MouseY() for all sorts of different things. However, there is some sort of lag between the time you click and the time you move your mouse. For instance, if you try to drag to select a group of units, you have to move your mouse, wait a second, click, wait a second, move the mouse, release, wait a second, then issue an order. If otherwise, the selection rectangle will become altered due to this lag problem.

Is there any sort of way for me to fix this? I appreciate it.


H&K(Posted 2007) [#2]
Are you clearing the input buffer after you have grabed the click?


Aeronux(Posted 2007) [#3]
What? I didn't know you needed to...

What does that do?

edit: looked it up, is flushmouse what you mean (cleans out mouse button states?) ? I was manually doing that actually, but I added in those (flushmouse and flushkeys) at the end of my input function, and it just made the lag worse...


H&K(Posted 2007) [#4]
What? I didn't know you needed to
Dont get me wrong, Im guessing
oh well, thats me stumped ;)

Humm, I "think" then you have to make sure that the program has time to handle the queue, so Maybe a delay 1?


Aeronux(Posted 2007) [#5]
Well, I have a FPS maintaining object that automatically keeps my 'game' from running to quickly (so, it is already delaying X ms...)

So, there goes that idea.

I appreciate the help though H&K.


FlameDuck(Posted 2007) [#6]
However, there is some sort of lag between the time you click and the time you move your mouse.
Switch to OpenGL. This is a known issue with DirectX and nVidia drivers, that is considered a feature by both Microsoft and nVidia. If you have an nVidia graphics card, you can install the Forceware Coolbits package (or manually hack your registry) to change the setting "Maximum frames to render ahead" from the default of 3 to a more sensible default of 1.


tonyg(Posted 2007) [#7]
Are you using the latest Bmax level?
Search for 'mouse lag' in the Bmax forums as there is anb oustanding issue in windowed mode (and that might even be fixed with latest syncmods).
It's always useful to provide small example code showing the problem.


TomToad(Posted 2007) [#8]
@FlameDuck: I don't think that's his problem. I get a mouse lag as well, but it is only a fraction of a second. Long enough to be noticeable, but not an entire second long. Unless his movement requires precision movement, I'd doubt he'd really notice the lag at all.

eta: This will show you the difference between where the mouse pointer is and where the pointer is being rendered.
Graphics 800,600,32

While Not KeyHit(KEY_ESCAPE)
	Cls
	DrawRect MouseX()-10,MouseY()-10,20,20
	Flip
Wend



skidracer(Posted 2007) [#9]
There was a lag issue for windowed mode dx that was fixed last week, syncmods for a fix.

Aeronux, are you using normal flip?

If your game does have intense render requirements you would be best reading the mouse events and not using mousex() mousey(). The following demonstrates (see EventX etc. for more details (equals location of mouse at time MouseDown or such actually occured)).

Framework brl.d3d7max2d
Import brl.eventqueue

Graphics 640,480

While True
	While PollEvent()
		DebugLog CurrentEvent.tostring()
	Wend
	Flip
Wend



Grey Alien(Posted 2007) [#10]
yeahthis whole second thing sounds like a completely different issue. The render lag wasn't that bad unless you were doing silly amounts of rendering and then it affected keys and pointer position, everything.


ImaginaryHuman(Posted 2007) [#11]
I just got a new Intel iMac with OpenGL and am finding a significant mouse lag effect.

Any ideas?


Dreamora(Posted 2007) [#12]
From the description: DO NOT USE DELAY to force drop the frame rate!
Delay will hold the whole application, this actually means that during that time, input isn't processed as well -> queue up of all user input which can have some "unnice" side efects.
And after each flip, just to make sure, grab a 1x1 large pixmap, this clears the backbuffer chain (or has the fix been reimplemented into the new DX module)


Grey Alien(Posted 2007) [#13]
The fix was only required for Windowed mode (it was already in Full-screen mode) and has been reimplemented, just Syncmods as Skidracer says.


ImaginaryHuman(Posted 2007) [#14]
I'll test the grabbing pixmap pixel to see if that fixes the lag on intel mac.