Subversion Repositories SvarDOS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
41 mv_fox 1
/*
190 mateuszvis 2
 * input keyboard routines used by the SvarDOS installer.
41 mv_fox 3
 * Copyright (C) 2016 Mateusz Viste
4
 */
5
 
6
#ifndef input_h_sentinel
7
#define input_h_sentinel
8
 
9
#include <dos.h>
10
#include "input.h" /* include self for control */
11
 
12
/* waits for a keypress and return it. Returns 0x1xx for extended keys */
13
int input_getkey(void) {
14
  union REGS regs;
15
  int res;
16
  regs.h.ah = 0x08;
17
  int86(0x21, &regs, &regs);
18
  res = regs.h.al;
19
  if (res == 0) { /* extended key - poll again */
20
    regs.h.ah = 0x08;
21
    int86(0x21, &regs, &regs);
22
    res = regs.h.al | 0x100;
23
  }
24
  return(res);
25
}
26
 
27
 
28
/* poll the keyboard, and return the next input key in buffer, or -1 if none */
29
int input_getkeyifany(void) {
30
  union REGS regs;
31
  regs.h.ah = 0x0B;
32
  int86(0x21, &regs, &regs);
33
  if (regs.h.al == 0xFF) return(input_getkey());
34
  return(-1);
35
}
36
 
37
#endif