473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

strange getch+keybhit beheaviour

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);
}
Sep 21 '06 #1
1 1829
simnav wrote:
>
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
There is no point to posting the same query three times in two
minutes. Allow at least a day for replies to appear. But don't
count on them.

--
Some informative links:
news:news.announce.newusers
http://www.geocities.com/nnqweb/
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html

--
Posted via a free Usenet account from http://www.teranews.com

Sep 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: simnav | last post by:
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...
0
by: simnav | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.