Article View: comp.os.os2.programmer
Article #2335Re: Fix/workaround for Watcom C kbhit bug??
From: Fred Walter
Date: Tue, 06 Oct 1992 22:45
Date: Tue, 06 Oct 1992 22:45
47 lines
1670 bytes
1670 bytes
sthiagar@bronze.ucs.indiana.edu (sivasailam thiagarajan) writes:
>Help! I'm using the Watcom C 386 9.0 compiler and need a fix or
>workaround for the kbhit() bug.
Someone suggested that I use KBDTRF_FINAL_CHAR_IN instead of 0x40, but I know
the following works for me (and I haven't tried his suggestion yet).
---cut here and say thank you---
/*
* kbhit()
*
* Implimention of the above library call.
*
* Replaces the broken implimentation of kbhit() found in the Watcom C/386 9.0
* libraries.
*
* Copyright July 1992 by G. R. (Fred) Walter
*/
#include <stdio.h>
#include <stdlib.h>
#define INCL_KBD
#include <os2.h>
static KBDKEYINFO *_kbhit_keyinfo = NULL;
int
kbhit()
{
if (_kbhit_keyinfo == NULL) {
_kbhit_keyinfo = (KBDKEYINFO *)malloc(sizeof(KBDKEYINFO));
if (_kbhit_keyinfo == NULL) {
fprintf(stderr, "Out of memory error\n");
exit(1);
}
}
if (KbdPeek(_kbhit_keyinfo, 0) != 0)
return (0);
if (_kbhit_keyinfo->fbStatus & 0x40)
return (1);
else
return (0);
}
--
Disclaimer: everything I write is my *personal* opinion and does not represent
or reflect the opinion of the company which employs me.
Technical Details
Message-ID:
<1992Oct6.224517.8823@mks.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!darwin.sura.net!wupost!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watserv1!mks.com!fredwReferences:
<BvpD1y.AE@usenet.ucs.indiana.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!darwin.sura.net!wupost!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watserv1!mks.com!fredw From: fredw@mks.com (Fred Walter) Subject: Re: Fix/workaround for Watcom C kbhit bug?? Message-ID: <1992Oct6.224517.8823@mks.com> Organization: Mortice Kern Systems Inc., Waterloo, Ontario, CANADA References: <BvpD1y.AE@usenet.ucs.indiana.edu> Distribution: na Date: Tue, 6 Oct 1992 22:45:17 GMT Lines: 47