key/mouse repeats too fast

Started by
11 comments, last by Nibbles 22 years, 9 months ago
hi, in my proggy, to get a mouse click i use:
  
GetAsyncKeyState(VK_LBUTTON);
  
however, it repeats too fast... for a keypress i the following and it works fine.
  
  if (g_keys->keyDown [AUX_S] == TRUE) {
      g_keys->keyDown [AUX_S] = FALSE;

      ...
  }
}
  
but i''m not sure how to get a mouse click not to repeat so quickly. Thanks, Scott Email Website
"If you try and don''t succeed, destroy all evidence that you tried."
Advertisement
I have this problem myself, it just hasn''t bugged me enough for me to do anything about it yet You could do something like only checking that keystate every 10th frame or something, or every 100ms or some other time length, but that seems a bit of a kludge, because you might completely miss keys that are quickly pressed then unpressed in that time.

Buffered input with DirectInput would be better, you wouldn''t loose keystrokes that are pressed then unpressed in that time. That''s the best way I know of, but somone else probably knows the correct way of doing it.

FatalXC
You could try something like this :

if (mousepressed && !reg_click)
{
//Do stuff
reg_click = TRUE;
}
if (!mousepressed)
{
reg_click = FALSE;
}


At least this would stop you from holding down
the mouse button!! Don''t know about really fast clicking!!
I never tried doing this, so i don''t know if it works...
But hey...it''s worth a shot!!

Take Care!


- -- ---[XaOs]--- -- -
- -- ---[XaOs]--- -- -[ Project fy ||| CyberTux ]
GetAsyncKeyState will not handle just clicks by itself. As the name suggests, it gets the current state of the button or key in question. So, unless you process the WM_LBUTTONDOWN message, you'll have to do the proper checks yourself: namely, when the mouse's state changes, let the state change register only once.

Edited by - merlin9x9 on June 27, 2001 9:19:05 PM
i use Xaos approach and never had troubles !

glHorizon_Project



www.web-discovery.net


hey,

XaOs, that work perfectly. It's for a map editor i'm working on and every mouse click is supposed to draw only one object (which it does now), but before as fast as i could click and release the mouse button to draw an object, i caught a good 5 states... which really sucked.

thank ya,
Scott

EDIT: spelt yer nick wrong

Email
Website

"If you try and don't succeed, destroy all evidence that you tried."

Edited by - wojtos on June 28, 2001 2:19:03 PM
heyh....nice to see i am actually helping someone here...


Glad to hear that it worked!! Sending over a shot so that i can see what you actually are working on?


BTW: Never mind the nick spelling...i had some real trouble spelling your name right in the beginning to....
(Remember my link to your site?)


Take Care!


- -- ---[XaOs]--- -- -
- -- ---[XaOs]--- -- -[ Project fy ||| CyberTux ]
I almost forgot....

Penetrator
If you''d like to see another game engine using a terrain engine,
take a look at my current project...(not only me though...)!!

We are using ROAM in a QuadTree for fast rendering with a high LOD!! Check it out.. http://brunomtc.no.sapo.pt (No source available though...)!!

Let me know what you think....if you allready haven''t looked at it!!


Take Care!

- -- ---[XaOs]--- -- -
- -- ---[XaOs]--- -- -[ Project fy ||| CyberTux ]
Xaos, unfortunately when i run the demo i get a GPF :-(

tomorrow i''ll try on another computer.

Perhaps it is because of the geforce3 ?


glHorizon_Project



www.web-discovery.net


hey,

same with me, whenever i try running that demo you have, i always get a memory/fatal error. whether i turn all the options off, or on.

Scott

p.s. my last name is Ukrainian, and yes, nobody seems to spell or pronouce it properly

Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."

This topic is closed to new replies.

Advertisement