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