Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
105 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/**
22
 ------------
23
 CVS :        $Id: keyb.h,v 1.1 2003-03-24 10:54:17 pj Exp $
24
 
25
 File:        $File$
26
 Revision:    $Revision: 1.1 $
27
 Last update: $Date: 2003-03-24 10:54:17 $
28
 ------------
29
 
30
**/
31
 
32
/*
33
 * Copyright (C) 2000 Giuseppe Lipari
34
 *
35
 * This program is free software; you can redistribute it and/or modify
36
 * it under the terms of the GNU General Public License as published by
37
 * the Free Software Foundation; either version 2 of the License, or
38
 * (at your option) any later version.
39
 *
40
 * This program is distributed in the hope that it will be useful,
41
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
43
 * GNU General Public License for more details.
44
 *
45
 * You should have received a copy of the GNU General Public License
46
 * along with this program; if not, write to the Free Software
47
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
48
 *
49
 */
50
 
51
/* Project:     HARTIK 3.0                                      */
52
/* Description: Hard Real TIme Kernel for 8086 compatible       */
53
/* Author:      Giuseppe Lipari                                 */
54
/* Start date   : 19/6/96                                       */
55
 
56
/* CVS $Id: keyb.h,v 1.1 2003-03-24 10:54:17 pj Exp $ */
57
 
58
/* File:        Keyb.H                                          */
59
/* Revision:    1.4b                                            */
60
 
61
/* Last update  : 22/3/99                                       */
62
 
63
/* (MG)                                                         */
64
/* -- added keyb_enable() & keyb_disable()                      */
65
/* -- changed keyb_init() definition                            */
66
 
67
#ifndef __KEYB_H__
68
#define __KEYB_H__
69
 
70
#include <kernel/const.h>
71
#include <kernel/model.h>
72
 
73
#ifdef __cplusplus
74
extern "C" {
75
#endif
76
 
77
#include <drivers/keycode.h>
78
 
79
/* Ascii Codes */
80
#define BACKSPACE       8
81
#define ENTER           13
82
#define DELETE          24
83
#define ESC             27
84
#define TAB             9
85
 
86
/* Scan Codes */
87
#define UP_KEY          72
88
#define DOWN_KEY        80
89
#define LEFT_KEY        75
90
#define RIGHT_KEY       77
91
#define PGUP_KEY        73
92
#define PGDW_KEY        81
93
#define HOME_KEY        71
94
#define END_KEY         79
95
#define INS_KEY         82
96
 
97
#define F1_KEY          59
98
#define F2_KEY          60
99
#define F3_KEY          61
100
#define F4_KEY          62
101
#define F5_KEY          63
102
#define F6_KEY          64
103
#define F7_KEY          65
104
#define F8_KEY          66
105
#define F9_KEY          67
106
#define F10_KEY         68
107
 
108
/* Flag Codes */
109
#define ALTR_BIT        0x001
110
#define ALTL_BIT        0x002
111
#define CNTR_BIT        0x004
112
#define CNTL_BIT        0x008
113
#define SHFL_BIT        0x010
114
#define SHFR_BIT        0x020
115
#define SCAN_BIT        0x040
116
 
117
typedef struct {
118
    BYTE flag;
119
    BYTE ascii;
120
    BYTE scan;
121
} KEY_EVT;
122
 
123
#define isScanCode(k)   (k.flag & SCAN_BIT)
124
#define isLeftShift(k)  (k.flag & SHFL_BIT)
125
#define isRightShift(k) (k.flag & SHFR_BIT)
126
#define isLeftCtrl(k)   (k.flag & CNTL_BIT)
127
#define isRightCtrl(k)  (k.flag & CNTR_BIT)
128
#define isLeftAlt(k)    (k.flag & ALTL_BIT)
129
#define isRightAlt(k)   (k.flag & ALTR_BIT)
130
 
131
#define keyb_getchar()  keyb_getch(BLOCK)
132
 
133
extern char engMap[];
134
extern char itaMap[];
135
 
136
typedef struct keyb_parms {
137
  TASK_MODEL *tm;
138
  char  *keybmap;
139
  void  (*ctrlcfunc)(KEY_EVT *k);
140
} KEYB_PARMS;
141
 
142
 
143
#define KEYB_DEFAULT ((unsigned long)(-1))   /*+ used for default params +*/
144
 
145
#define BASE_KEYB {(TASK_MODEL *)KEYB_DEFAULT, \
146
                   (char*)KEYB_DEFAULT,        \
147
                   (void *)KEYB_DEFAULT}
148
 
149
#define keyb_default_parm(m)   (m).tm = (TASK_MODEL *) KEYB_DEFAULT, \
150
                               (m).keybmap = (char *) KEYB_DEFAULT,  \
151
                               (m).ctrlcfunc = (void *) KEYB_DEFAULT
152
#define keyb_def_map(s,m)      (s).keybmap=(m)
153
#define keyb_def_ctrlC(s,f)    (s).ctrlcfunc=(f)
154
#define keyb_def_task(s,m)     (s).tm=(TASK_MODEL *)(m)
155
 
156
int  KEYB_init(KEYB_PARMS *s);
157
int  keyb_getch(BYTE wait);
158
int  keyb_getcode(KEY_EVT *k, BYTE wait);
159
void keyb_hook(KEY_EVT k, void (*f)(KEY_EVT *k));
160
int  keyb_enable(void);
161
int  keyb_disable(void);
162
int  keyb_end(void);
163
void keyb_set_map(char *t);
164
 
165
#ifdef __cplusplus
166
};
167
#endif
168
 
169
#endif