File: input.c

package info (click to toggle)
koules 1.4-29
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,940 kB
  • sloc: ansic: 15,535; makefile: 779; asm: 379; tcl: 362; sh: 134
file content (72 lines) | stat: -rw-r--r-- 2,141 bytes parent folder | download | duplicates (13)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/***********************************************************
*                      K O U L E S                         *
*----------------------------------------------------------*
*  C1995 JAHUSOFT                                          *
*        Jan Hubicka                                       *
*        Dukelskych Bojovniku 1944                         *
*        390 03 Tabor                                      *
*        Czech Republic                                    *
*        Telefon: (048-I think) (0361) 32613               *
*        eMail: hubicka@limax.paru.cas.cz                  *
*----------------------------------------------------------*
* Copyright(c)1995 by Jan Hubicka.See README for license   *
*                          details.                        *
*----------------------------------------------------------*
*  input.c input functions for OS/2                        *
***********************************************************/
#include "koules.h"
#undef next

/* and something for the keyboard handling */
BYTE penter, pup, pdown, pp, pesc, pleft, pright;
ULONG mousex=0, mousey=0, mousebuttons=0;

struct keyrec *findkey(CONST int sc)
{
    struct keyrec  *kkey = firstkey;

    while (kkey != NULL && kkey->scancode != sc)
      kkey = kkey->next;
    return (kkey);
}

void addkey (CONST int scancode)
{
    struct keyrec  *key;

    if (!findkey (scancode))
      {
	  key = malloc (sizeof (struct keyrec));
	  key->last = NULL;
	  key->next = firstkey;
	  if (firstkey != NULL)
	    firstkey->last = key;
	  key->scancode = scancode;
	  firstkey = key;
      }
}

void deletekey (CONST int scancode)
{
    struct keyrec  *key;
    if (!(key = findkey (scancode)))
      {
	  printf ("Key not found!\n");
	  return;
      }
    if (key->last)
      key->last->next = key->next;
    else
      firstkey = key->next;
    if (key->next)
      key->next->last = key->last;
    free (key);
}

int GetKey()
{
    if (firstkey != NULL	/* && firstkey->next != NULL */ )
      return (firstkey->scancode);
    return (0);
}