While MouseDown(1) ,,,

BlitzMax Forums/BlitzMax Programming/While MouseDown(1) ,,,

SystemError51(Posted 2012) [#1]
I'm not sure this has been asked before, it may also just be me who is stupid.

For some reason, if I take a very simple program and I do

While MouseDown(1)
    Print "down"
WEnd


It'll work.

If however, I'm using that in OpenGL and I either put a mouse check call in a thread or main loop, the same thing will stop working after a short amount of time. It's seriously bizarre.

Ideas?


Example - above thing will work when used like this:

Repeat
    While MouseDown(1)
        Print "down " + Rnd(1,100000000)
    WEnd
    Flip
Until AppTerminate


Example - when used like this, it will work but cancel out after less than a second:

Global eventCheck : TThread
eventCheck = CreateThread(mouseCheck, "a")

Repeat
    ' Do some random drawing here
    Flip
Until AppTerminate

Function mouseCheck:Object(data:Object)
	Local doNotEnd = 1
	
	While doNotEnd = 1
		While MouseDown(1)
			Print "down " + Rnd(1,100000000)
		WEnd
	WEnd
EndFunction




// EDIT

When I just put the same thing in the main loop it does work -
but it is blocking the app.

Last edited 2012


matibee(Posted 2012) [#2]
Is it something to do with enabling polled input? Can't test right now.


col(Posted 2012) [#3]
Can you post a sample code that re-creates the issue ?


SystemError51(Posted 2012) [#4]
I just did.


col(Posted 2012) [#5]
I must have posted before you edited.

Worked flawlessy here.

Is it specific to the Print statement that its a problem for you??


SystemError51(Posted 2012) [#6]
Yeah... for some reason the numbers don't change anymore after about 1 second.


col(Posted 2012) [#7]
Could it be that the console buffer maybe lagging? Does it work if, after it stops, you release the mouse and then press the button again?

*edited for bad grammar :P

Last edited 2012


SystemError51(Posted 2012) [#8]
It works when I release the button, and press it again. However the same effect happens, that it stops in less than a second.

I will however try other approaches, such as outputting to a text file to see differences.


col(Posted 2012) [#9]
I changed the code slightly to increase an integer, and it does indeed stop after a short time, after releasing and pressing the mouse the integer value had increased even though the display didnt, so I guess its just the console buffer unable to keep up with the thread pumping so much into it.




SystemError51(Posted 2012) [#10]
Yeah so I got it to work in my code. Somewhere in a model click check function (that determines whether or not you clicked on a model in the world), I had a FlushMouse() call. Pretty lethal.

It's all working now :)


H&K(Posted 2012) [#11]
Possibly a wait somewhere in there might help?


Captain Wicker (crazy hillbilly)(Posted 2012) [#12]
i didn't think bmax used those old 'scancodes'...