Subversion Repositories shark

Rev

Rev 519 | Rev 547 | Go to most recent revision | Details | Compare with Previous | 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
 * Copyright (C) 2000 Giuseppe Lipari
24
 *
25
 * This program is free software; you can redistribute it and/or modify
26
 * it under the terms of the GNU General Public License as published by
27
 * the Free Software Foundation; either version 2 of the License, or
28
 * (at your option) any later version.
29
 *
30
 * This program is distributed in the hope that it will be useful,
31
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33
 * GNU General Public License for more details.
34
 *
35
 * You should have received a copy of the GNU General Public License
36
 * along with this program; if not, write to the Free Software
37
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
38
 *
39
 */
40
 
41
#ifndef __KEYB_H__
42
#define __KEYB_H__
43
 
44
#include <kernel/const.h>
45
#include <kernel/model.h>
46
 
47
#ifdef __cplusplus
48
extern "C" {
49
#endif
50
 
51
#include "keycode.h"
52
 
53
typedef struct {
54
        BYTE useAltGr;
55
        char keyMap     [TABLE_KEY_SIZE];
56
        char keyShiftMap[TABLE_KEY_SIZE];
57
        char keyAltGrMap[TABLE_KEY_SIZE];
58
} KEYB_MAP;
59
 
60
extern KEYB_MAP keyMaps[];
61
 
62
#define KEYMAP_US       0
63
#define KEYMAP_IT       1
64
 
65
/* Key Status */
66
#define KEY_RELEASED    0
67
#define KEY_PRESSED     1
68
#define KEY_REPEATED    2
69
 
70
/* Ascii Codes */
71
#define BACKSPACE       0x08
72
#define ENTER           0x0d
73
#define DELETE          0x18
74
#define ESC             0x1b
75
#define TAB             0x09
76
 
77
/* Flag Codes */
78
#define ALTR_BIT        0x01
79
#define ALTL_BIT        0x02
80
#define CNTR_BIT        0x04
81
#define CNTL_BIT        0x08
82
#define SHFL_BIT        0x10
83
#define SHFR_BIT        0x20
84
#define SCAN_BIT        0x40
85
 
86
typedef struct {
87
        BYTE ascii;
88
        BYTE scan;
89
        BYTE flag;
90
        BYTE status;
91
} KEY_EVT;
92
 
93
#define isRepeated(k)   (k.status == KEY_REPEATED)
94
#define isReleased(k)   (k.status == KEY_RELEASED)
95
 
96
#define isScanCode(k)   (k.flag & SCAN_BIT)
97
#define isLeftShift(k)  (k.flag & SHFL_BIT)
98
#define isRightShift(k) (k.flag & SHFR_BIT)
99
#define isLeftCtrl(k)   (k.flag & CNTL_BIT)
100
#define isRightCtrl(k)  (k.flag & CNTR_BIT)
101
#define isLeftAlt(k)    (k.flag & ALTL_BIT)
102
#define isRightAlt(k)   (k.flag & ALTR_BIT)
103
 
104
#define keyb_getchar()  keyb_getch(BLOCK)
105
 
523 mauro 106
/*
107
 * keyboard initialization
108
 */
109
 
110
/* the KEYB_PARMS structure used by KEYB26_init() */
519 mauro 111
typedef struct keyb_parms {
112
        TASK_MODEL *tm;
113
        unsigned char keymap;
114
        void  (*ctrlcfunc)(KEY_EVT *k);
115
} KEYB_PARMS;
116
 
117
#define KEYB_DEFAULT ((unsigned long)(-1))   /*+ used for default params +*/
118
 
119
#define BASE_KEYB       {(TASK_MODEL *)KEYB_DEFAULT, \
523 mauro 120
                         (unsigned char)KEYB_DEFAULT, \
519 mauro 121
                         (void *)KEYB_DEFAULT}
122
 
123
#define keyb_default_parm(m)    (m).tm = (TASK_MODEL *) KEYB_DEFAULT, \
124
                                (m).keymap = (unsigned char) KEYB_DEFAULT,  \
125
                                (m).ctrlcfunc = (void *) KEYB_DEFAULT
126
 
523 mauro 127
#define keyb_def_map(s,m)       (s).keymap = (m)
128
#define keyb_def_ctrlC(s,f)     (s).ctrlcfunc = (f)
129
#define keyb_def_task(s,m)      (s).tm = (TASK_MODEL *)(m)
130
 
519 mauro 131
int  KEYB26_init(KEYB_PARMS *s);
132
int  KEYB26_close(void);
133
 
134
BYTE keyb_getch(BYTE wait);
135
int  keyb_getcode(KEY_EVT *k, BYTE wait);
136
void keyb_hook(KEY_EVT k, void (*f)(KEY_EVT *k), unsigned char l);
137
int  keyb_enable(void);
138
int  keyb_disable(void);
139
int  keyb_end(void);
140
int  keyb_set_map(unsigned char m);
141
int  keyb_get_map(void);
142
 
143
#ifdef __cplusplus
144
};
145
#endif
146
 
147
#endif