Subversion Repositories shark

Rev

Rev 523 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
519 mauro 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
 *   Mauro Marinoni      <mauro.marinoni@unipv.it>
13
 *   (see the web pages for full authors list)
14
 *
15
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
16
 *
17
 * http://www.sssup.it
18
 * http://retis.sssup.it
19
 * http://shark.sssup.it
20
 */
21
 
22
/**
23
 ------------
24
 CVS :        $Id: shark_keyb26.h,v 1.1 2004-03-22 14:48:15 mauro Exp $
25
 
26
 File:        $File$
27
 Revision:    $Revision: 1.1 $
28
 Last update: $Date: 2004-03-22 14:48:15 $
29
 ------------
30
 
31
**/
32
 
33
/*
34
 * Copyright (C) 2000 Giuseppe Lipari
35
 *
36
 * This program is free software; you can redistribute it and/or modify
37
 * it under the terms of the GNU General Public License as published by
38
 * the Free Software Foundation; either version 2 of the License, or
39
 * (at your option) any later version.
40
 *
41
 * This program is distributed in the hope that it will be useful,
42
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
43
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
44
 * GNU General Public License for more details.
45
 *
46
 * You should have received a copy of the GNU General Public License
47
 * along with this program; if not, write to the Free Software
48
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
49
 *
50
 */
51
 
52
/* Project:     HARTIK 3.0                                      */
53
/* Description: Hard Real TIme Kernel for 8086 compatible       */
54
/* Author:      Giuseppe Lipari                                 */
55
/* Start date   : 19/6/96                                       */
56
 
57
/* CVS $Id: shark_keyb26.h,v 1.1 2004-03-22 14:48:15 mauro Exp $ */
58
 
59
/* File:        Keyb.H                                          */
60
/* Revision:    1.4b                                            */
61
 
62
/* Last update  : 22/3/99                                       */
63
 
64
/* (MG)                                                         */
65
/* -- added keyb_enable() & keyb_disable()                      */
66
/* -- changed keyb_init() definition                            */
67
 
68
#ifndef __KEYB_H__
69
#define __KEYB_H__
70
 
71
#include <kernel/const.h>
72
#include <kernel/model.h>
73
 
74
#ifdef __cplusplus
75
extern "C" {
76
#endif
77
 
78
#include "keycode.h"
79
 
80
typedef struct {
81
        BYTE useAltGr;
82
        char keyMap     [TABLE_KEY_SIZE];
83
        char keyShiftMap[TABLE_KEY_SIZE];
84
        char keyAltGrMap[TABLE_KEY_SIZE];
85
} KEYB_MAP;
86
 
87
extern KEYB_MAP keyMaps[];
88
 
89
#define KEYMAP_US       0
90
#define KEYMAP_IT       1
91
 
92
/* Key Status */
93
#define KEY_RELEASED    0
94
#define KEY_PRESSED     1
95
#define KEY_REPEATED    2
96
 
97
/* Ascii Codes */
98
#define BACKSPACE       0x08
99
#define ENTER           0x0d
100
#define DELETE          0x18
101
#define ESC             0x1b
102
#define TAB             0x09
103
 
104
/* Flag Codes */
105
#define ALTR_BIT        0x01
106
#define ALTL_BIT        0x02
107
#define CNTR_BIT        0x04
108
#define CNTL_BIT        0x08
109
#define SHFL_BIT        0x10
110
#define SHFR_BIT        0x20
111
#define SCAN_BIT        0x40
112
 
113
typedef struct {
114
        BYTE ascii;
115
        BYTE scan;
116
        BYTE flag;
117
        BYTE status;
118
} KEY_EVT;
119
 
120
#define isRepeated(k)   (k.status == KEY_REPEATED)
121
#define isReleased(k)   (k.status == KEY_RELEASED)
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
typedef struct keyb_parms {
134
        TASK_MODEL *tm;
135
        unsigned char keymap;
136
        void  (*ctrlcfunc)(KEY_EVT *k);
137
} KEYB_PARMS;
138
 
139
#define KEYB_DEFAULT ((unsigned long)(-1))   /*+ used for default params +*/
140
 
141
#define BASE_KEYB       {(TASK_MODEL *)KEYB_DEFAULT, \
142
                         (unsigned char)KEYB_DEFAULT,        \
143
                         (void *)KEYB_DEFAULT}
144
 
145
#define keyb_default_parm(m)    (m).tm = (TASK_MODEL *) KEYB_DEFAULT, \
146
                                (m).keymap = (unsigned char) KEYB_DEFAULT,  \
147
                                (m).ctrlcfunc = (void *) KEYB_DEFAULT
148
#define keyb_def_map(s,m)       (s).keymap=(m)
149
#define keyb_def_ctrlC(s,f)     (s).ctrlcfunc=(f)
150
#define keyb_def_task(s,m)      (s).tm=(TASK_MODEL *)(m)
151
 
152
int  KEYB26_init(KEYB_PARMS *s);
153
int  KEYB26_close(void);
154
 
155
BYTE keyb_getch(BYTE wait);
156
int  keyb_getcode(KEY_EVT *k, BYTE wait);
157
void keyb_hook(KEY_EVT k, void (*f)(KEY_EVT *k), unsigned char l);
158
int  keyb_enable(void);
159
int  keyb_disable(void);
160
int  keyb_end(void);
161
int  keyb_set_map(unsigned char m);
162
int  keyb_get_map(void);
163
 
164
#ifdef __cplusplus
165
};
166
#endif
167
 
168
#endif