00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "htkeyb.h"
00022
00023 #include <pc.h>
00024 #include <stdio.h>
00025 #include <bios.h>
00026
00027 #define SHIFT_KEY(k) (k | 0x80000000)
00028
00029 bool ht_shift_pressed()
00030 {
00031 return (bioskey(2) & 3);
00032 }
00033
00034 bool ht_keypressed()
00035 {
00036 return kbhit();
00037 }
00038
00039 int ht_raw_getkey()
00040 {
00041 int k=-1;
00042 if (ht_shift_pressed()) {
00043 k=getkey();
00044 switch (k) {
00045 case 0x14b:
00046 case 0x14d:
00047 case 0x148:
00048 case 0x150:
00049 case 0x149:
00050 case 0x151:
00051 case 0x147:
00052 case 0x14f:
00053 case 0x152:
00054 case 0x153:
00055 case 0x173:
00056 case 0x174:
00057 k=SHIFT_KEY(k);
00058 break;
00059 }
00060 } else k=getkey();
00061 return k;
00062 }
00063
00064 ht_key ht_getkey()
00065 {
00066 UINT r=ht_raw_getkey();
00067 ht_key k=ht_rawkey2key(r);
00068 if ((k==K_INVALID) && (r<=255)) return (ht_key)r;
00069 return k;
00070 }
00071
00072 struct ht_key_keycode {
00073 ht_key key;
00074 int keycode;
00075 };
00076
00077 ht_key_keycode ht_dj_key_defs[] = {
00078 {K_BackSpace, 0x008},
00079 {K_BackTab, 0x10f},
00080
00081 {K_Tab, 0x009},
00082 {K_Return, 0x00d},
00083 {K_Escape, 0x01b},
00084
00085 {K_Control_A, 0x001},
00086 {K_Control_B, 0x002},
00087 {K_Control_C, 0x003},
00088 {K_Control_D, 0x004},
00089 {K_Control_E, 0x005},
00090 {K_Control_F, 0x006},
00091 {K_Control_G, 0x007},
00092 {K_Control_H, 0x008},
00093 {K_Control_I, 0x009},
00094 {K_Control_J, 0x00a},
00095 {K_Control_K, 0x00b},
00096 {K_Control_L, 0x00c},
00097 {K_Control_M, 0x00d},
00098 {K_Control_N, 0x00e},
00099 {K_Control_O, 0x00f},
00100 {K_Control_P, 0x010},
00101 {K_Control_Q, 0x011},
00102 {K_Control_R, 0x012},
00103 {K_Control_S, 0x013},
00104 {K_Control_T, 0x014},
00105 {K_Control_U, 0x015},
00106 {K_Control_V, 0x016},
00107 {K_Control_W, 0x017},
00108 {K_Control_X, 0x018},
00109 {K_Control_Y, 0x019},
00110 {K_Control_Z, 0x01a},
00111
00112 {K_Alt_Escape, 0x101},
00113 {K_Alt_Backspace, 0x10e},
00114 {K_Alt_Tab, 0x1a5},
00115 {K_Alt_Enter, 0x1a6},
00116
00117 {K_Alt_A, 0x11e},
00118 {K_Alt_B, 0x130},
00119 {K_Alt_C, 0x12e},
00120 {K_Alt_D, 0x120},
00121 {K_Alt_E, 0x112},
00122 {K_Alt_F, 0x121},
00123 {K_Alt_G, 0x122},
00124 {K_Alt_H, 0x123},
00125 {K_Alt_I, 0x117},
00126 {K_Alt_J, 0x124},
00127 {K_Alt_K, 0x125},
00128 {K_Alt_L, 0x126},
00129 {K_Alt_M, 0x132},
00130 {K_Alt_N, 0x131},
00131 {K_Alt_O, 0x118},
00132 {K_Alt_P, 0x119},
00133 {K_Alt_Q, 0x110},
00134 {K_Alt_R, 0x113},
00135 {K_Alt_S, 0x11f},
00136 {K_Alt_T, 0x114},
00137 {K_Alt_U, 0x116},
00138 {K_Alt_V, 0x12f},
00139 {K_Alt_W, 0x111},
00140 {K_Alt_X, 0x12d},
00141 {K_Alt_Y, 0x115},
00142 {K_Alt_Z, 0x12c},
00143
00144 {K_F1, 0x13b},
00145 {K_F2, 0x13c},
00146 {K_F3, 0x13d},
00147 {K_F4, 0x13e},
00148 {K_F5, 0x13f},
00149 {K_F6, 0x140},
00150 {K_F7, 0x141},
00151 {K_F8, 0x142},
00152 {K_F9, 0x143},
00153 {K_F10, 0x144},
00154 {K_F11, 0x185},
00155 {K_F12, 0x186},
00156
00157 {K_Shift_F1, 0x154},
00158 {K_Shift_F2, 0x155},
00159 {K_Shift_F3, 0x156},
00160 {K_Shift_F4, 0x157},
00161 {K_Shift_F5, 0x158},
00162 {K_Shift_F6, 0x159},
00163 {K_Shift_F7, 0x15a},
00164 {K_Shift_F8, 0x15b},
00165 {K_Shift_F9, 0x15c},
00166 {K_Shift_F10, 0x15d},
00167 {K_Shift_F11, 0x187},
00168 {K_Shift_F12, 0x188},
00169
00170 {K_Control_F1, 0x15e},
00171 {K_Control_F2, 0x15f},
00172 {K_Control_F3, 0x160},
00173 {K_Control_F4, 0x161},
00174 {K_Control_F5, 0x162},
00175 {K_Control_F6, 0x163},
00176 {K_Control_F7, 0x164},
00177 {K_Control_F8, 0x165},
00178 {K_Control_F9, 0x166},
00179 {K_Control_F10, 0x167},
00180 {K_Control_F11, 0x189},
00181 {K_Control_F12, 0x18a},
00182
00183 {K_Alt_F1, 0x168},
00184 {K_Alt_F2, 0x169},
00185 {K_Alt_F3, 0x16a},
00186 {K_Alt_F4, 0x16b},
00187 {K_Alt_F5, 0x16c},
00188 {K_Alt_F6, 0x16d},
00189 {K_Alt_F7, 0x16e},
00190 {K_Alt_F8, 0x16f},
00191 {K_Alt_F9, 0x170},
00192 {K_Alt_F10, 0x171},
00193 {K_Alt_F11, 0x18b},
00194 {K_Alt_F12, 0x18c},
00195
00196 {K_Alt_1, 0x178},
00197 {K_Alt_2, 0x179},
00198 {K_Alt_3, 0x17a},
00199 {K_Alt_4, 0x17b},
00200 {K_Alt_5, 0x17c},
00201 {K_Alt_6, 0x17d},
00202 {K_Alt_7, 0x17e},
00203 {K_Alt_8, 0x17f},
00204 {K_Alt_9, 0x180},
00205 {K_Alt_0, 0x181},
00206
00207 {K_Left, 0x14b},
00208 {K_Right, 0x14d},
00209 {K_Up, 0x148},
00210 {K_Down, 0x150},
00211 {K_PageUp, 0x149},
00212 {K_PageDown, 0x151},
00213 {K_Home, 0x147},
00214 {K_End, 0x14f},
00215 {K_Insert, 0x152},
00216 {K_Delete, 0x153},
00217
00218 {K_Control_Left, 0x173},
00219 {K_Control_Right, 0x174},
00220 {K_Control_Up, 0x18d},
00221 {K_Control_Down, 0x191},
00222 {K_Control_PageUp, 0x184},
00223 {K_Control_PageDown, 0x176},
00224 {K_Control_Home, 0x177},
00225 {K_Control_End, 0x175},
00226 {K_Control_Insert, 0x192},
00227 {K_Control_Delete, 0x193},
00228
00229 {K_Shift_Left, SHIFT_KEY(0x14b)},
00230 {K_Shift_Right, SHIFT_KEY(0x14d)},
00231 {K_Shift_Up, SHIFT_KEY(0x148)},
00232 {K_Shift_Down, SHIFT_KEY(0x150)},
00233 {K_Shift_PageUp, SHIFT_KEY(0x149)},
00234 {K_Shift_PageDown, SHIFT_KEY(0x151)},
00235 {K_Shift_Home, SHIFT_KEY(0x147)},
00236 {K_Shift_End, SHIFT_KEY(0x14f)},
00237 {K_Shift_Insert, SHIFT_KEY(0x152)},
00238 {K_Shift_Delete, SHIFT_KEY(0x153)},
00239 {K_Control_Shift_Left, SHIFT_KEY(0x173)},
00240 {K_Control_Shift_Right, SHIFT_KEY(0x174)}
00241 };
00242
00243
00244
00245
00246
00247 bool init_keyb()
00248 {
00249 UINT i;
00250
00251 for (i=0; i<K_COUNT; i++) {
00252 ht_set_key((ht_key)i, -1);
00253 }
00254
00255 for (i=0; i<sizeof ht_dj_key_defs/sizeof ht_dj_key_defs[0]; i++) {
00256 ht_set_key(ht_dj_key_defs[i].key, ht_dj_key_defs[i].keycode);
00257 }
00258
00259 return true;
00260 }
00261
00262
00263
00264
00265
00266 void done_keyb()
00267 {
00268 }
00269