Flushkeys also for the mouse?

BlitzMax Forums/BlitzMax Programming/Flushkeys also for the mouse?

taumel(Posted 2005) [#1]
Hello,

is it an intention that i have to use flushkeys() also for the mousebutton inputs?

If not than there is a bug.


Greetings,

taumel


Perturbatio(Posted 2005) [#2]
The mouse is detected as keyboard input as well (for the purposes of KeyDown and KeyHit), so I would imagine you would have to.


taumel(Posted 2005) [#3]
Puhhh if you're right this is pretty much uncomfortable!

What if i want to memorize button 1 but not button 2?
And if i want to keep it seperate from the keys?

How do i get this done for example:

- I want to check button 1 all the time.
- At a certain time i want to check button 2 and i'm not interested if this button has been hit before. And without interfering the input of button 1.


Greetings,

taumel


Perturbatio(Posted 2005) [#4]
do you mean like this?

Graphics 640,480,0

While Not KeyDown(KEY_ESCAPE)
Cls
If MouseDown(1) Then DrawText("mouse 1 is down",10,10)
If MouseDown(2) Then DrawText("mouse 2 is down",10,24)
Flip
Wend

End




Perturbatio(Posted 2005) [#5]
It might be good to have an optional parameter on Flushkeys, perhaps FlushAll, when if not specified, does not flush the first 3 (or however many the mouse uses) elements of the key_hit and key_down buffers.


taumel(Posted 2005) [#6]
I mean something like this:

Graphics 640,480,0,0

While Not MouseHit(1)
	Cls
	DrawText ("press the right mousebutton and then the left one",20,20)
	Flip
Wend
'FlushKeys()
While Not MouseHit(2)
	Cls
	DrawText ("press the right mousebutton",20,20)
	Flip
Wend


Without flushkeys() this will end like this:

- hitting mouse(2)
- hitting mouse(1) and you're out

and it should be, at least as i understand it,

- hitting mouse(1)
- hitting mouse(2) and you're out

Problem ist that in my gamescenario when i use flushkeys the input of mouse(1) is interfered...


Perturbatio(Posted 2005) [#7]
just created a function to allow you to flush a range from the buffer: http://www.blitzbasic.com/Community/posts.php?topic=47031
(requires you to edit the source and recompile the modules).


marksibly(Posted 2005) [#8]
Hmm...

What's the general feeling about treating mouse buttons as keys as widely as Max does?

This behaviour can always be modified.


taumel(Posted 2005) [#9]
Hello,

i think that the mousehit(x) should only be true if the mouse has been hit in the current loop. It's more practical.


Greetings,

taumel

PS: Due to the mousehit()/flushkeys() i do have the bug in kaboom that when you press the right button before you are finished with one level then it remembers the hit and jumps directly into the next level. When i tried using flushkeys() i couldn't retain the firefrequency any more.


Perturbatio(Posted 2005) [#10]

i think that the mousehit(x) should only be true if the mouse has been hit in the current loop. It's more practical.

that *could* cause problems for people, for instance if they want to count double clicks.

I think a flushmouse() command would be more sensible.


taumel(Posted 2005) [#11]
Hi,

that *could* cause problems for people, for instance if they want to count double clicks.

Why?

If the mouse is beeing hit then i check if it has already been hit by checking a given timer i start once the mouse has been pressed and it's not within a certain range.

Most of the time i do have normal clicks so i would prefer having this as simple as possible.

I think a flushmouse() command would be more sensible.

Hmmm i would prefer not to have flush the mouse at all. But this would be ok when it's not causing the same lags as written above.

Maybe some different commands? I've read that you don't like flash (hope it's not wrong) but they do have a pack of mousecommands which can save you some time.


Greetings,

taumel


marksibly(Posted 2005) [#12]
Moving this to programming as it's not strictly a bug - more just a debatable 'feature'.


Curtastic(Posted 2005) [#13]

What's the general feeling about treating mouse buttons as keys as widely as Max does?

This behaviour can always be modified.


coooool.

I don't know why it should flush the mouse also. when I say flush keys, just flush the keys.
I think bart did that on the simpsons whe he was like "byebye keees"


Tom Darby(Posted 2005) [#14]
I'd be happy with something along the lines of:

FlushInput(flushMouse:Int=true, flushKeys:Int=True)

Where FlushInput() would Flush All inputs, FlushInput(false) would flush keys only, and FlushInput(true, false) would flush mouse only.

Then again, I'd be happy with a Snickers bar, too. I'm easy to please.


Amon_old(Posted 2005) [#15]
Please seperate it in to 2. ie Flushmouse, Flushkeys.


taumel(Posted 2005) [#16]
Hello,

could anyone give me an example why it's good to flush the mouse at all?


Greetings,

taumel


Perturbatio(Posted 2005) [#17]
anytime you want to get a mouse button but aren't interested in previous mouseclicks.


taumel(Posted 2005) [#18]
Hmm maybe my question was misleading.

What's the benefit if i have to flush the mouse by myself instead when it's done automatically once per loop for example?


Greetings,

taumel


Perturbatio(Posted 2005) [#19]
if it's done automatically and you *are* interested in more than one mouse click, you're not going to be able to do what you want and we would have threads like: "I want a flushmouse() command", or "why does the mouse buffer get flushed automatically?"


taumel(Posted 2005) [#20]
So i would benefit from it for example if i have a situation where i run on a very low loopingrate because the code is too much for the cpu and i still want to react fast to a doubleclick of one mousebutton?!


Perturbatio(Posted 2005) [#21]
here's an example that demonstrates the issue, WASD + Left Mouse
comment out flushkeys to see what I mean.



taumel(Posted 2005) [#22]
Hi Pertubatio,

first many thanks for the effort you put into exlaining this to me! I did a lot of work in director and flash the last and this year and there it just runs fine without flushing any inputs.

I ran your example. I see the difference but i still don't understand it really. When i comment out the flushkeys than everything runs smooth and fine. When i let flushkeys go i do have it choppy.

a) But why runs it choppy when i use the flushkeys after i already tested for mouse/keys? The input is already done, it has been recognized, the apropriate actions were taken and so it should be not a problem to flush it (a queue or whatever it is where it's memorized)...what's happening there? And in the next loop there would be the next input... What is flushkeys exactly doing and when?

b) How do i then create a situation where i do have smooth graphics so NO flushkeys but where i also can ignore inputs from before which were done before i really want to check them?


Greetings,

taumel