Subversion Repositories SvarDOS

Rev

Rev 28 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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