int vm_getch(void) { KBDKEYINFO ki; ki.chChar = 0; ki.chScan = 0; KbdCharIn(&ki, IO_WAIT, 0); if (ki.chChar == 0xe0) { if (ki.chScan) { ki.chChar = 0; /* force scan return */ } else { /* get next block */ ki.chChar = 0; KbdCharIn(&ki, IO_WAIT, 0); if (!ki.chScan) { /* still no scan? */ ki.chScan = ki.chChar; /* move new char over */ ki.chChar = 0; /* force its return */ } else { ki.chChar = 0; /* force new scan */ } } } if (ki.chScan == 0xe0) { if (!ki.chChar) { ki.chScan = 0; KbdCharIn(&ki, IO_WAIT, 0); if (!ki.chScan) { /* still no scan? */ ki.chScan = ki.chChar; /* move new char over */ ki.chChar = 0; /* force its return */ } else { ki.chChar = 0; /* force new scan */ } } else { ki.chScan = 0; /* handle 0xe00d case */ } } if (ki.chChar) { ki.chScan = 0; } return (int)((ki.chScan << 8) + (ki.chChar)); }
static char DOSgetch() { KBDKEYINFO CharData; USHORT IOWait = 0; HKBD KbdHandle = 0; KbdCharIn(&CharData, IOWait, KbdHandle); if (CharData.chChar == 0) { /* an extended code -- not yet supported */ KbdCharIn(&CharData, IOWait, KbdHandle); /* eat the next character */ CharData.chChar = 0; /* and return a 0 */ } return (CharData.chChar); }
_WCRTLINK int getch( void ) { int c; APIRET rc; KBDKEYINFO info; if( (c = _RWD_cbyte) != 0 ) { _RWD_cbyte = 0; return( c ); } #ifdef DEFAULT_WINDOWING if( _WindowsGetch != NULL ) { // Default windowing LPWDATA res; res = _WindowsIsWindowedHandle( (int)STDIN_FILENO ); return( _WindowsGetch( res ) ); } #endif #if defined(__OS2_286__) if( _RWD_osmode == DOS_MODE ) { return( _dos( DOS_GET_CHAR_NO_ECHO_CHECK ) ); } #endif if( (c = _RWD_cbyte2) != 0 ) { _RWD_cbyte2 = 0; return( c ); } rc = KbdCharIn( &info, 0, 0 ); if( rc == ERROR_KBD_DETACHED ) return( EOF ); if( info.chChar == 0 || info.chChar == 0xe0 ) { _RWD_cbyte2 = info.chScan; } return( info.chChar ); }
static char BIOSgetch() { unsigned char scan, shift, ch; const struct pad *kpad; KBDKEYINFO CharData; USHORT IOWait = 0; HKBD KbdHandle = 0; KbdCharIn(&CharData, IOWait, KbdHandle); ch = CharData.chChar; scan = CharData.chScan; shift = CharData.fsState; /* Translate keypad keys */ if (iskeypad(scan)) { kpad = iflags.num_pad ? numpad : keypad; if (shift & SHIFT_KEY) ch = kpad[scan - KEYPADLO].shift; else if (shift & CTRL_KEY) ch = kpad[scan - KEYPADLO].cntrl; else ch = kpad[scan - KEYPADLO].normal; } /* Translate unassigned Alt-letters */ if ((shift & ALT_KEY) && !ch) { if (inmap(scan)) ch = scanmap[scan - SCANLO]; return (isprint(ch) ? M(ch) : ch); } return ch; }
void TEventQueue::keyboardThread( void * arg ) { arg = arg; KBDKEYINFO *info = &TThreads::tiled->keyboardInfo; while (1) { jsSuspendThread USHORT errCode = KbdCharIn( info, IO_NOWAIT, 0 ); jsSuspendThread if ( errCode || (info->fbStatus & 0xC0)!=0x40 || info->fbStatus & 1) { // no char keyboardEvent.what = evNothing; DosSleep(keyboardPollingDelay); if (keyboardPollingDelay < 500) keyboardPollingDelay += 5; } else { keyboardEvent.what = evKeyDown; if ((info->fbStatus & 2) && (info->chChar==0xE0)) info->chChar=0; // OS/2 cursor keys. keyboardEvent.keyDown.charScan.charCode=info->chChar; keyboardEvent.keyDown.charScan.scanCode=info->chScan; shiftState = info->fsState & 0xFF; jsSuspendThread assert(! DosPostEventSem(TThreads::hevKeyboard1) ); jsSuspendThread assert(! DosWaitEventSem(TThreads::hevKeyboard2, SEM_INDEFINITE_WAIT) ); keyboardEvent.what = evNothing; ULONG dummy; jsSuspendThread assert(! DosResetEventSem(TThreads::hevKeyboard2, &dummy) ); keyboardPollingDelay=0; } } TThreads::deadEnd(); }
/* ---------------------------------------------------- */ void readln(char *st,int maxnum, int echo) { char ch; int pos; KBDKEYINFO kbci; pos=0; do { KbdCharIn(&kbci, IO_WAIT, 0); ch=kbci.chChar; if ((ch < 128) && (ch >= 8)) { switch (ch) { case 8 : if (pos>0) { pos--; printf("%c %c",ch,ch); break; } case 13 : st [pos]=0; break; case 3 : case 27 : st[0]=0; exit(1); default : if (pos < maxnum) { st[pos++]=ch; if (echo) putchar(ch); else putchar('*'); } } } } while (ch != 13); printf("\n"); }
static void thread_getkey () { KBDKEYINFO keyInfo; int n; while (!atEnd) { /* at end is a flag */ set_kbd(); KbdCharIn(&keyInfo, IO_NOWAIT, 0); /* get a character */ if (keyInfo.fbStatus & 0x040) { /* found a char process it */ if (keyInfo.chChar == SLang_Abort_Char) { if (SLang_Ignore_User_Abort == 0) SLang_set_error (SL_USER_BREAK); SLKeyBoard_Quit = 1; } n = (endBuf + 1) % BUFFER_LEN; if (n == startBuf) { DosBeep (500, 20); KbdFlushBuffer(0); continue; } RequestSem(); threadKeys [n].ascii = keyInfo.chChar; threadKeys [n].scan = keyInfo.chScan; /* threadKeys [n].shift = keyInfo.fsState; */ endBuf = n; ReleaseSem(); } else /* no char available*/ DosSleep (20); } }
static int os2_getchar(aa_context * c, int wait) { KBDKEYINFO kbdkey; MOUEVENTINFO mouEvent; USHORT mouwait = MOU_NOWAIT; if(wait) { while(1) { KbdCharIn(&kbdkey, IO_NOWAIT, 0); if(kbdkey.fbStatus!=0) return check_keys(kbdkey); if(hMou!=-1) { MouReadEventQue(&mouEvent, &mouwait, hMou); /* mouse event! */ if(!((mouEvent.fs==0)&&(mouEvent.col==0)&&(mouEvent.row==0))) { if(mouEvent.fs&0x60) but |= AA_BUTTON2; else but &= ~AA_BUTTON2; if((mouEvent.fs&0x18)||(mouEvent.fs&0x60 && mouEvent.fs&0x06)) but |= AA_BUTTON3; else but &= ~AA_BUTTON3; if(mouEvent.fs&0x06) but |= AA_BUTTON1; else but &= ~AA_BUTTON1; if(mouEvent.fs&0x01) but = 0; return AA_NONE; } } DosSleep(0); } } else { KbdCharIn(&kbdkey, IO_NOWAIT, 0); if(kbdkey.fbStatus==0) return AA_NONE; else return check_keys(kbdkey); } return (AA_NONE); }
void EndPopUp() { if (DebugFlag & DB_ECHO_LINE) return; if (OS2MODE) { VioWrtTTY(pszPressAny, strlen(pszPressAny), 0); KbdCharIn(&kbci, IO_WAIT, hkbd); VioEndPopUp(0); } }
int ext_getch(void) { int key; #ifdef __OS2__ extern KBDKEYINFO ki; /* defined in ISSHIFT.C */ KBDINFO kb_state; kb_state = setkbmode(); /* Change keyboard to binary mode */ KbdCharIn(&ki, IO_WAIT, 0); /* Get the key */ restkbmode(kb_state); /* restore previous keyboard mode */ key = (ki.chScan << 8) + ki.chChar; /* format it into an int */ #else /* assume DOS */ union REGS regs; #if USING_DOS regs.h.ah = 7; intdos(®s, ®s); key = regs.h.al; if (0 == key) { regs.h.ah = 7; intdos(®s, ®s); key = (regs.h.al << 8); } #else regs.h.ah = 0x10; int86(0x16, ®s, ®s); key = regs.x.ax; #endif switch (LoByte(key)) { case 0: key = HiByte(key) + 256; break; case 0xe0: key = HiByte(key) + 512; break; default: if (0xe0 == HiByte(key)) key = LoByte(key) + 512; else { if (ispunct(LoByte(key)) && HiByte(key) > 0x36) key = LoByte(key) + 512; else key = LoByte(key); } } #endif return key; }
int read_key( void ) { KBDKEYINFO Char; KbdCharIn(&Char, IO_NOWAIT, 0); if( Char.fbStatus ) return Char.chChar; return 0; }
void os2KbdBitBucketThread(void* arg) { KBDKEYINFO key; while (1) { if (xf86Info.consoleFd != -1) { KbdCharIn(&key,1,xf86Info.consoleFd); usleep(100000); } else usleep(500000); } }
int get_ch (clock_t timer) { KBDKEYINFO kbd; USHORT wait = IO_WAIT; clock_t t; int key = 0; if(timer != (clock_t)-1) { /* we're on a timer */ wait = IO_NOWAIT; t = clock() + ((timer * CLOCKS_PER_SEC) / 1000); do { if(!KbdCharIn(&kbd,wait,0)) { if(kbd.fbStatus & 0x40) { if(kbd.chChar == 0 || kbd.chChar == 0xe0) key = kbd.chScan | 256; else key = kbd.chChar; break; } else if(kbd.fbStatus & 0x01) return 256; } DosSleep(33L); /* snooze a bit... */ } while(t > clock()); } else { /* we're NOT on a timer */ while(!KbdCharIn(&kbd,wait,0)) { if(kbd.fbStatus & 0x40) { if(kbd.chChar == 0 || kbd.chChar == 0xe0) key = kbd.chScan | 256; else key = kbd.chChar; break; } else if(kbd.fbStatus & 0x01) return 256; } } return key; }
void Kbd_Wait() { char str[80]; beg: KbdCharIn(&KeyInput,0,hkbd); if(KeyInput.chChar >= 32) sprintf(str,"KeyInput:fbStatus (%x) chScan (%x) chChar (%c=%x)", KeyInput.fbStatus, KeyInput.chScan,KeyInput.chChar,KeyInput.chChar); else sprintf(str,"KeyInput:fbStatus (%x) chScan (%x) chChar (%x)", KeyInput.fbStatus, KeyInput.chScan,KeyInput.chChar); LOG_EVENT( str ) // if (HELP_SYSTEM && Kbd_GetCode() == F1 && Kbd_GetType()==KBD_CNTRL) { Run_Help(); goto beg; } if (Kbd_Chain_of_FLT) FLT_RunChain(); }
/* This function does what ttyread() does with the termcap interface */ static int vio_read (char *buf, int len, int timeout) { KBDKEYINFO ki; /* Fast 'n' sleazy keyboard processing. */ KbdCharIn(&ki, IO_WAIT, 0); if ((ki.fbStatus & 0x02) != 0) { /* * Convert an extended scan code to ^K, followed by four * hex digits. This scheme is borrowed from the X11 GUI. */ sprintf (buf, "%c%02x%02x", ELVCTRL ('K'), ki.chChar, ki.chScan); return strlen (buf); } else { buf[0] = ki.chChar; return 1; } }
/* * inchar() - get a character from the keyboard. * * Timeout not implemented yet for OS/2. */ int inchar(long mstimeout) { for (;;) { KBDKEYINFO k; bool_t mstatus, psvstatus; flush_output(); mstatus = (usemouse && State == NORMAL); psvstatus = (keystrokes >= PSVKEYS); /* * We don't have to give control to any other thread * if neither of these conditions is true. */ if (mstatus || psvstatus) { #ifndef NOMOUSE if (mstatus) showmouse(); #endif if (psvstatus && DosSemWait(psvsema, SEM_IMMEDIATE_RETURN) == ERROR_SEM_TIMEOUT) { /* * If psvsema is set, clear it. */ DosSemClear(psvsema); } DosSemClear(control); } /* * Start of non-critical section. * * Wait for character from keyboard. */ KbdCharIn((PKBDKEYINFO) &k, IO_WAIT, 0); /* * End of non-critical section. */ if (mstatus || psvstatus) { DosSemRequest(control, SEM_INDEFINITE_WAIT); #ifndef NOMOUSE if (mstatus) hidemouse(); #endif } if (++keystrokes >= PSVKEYS) lastevent = clock(); /* * Now deal with the keypress information. */ if ((unsigned char) k.chChar == (unsigned char) 0xe0) { /* * It's (probably) a function key. */ if (k.chScan == 0x53) /* * It's the delete key. */ return State == NORMAL ? 'x' : '\b'; /* else */ if (State == NORMAL) { /* * Assume it must be a function key. */ switch (k.chScan) { case 0x3b: return(K_HELP); /* F1 key */ case 0x47: return(K_HOME); /* home key */ case 0x48: return(K_UARROW); /* up arrow key */ case 0x49: return(K_PGUP); /* page up key */ case 0x4b: return(K_LARROW); /* left arrow key */ case 0x4d: return(K_RARROW); /* right arrow key */ case 0x4f: return(K_END); /* end key */ case 0x50: return(K_DARROW); /* down arrow key */ case 0x51: return(K_PGDOWN)); /* page down key */ case 0x52: return(K_INSERT); /* insert key */ default: /* just ignore it ... */ continue; } /* * If we aren't in command mode, 0xe0 * is a perfectly legitimate * character, & we can't really tell * whether or not it's supposed to be * a function key, so we just have to * return it as is. */ } } return (unsigned char) k.chChar; } }
/* * Check for events -- called by "Term_scan_emx()" * * Note -- this is probably NOT the most efficient way * to "wait" for a keypress (TERM_XTRA_EVENT). * * * This code was ripped from "main-ibm.c" -- consult it to * figure out what's going on. * * See "main-ibm.c" for more information about "macro encoding". * * * The following documentation was cut&pasted from * the OS/2 Programming Reference, PRCP.INF * <ftp://hobbes.nmsu.edu/pub/os2/dev/16-bit/inf16bit.zip> ------------------------------------------------------------------------------- This call returns a character data record from the keyboard. KbdCharIn (CharData, IOWait, KbdHandle) CharData (PKBDKEYINFO) - output Address of the character data structure: asciicharcode (UCHAR) ASCII character code. The scan code received from the keyboard is translated to the ASCII character code. scancode (UCHAR) Code received from the keyboard. The scan code received from the keyboard is translated to the ASCII character code. status (UCHAR) State of the keystroke event: Bit Description 7-6 00 = Undefined 01 = Final character, interim character flag off 10 = Interim character 11 = Final character, interim character flag on. 5 1 = Immediate conversion requested. 4-2 Reserved. 1 0 = Scan code is a character. 1 = Scan code is not a character; is an extended key code from the keyboard. 0 1 = Shift status returned without character. reserved (UCHAR) NLS shift status. Reserved, set to zero. shiftkeystat (USHORT) Shift key status. Bit Description 15 SysReq key down 14 CapsLock key down 13 NumLock key down 12 ScrollLock key down 11 Right Alt key down 10 Right Ctrl key down 9 Left Alt key down 8 Left Ctrl key down 7 Insert on 6 CapsLock on 5 NumLock on 4 ScrollLock on 3 Either Alt key down 2 Either Ctrl key down 1 Left Shift key down 0 Right Shift key down time (ULONG) Time stamp indicating when a key was pressed. It is specified in milliseconds from the time the system was started. IOWait (USHORT) - input Wait if a character is not available. Value Definition 0 Requestor waits for a character if one is not available. 1 Requestor gets an immediate return if no character is available. KbdHandle (HKBD) - input Default keyboard or the logical keyboard. rc (USHORT) - return Return code descriptions are: 0 NO_ERROR 375 ERROR_KBD_INVALID_IOWAIT 439 ERROR_KBD_INVALID_HANDLE 445 ERROR_KBD_FOCUS_REQUIRED 447 ERROR_KBD_KEYBOARD_BUSY 464 ERROR_KBD_DETACHED 504 ERROR_KBD_EXTENDED_SG Remarks On an enhanced keyboard, the secondary enter key returns the normal character 0DH and a scan code of E0H. Double-byte character codes (DBCS) require two function calls to obtain the entire code. If shift report is set with KbdSetStatus, the CharData record returned reflects changed shift information only. Extended ASCII codes are identified with the status byte, bit 1 on and the ASCII character code being either 00H or E0H. Both conditions must be satisfied for the character to be an extended keystroke. For extended ASCII codes, the scan code byte returned is the second code (extended code). Usually the extended ASCII code is the scan code of the primary key that was pressed. A thread in the foreground session that repeatedly polls the keyboard with KbdCharIn (with no wait), can prevent all regular priority class threads from executing. If polling must be used and a minimal amount of other processing is being performed, the thread should periodically yield to the CPU by issuing a DosSleep call for an interval of at least 5 milliseconds. Family API Considerations Some options operate differently in the DOS mode than in the OS /2 mode. Therefore, the following restrictions apply to KbdCharIn when coding in the DOS mode: o The CharData structure includes everything except the time stamp. o Interim character is not supported o Status can be 0 or 40H o KbdHandle is ignored. ------------------------------------------------------------------------------- typedef struct _KBDKEYINFO { / * kbci * / UCHAR chChar; / * ASCII character code * / UCHAR chScan; / * Scan Code * / UCHAR fbStatus; / * State of the character * / UCHAR bNlsShift; / * Reserved (set to zero) * / USHORT fsState; / * State of the shift keys * / ULONG time; / * Time stamp of keystroke (ms since ipl) * / }KBDKEYINFO; #define INCL_KBD USHORT rc = KbdCharIn(CharData, IOWait, KbdHandle); PKBDKEYINFO CharData; / * Buffer for data * / USHORT IOWait; / * Indicate if wait * / HKBD KbdHandle; / * Keyboard handle * / USHORT rc; / * return code * / ------------------------------------------------------------------------------- * */ static errr CheckEvents(int returnImmediately) { int i, k, s; bool mc = FALSE; bool ms = FALSE; bool ma = FALSE; /* start OS/2 specific section */ struct _KBDKEYINFO keyinfo; /* see structure description above */ /* Check (and possibly wait) for a keypress */ /* see function description above */ KbdCharIn( &keyinfo, returnImmediately, (HKBD)0 ); #if 0 printf("AC:%x SC:%x ST:%x R1:%x SH:%x TI:%ld\n", /* OS/2 debug */ keyinfo.chChar, keyinfo.chScan, keyinfo.fbStatus, keyinfo.bNlsShift, keyinfo.fsState, keyinfo.time ); #endif /* If there wasn't a key, leave now. */ if ((keyinfo.fbStatus & 0xC0) == 0) return(1); /* by a set of lucky coincidences, the data maps directly over. */ k = keyinfo.chChar; s = keyinfo.chScan; i = (keyinfo.fsState & 0xFF); /* end OS/2 specific section */ /* Process "normal" keys */ if ( k != 0 && ((s <= 58) || (s == 0xE0)) ) /* Tweak: allow for ALT-keys */ { /* Enqueue it */ Term_keypress(k); /* Success */ return (0); } /* Extract the modifier flags */ if (i & (1 << K_CTRL)) mc = TRUE; if (i & (1 << K_LSHIFT)) ms = TRUE; if (i & (1 << K_RSHIFT)) ms = TRUE; if (i & (1 << K_ALT)) ma = TRUE; /* Begin a "macro trigger" */ Term_keypress(31); /* Hack -- Send the modifiers */ if (mc) Term_keypress('C'); if (ms) Term_keypress('S'); if (ma) Term_keypress('A'); /* Introduce the hexidecimal scan code */ Term_keypress('x'); /* Encode the hexidecimal scan code */ Term_keypress(hexsym[s/16]); Term_keypress(hexsym[s%16]); /* End the "macro trigger" */ Term_keypress(13); /* Success */ return (0); }
int ReadKbdEvent(TEvent *Event, int Wait) { KBDKEYINFO ki; UCHAR CharCode, ScanCode; ULONG KeyCode, KeyFlags; USHORT CharScan, Flags; static USHORT PrevFlags = 0; unsigned int I; Event->What = evNone; KbdCharIn(&ki, IO_NOWAIT, 0); if (!(ki.fbStatus & 0x40)) return 0; Event->What = evKeyDown; CharCode = ki.chChar; ScanCode = ki.chScan; CharScan = (USHORT)((((USHORT)ScanCode) << 8) | ((USHORT)CharCode)); Flags = ki.fsState; KeyCode = 0; KeyFlags = 0; /* printf("Key: %X %X %X %X %X \n", (unsigned long) ki.bNlsShift, (unsigned long) ki.fbStatus, (unsigned long) Flags, (unsigned long) CharCode, (unsigned long) ScanCode);*/ if ((Flags & (LEFTSHIFT | RIGHTSHIFT)) != 0) KeyFlags |= kfShift; if ((Flags & (LEFTCONTROL | RIGHTCONTROL)) != 0) KeyFlags |= kfCtrl; /* cpCount = sizeof(cpList);*/ /* rc = DosQueryCp(sizeof(cpList), cpList, &cpCount); // get active code page*/ if (CharCode != 0) { if ((Flags & (LEFTALT)) != 0) KeyFlags |= kfAlt; } else { if ((Flags & (LEFTALT | RIGHTALT)) != 0) KeyFlags |= kfAlt; } /* if (rc != 0) printf("rc = %d\n", rc);*/ if (CharScan == 0) { /* shift/alt/ctrl/caps/scroll/num */ } else if (ScanCode == 0) { /* alt numeric */ KeyCode = CharCode; KeyFlags |= kfAltXXX; } else { /* now check special combinations */ for (I = 0; I < sizeof(TransCharScan) / sizeof(TransCharScan[0]); I++) if (TransCharScan[I].CharScan == CharScan) { KeyCode = TransCharScan[I].KeyCode; break; } if (KeyCode == 0) { if ((CharCode == 0) || (CharCode == 0xE0)) { if (CharCode == 0xE0) KeyFlags |= kfGray; for (I = 0; I < sizeof(TransScan) / sizeof(TransScan[0]); I++) if (TransScan[I].ScanCode == ScanCode) { KeyCode = TransScan[I].KeyCode; break; } } else { if (CharCode < 32) if (KeyFlags & kfCtrl) CharCode += 64; KeyCode = CharCode; } } } Event->Key.Code = KeyCode | KeyFlags; PrevFlags = Flags; return 1; }
/* ** void main(int argc, CHAR * argv[]) */ void main(int argc, CHAR * argv[]) { unsigned us; CHAR * pch; int cch; int i; #ifdef OS2SU KBDKEYINFO kb; #endif /* OS2SU */ vcolorCurFore = colorWhite; vcolorCurBack = colorBlue; vcolorScrFore = colorWhite; vcolorScrBack = colorBlue; vcolorEditFore = colorRed; vcolorEditBack = colorWhite; vcolorListboxFore = colorWhite; vcolorListboxBack = colorBlue; vcolorLbMoreFore = colorRed; vcolorLbMoreBack = colorWhite; vcolorErrorFore = colorWhite; vcolorErrorBack = colorRed; /* parse command line args */ for (i = 1; i < argc; i++) { if (argv[i][0] == '/' || argv[i][0] == '-') { switch (argv[i][1]) { default: case '?': Usage(); break; case 'c': case 'C': fMonoDisplay = TRUE; break; } } } if (!fMonoDisplay && !FDetectAndSetMonoDisplay()) { /* detection not sure if color or mono -- set to mono by routine ** we could ask the user here and reset to color, or just run */ } for (us = 0; (rgchSourcePath[us] = *(_pgmptr + us)) != '\0'; us++) ; if (rgchSourcePath[1] != ':' || rgchSourcePath[2] != '\\') { _getcwd(rgchSourcePath, PATHMAX - 1); if (rgchSourcePath[strlen(rgchSourcePath) - 1] != '\\') strcat(rgchSourcePath, "\\"); } else { pch = strrchr(rgchSourcePath, '\\'); *(pch + 1) = '\0'; /* strip off SETUP.EXE */ _strupr(rgchSourcePath); } /* Replace INT24 disk-error handler. Restore with CloseDisks at ** termination of program via ExitPgm(). */ OpenDisks(); QueryDisks(&vdskFloppy, &vdskHard, FALSE); /* steal CTRL+C interrupt */ signal(SIGINT, SIG_IGN); ScrClear(); /* switch to source directory to read INF file */ cch = strlen(rgchSourcePath); if (cch > 3) /* remove trailing backslash except for root case */ rgchSourcePath[cch - 1] = '\0'; #ifdef OS2SU DosSelectDisk(*rgchSourcePath - 'A' + 1); #else /* !OS2SU */ _dos_setdrive(*rgchSourcePath - 'A' + 1, &us); #endif /* !OS2SU */ _chdir(rgchSourcePath + 2); rgchSourcePath[cch - 1] = '\\'; /* read SETUP.INF */ if (!FOpenInfo(SetupInf, CLIST, CMACRO, CMENU, CSCREEN)) FatalError(smInfOpenErr, 8); GetInfo(); CloseInfo(); Install(); /* switch to destination directory to exit */ cch = strlen(rgchDestPath); if (cch > 3) /* remove trailing backslash except for root case */ rgchDestPath[cch - 1] = '\0'; #ifdef OS2SU DosSelectDisk(*rgchDestPath - 'A' + 1); KbdCharIn(&kb, IO_WAIT, 0); /* ensure current message gets read */ #else /* !OS2SU */ _dos_setdrive(*rgchDestPath - 'A' + 1, &us); #endif /* !OS2SU */ _chdir(rgchDestPath + 2); ExitPgm(); } /* main */
/* -------------------------------------------------------------------------- Return details about the last pressed key as an ULONG value. - Parameters ------------------------------------------------------------- VOID - Return value ----------------------------------------------------------- ULONG : selected data from the KBDKEYINFO data structure. -------------------------------------------------------------------------- */ ULONG kbdKey(VOID) { KBDKEYINFO kki; if (KbdCharIn(&kki, 0, 0)) return 0; return kki.chChar | (kki.chScan<<8) | (kki.fbStatus<<16) | (kki.fsState<<24); }
int vm_getch(void) { if (_osmode == DOS_MODE) { unsigned char chChar, chScan; while (!vm_kbhit()) { /* nada */ } vm_getkey(&chScan, &chChar); if (chChar == 0xe0) { if (chScan) { chChar = 0; /* force scan return */ } else { /* get next block */ chChar = 0; vm_getkey(&chScan, &chChar); if (!chScan) { /* still no scan? */ chScan = chChar; /* move new char over */ chChar = 0; /* force its return */ } else { chChar = 0; /* force new scan */ } } } if (chScan == 0xe0) { if (!chChar) { chScan = 0; vm_getkey(&chScan, &chChar); if (!chScan) { /* still no scan? */ chScan = chChar; /* move new char over */ chChar = 0; /* force its return */ } else { chChar = 0; /* force new scan */ } } else { chScan = 0; /* handle 0xe00d case */ } } if (chChar) { chScan = 0; } return (int)((chScan << 8) + (chChar)); } else { KBDKEYINFO ki; ki.chChar = 0; ki.chScan = 0; KbdCharIn(&ki, IO_WAIT, 0); if (ki.chChar == 0xe0) { if (ki.chScan) { ki.chChar = 0; /* force scan return */ } else { /* get next block */ ki.chChar = 0; KbdCharIn(&ki, IO_WAIT, 0); if (!ki.chScan) { /* still no scan? */ ki.chScan = ki.chChar; /* move new char over */ ki.chChar = 0; /* force its return */ } else { ki.chChar = 0; /* force new scan */ } } } if (ki.chScan == 0xe0) { if (!ki.chChar) { ki.chScan = 0; KbdCharIn(&ki, IO_WAIT, 0); if (!ki.chScan) { /* still no scan? */ ki.chScan = ki.chChar; /* move new char over */ ki.chChar = 0; /* force its return */ } else { ki.chChar = 0; /* force new scan */ } } else { ki.chScan = 0; /* handle 0xe00d case */ } } if (ki.chChar) { ki.chScan = 0; } return (int)((ki.chScan << 8) + (ki.chChar)); } }
USHORT __pascal KBDCHARIN(KBDKEYINFO * pkbci, const USHORT fWait, const HKBD hkbd) { return KbdCharIn(pkbci, fWait, hkbd); }