File:  [OS/2 SDKs] / os2sdk / demos / examples / keys / keys.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:26:19 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: os2sdk-1988, HEAD
Microsoft OS/2 SDK 03-01-1988

/*
 * keys.c - Demonstrate the MS OS/2 call KbdCharIn
 *
 * This program runs in the forground.	Cooked keystrokes are printed
 * to the console.  Typing an ESC charactor terminates the program.
 *
 * This program can be bound to work under DOS 3.x (Family API).
 *
 * Created by Microsoft Corp. 1986
 */
#define IOWAIT 0
#define ESC '\033'
#define COOKED 0x04
#define RAW    0x08

#define INCL_SUB

#include <os2def.h>
#include <bsesub.h>
#include <stdio.h>
main ()
{
    KBDKEYINFO keydata;
    KBDINFO kbdstatus;

    kbdstatus.cb = sizeof(kbdstatus);
    KbdGetStatus(&kbdstatus, 0);
    kbdstatus.fsMask &= ~(RAW | COOKED);
    kbdstatus.fsMask |= COOKED;
    KbdSetStatus (&kbdstatus, 0);

    do {
	KbdCharIn(&keydata, IOWAIT, 0);
	printf("char: %02X  scan: %02X  status: %02X  shift: %04X\n",
	    keydata.chChar,
	    keydata.chScan,
	    keydata.fbStatus,
	    keydata.fsState);

    } while (keydata.chChar != ESC);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.