MouseZ() Mouse Wheel not picking up small movement

BlitzMax Forums/BlitzMax Programming/MouseZ() Mouse Wheel not picking up small movement

Ian Martin(Posted 2014) [#1]
I'm having a weird problem with the MouseZ() command.

When I run this code in Blitz3D it works fine, every subtle small shift of the mouse wheel is counted:




But then if I run what is essentially the same code in BlitzMax:



...the mouse wheel number only changes if I spin the wheel a bit. I can turn the wheel just a tiny bit in BlitzMax, and as long as I move it really slow, the number never changes. In Blitz3D, every tiny movement is added up and it works perfectly.

I have a function I just added to my program that seems completely broken on BlitzMax, because you have to really spin the mouse wheel. It works, but only if you flick the wheel, and then it usually skips past what you want to select.

I saw some old posts about this sort of thing, and there was something about added MouseZSpeed(), which is pretty much just keeping track of the last position, and I'm already doing that. So I'm wondering if anyone else has found a solution to this problem or is having the same problem as me, or is there already a workaround that I didn't find searching the forums? Any help would be really appreciated :) I can always remove the feature, but I'm sure I'll run into this again if I make another game in BlitzMax...


xlsior(Posted 2014) [#2]
The two samples behave identical to me -- no matter how slowly I turn the scroll wheel, both slowly increment.

(Microsoft Wheelmouse Optical)


Chapman7(Posted 2014) [#3]
Those examples work the exact same for me. Everything from a quick flick to an extremely slow crawl - gets picked up in both tests.

Can you link to the older posts where people had a similar issue?


Derron(Posted 2014) [#4]
if you use "mouseZ" it is like a snapshot of this moment. It is not an "mouseZsinceLastRequest".


use something like this in your code

Global scrollWheelMoved:int  = 0
Global scrollWheelLastPosition:int = 0

'in your update loop (eg. "update()")
function update()
	'by default scroll wheel did not move
	scrollWheelMoved = 0

	if scrollWheelLastPosition <> MouseZ()
		scrollWheelMoved = scrollWheelLastPosition - MouseZ()
		scrollWheelLastPosition = MouseZ()
	endif

	'... your other code
end function


so after this code "scrollWheelMoved" contains a value:
< 0 means scrolled "up"
> 0 means scrolled "down"
= 0 means not scrolled

if you now comment out "scrollWheelMoved = 0", the last scroll direction will be kept (>0 or <0) until you manually reset "scrollWheelMoved" to 0 - eg. as soon as you handled it.



bye
Ron


Kryzon(Posted 2014) [#5]
The BlitzMax sample is working fine here.

If you want to directly act on each mouse wheel tick, you can do this:
Global myMouseZ:Int = 0

Function checkMouseZ:Object( id:Int, data:Object, context:Object )

	Local event:TEvent = TEvent( data )
	If Not event Then Return data
	
	Select event.id
	
		Case EVENT_MOUSEWHEEL
			myMouseZ :+ event.data

	End Select

	Return data

End Function

AddHook( EmitEventHook, checkMouseZ )

Graphics 640,480
While Not KeyHit(KEY_ESCAPE)
	Cls
	DrawText( "MouseZ()=" + myMouseZ, 0, 0 )
	Flip
Wend
Though this is just reproducing the functionality of PolledInput.mod, which does exactly the same.


Ian Martin(Posted 2014) [#6]
Thanks for testing it out for me everybody!
The other threads I had seen were just various ways people were adding the MouseZSpeed() functionality and there was something about doing it like Kryzon did in his code. I just searched again for it am not finding it, but I don't think any of the other posts were the same issue.

I've figured it out now, at least partially. Turns out it's my mouse. I ran the code that Kryzon posted (thanks!) and got the same results. I had thought maybe doing it this way would fix it, but it didn't. So I got one of my old mouses out and tried it. It worked fine in Kryzon's code, BlitzMax sample, and Blitz3D sample. The funny thing is, the mouse that doesn't work, which is a wireless Microsoft Explorer Mouse (Model 1362), works fine in Blitz3D. So BlitzMax must do something different in the way that it reads the mouse wheel. So I figured I'd post this and let everybody know about it. I guess if it's only happening with this one type of mouse I can just leave the code the way it is and make a note of it in my Known Issues file. I suppose the game will work right for everybody but me, heheh

Thanks to everybody that responded, I really appreciate the help getting to the bottom of this! :)