MouseZSpeed stuff and window losing focus

Blitz3D Forums/Blitz3D Programming/MouseZSpeed stuff and window losing focus

Picklesworth(Posted 2005) [#1]
I'm sure that many people here have noticed this problem.
Whenever the Blitz Runtime Window loses focus, MouseZ() resets to 0, causing MouseZSpeed() to mess up. In programs where rolling the mouse wheel causes the camera to zoom, for example, this is a problem because it means that it will reset the camera's zoom.
Does anyone know how to fix this problem?


John Blackledge(Posted 2005) [#2]
I'm not sure if we're discussing quite the same problem, but I can tell you that I have to FlushMouse quite often, since MouseZspeed will still be incrementing even when the mouse is outside my window. So as often as I can (screen changes, view mode changes) I do this:
;---------------------------------
Function zFlushMouse()
;---------------------------------
Local mzs#
	FlushMouse
	Repeat
		mzs# = MouseZSpeed()
	Until mzs# =0
End Function



Rhyolite(Posted 2005) [#3]
The other method is to reset the mouse coordinates to centre of screen.

Rhy :)


Picklesworth(Posted 2005) [#4]
Not working for me :(
I just came up with a silly but perhaps possible solution though. It needs a lot of that crazy windows stuff that I'm obsessed with.
The camera only zooms if a mouseZ message has been sent to the main window, but MouseZSpeed is checked every frame.


(Off topic: My program now has three ways to zoom the camera in and out)


John Pickford(Posted 2005) [#5]
I have this problem. Lose focus and my game camera zooms right in to the max.

Has anyone solved it? All I can think of at the moment is to detect big sudden jumps in the mouseZ and recalibrate.

Is there a way to detect loss of focus? That would be ideal.


John Blackledge(Posted 2005) [#6]
I use BlitzSys to get my window handle, then constantly check:
If hWnd <> GetActiveWindow() ; User32.decls I think.


Picklesworth(Posted 2005) [#7]
Even detecting loss of focus hasn't worked perfectly for me though. Perhaps its my own fault with that, but I don't think it is :(


Damien Sturdy(Posted 2005) [#8]
On Loss_of_focus, set a flag.

on gain_of_focus, check that flag and immediately check MouseZspeed() if its set. This results in the single erraneous value being used up by the check you threw in. then, reset the flag.