File: key.c

package info (click to toggle)
vgagamespack 1.4-5
  • links: PTS
  • area: main
  • in suites: sarge, woody
  • size: 292 kB
  • ctags: 424
  • sloc: ansic: 3,826; makefile: 85
file content (42 lines) | stat: -rw-r--r-- 809 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * GamesPak
 *
 * Copyright (C) Evan Harris, 1994
 *
 * Permission is granted to freely redistribute and modify this code,
 * providing the author(s) get credit for having written it.
 */

#include <vga.h>
#include "key.h"

/*
 * We probably should use the svgalib keyboard_() functions, but the warnings
 * scared me.  8-)
 */

int
key_getkey()
{
    int key;

    if ((key = vga_getkey()) != 0x1b) {
	return key;		/* not ESC */
    }
    if ((key = vga_getkey()) != '[') {
	return 0x1b;		/* it was ESC */
    }
    switch (key = vga_getkey()) {
      case 'A':
	return KEY_CURSORUP;	/* up */
      case 'B':
	return KEY_CURSORDOWN;	/* down */
      case 'C':
	return KEY_CURSORRIGHT;	/* right */
      case 'D':
	return KEY_CURSORLEFT;	/* left */
      default:
	return -1;		/* ignore */
	break;
    }
}