strange getch+kbhit behaviour



In the following code something strange happens ! If I keep pressed any
of ALT+Arrow, keys, they are extracted two times from buffer then getch
seems to stop; if I release and press again ALT+arrow nothing changes:
the only way to exit from this condition is press another key a single
time.
What seems to happen is that kbhit say some keys are present in buffer
but for getch don't see any data and waits for a key. Why this happen ?
If I remove the delay all is working correctly. I've inserted a delay
to reproduce thi problem that I've found on another bigger project
where loop delay is 155ms.
Last thing: I've verified this problem only on newer motherboards !

Please help me !!
Thank you.
Simone


#include <stdio.h>
#include <dpmi.h>

int Handle()
{
int vv;

int lo, hi;

__dpmi_regs reg;

reg.x.ax = 0x10 << 8; /* shift 10h into AH */
__dpmi_int( 0x16, &reg);

vv= reg.x.ax ;
lo = vv & 0X00FF;
hi= ( vv & 0XFF00) >> 8;
vv=( ((lo == 0)|(lo == 224)) ? hi+256 : lo);

return vv;

} // Handle


int main(void)
{
int i;

do
{
i=0;
while(kbhit())
{
fprintf(stdout,"i=%d\n",i++);
fprintf(stdout,"%c\n",getch());
}

fprintf(stdout,"%d\n",Handle());
delay(155);

} while(1);
}
.



Relevant Pages

  • [TOOL] Keyfinder - Cryptographic Analyzing Tool
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... Keyfinder analyzes files for public/private keys, ... It identified such areas by measuring the entropy, ... int ext_entropy; ...
    (Securiteam)
  • Re: Forwarding key events while using XGrabKeyboard
    ... It hooks all keys so once its running you ... int iKeyState; ... iKeyTime = xev.xkey.time; ... XSelectInput(disp, tmp, KeyPressMask | KeyReleaseMask); ...
    (comp.windows.x)
  • Re: strrange getch+keybhit behaviour
    ... What seems to happen is that kbhit say some keys are present in buffer ... but for getch don't see any data and waits for a key. ... int Handle ... Undefined function. ...
    (comp.lang.c)
  • Re: strange getch+keybhit beheaviour
    ... In the following code something strange happens! ... of ALT+Arrow, keys, they are extracted two times from buffer then getch ...
    (comp.lang.c)
  • Solved: Re: What to use for conio?
    ... but is hopeless with function keys in X. ... int getkey; ... knum = getkey; ... knoc = read; ...
    (freebsd-questions)