Re: WaitForSingleObjectEx() is broken



smile,

> Heh. You still haven't understood that a keypress generates at least two
> events, and that it's the *user* that isn't fast enough?

And you don't undersand what a keyboard repeat rate is.

This following code proved that WaitForSingleObjectEx() responds at the
keyboard repeat rate. Just press a key and watch it repeat at the
repeat rate.

OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

PollForKeyStroke proc keynum:DWORD

push esi
mov esi, rv(GetStdHandle,STD_INPUT_HANDLE)
@@:
invoke FlushConsoleInputBuffer,esi ; clear input buffer
invoke WaitForSingleObjectEx,
esi,INFINITE,0 ; wait for keystroke
print str$(eax),13,10
jmp @B

pop esi

ret

PollForKeyStroke endp

OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef

> Why Sleep() when you can block?

It does, it just happens to be ajustable as well and forces a yield.

============================
Whether they're for internal use and should be ignored is irrelevant
here,
they *are* inserted in the console message queue, they *will* trigger
WFSO,
and they *will* show up when you call ReadConsoleInput.
============================

Ah Microsoft, you are wrong again, f0dder has spoken.

> ...and you quietly ignored the MOUSE_EVENT :)

So does WaitForSingleObjectEx(). No mouse movement or button clicking
will trigger WaitForSingleObjectEx(). Try it while
WaitForSingleObjectEx() is waiting and nothing happens. :)

> Also notice that it does not poll _kbhit

Whoever said that it did ? I recommended checking on the code for
_getch instead of some of the crap you have posted.

Regards,

hutch at movsd dot com

.



Relevant Pages

  • Re: No, POLL and WAIT
    ... WaitForSingleObjectEx() by slowing it down as follows with the Sleep ... API. ... mov esi, rv ... invoke WaitForSingleObjectEx, ...
    (alt.lang.asm)
  • Re: No, POLL and WAIT
    ... WaitForSingleObjectEx() by slowing it down as follows with the SleepAPI. ... mov esi, rv ... invoke WaitForSingleObjectEx, ...
    (alt.lang.asm)
  • Re: WaitForSingleObjectEx() is broken
    ... this is not a problem with FlushConsoleInputBuffer... ... you will generate more events with KeyDown and RepeatCount. ... assumption is the repeat rate with the keyboard, ... mov esi, rv ...
    (alt.lang.asm)
  • Re: WaitForSingleObjectEx() is broken
    ... > And you don't undersand what a keyboard repeat rate is. ... > This following code proved that WaitForSingleObjectEx() responds at ... I'm not saying Microsoft is wrong. ...
    (alt.lang.asm)