HPGCC3 Documentation 3.0 R003
|
00001 //& *** (c) 2006-2011 The HPGCC3 Team *** 00002 //& Claudio Lapilli 00003 //& Ingo Blank 00004 //& 00005 //& This file is licensed under the terms and conditions of the 00006 //& HPGCC3 license that is included with the source distribution. 00007 //& *** (c) 2006-2011 The HPGCC3 Team *** 00008 00009 #ifndef _KEYB_H 00010 #define _KEYB_H 00011 00012 // LONG TYPE DEFINITION, ADDED BY CLAUDIO 01/14/05 00013 #ifndef _LONGLONG_DEF 00014 typedef unsigned long long ULONGLONG; 00015 typedef long long LONGLONG; 00016 #define _LONGLONG_DEF 00017 #endif 00018 00048 // KEYBOARD MATRIX HANDLING ROUTINE, ADDED BY CLAUDIO 00049 00050 /* 00051 00052 KEYBOARD BIT MAP 00053 ---------------- 00054 This is the bit number in the 64-bit keymatrix. 00055 Bit set means key is pressed. 00056 00057 A]-+ B]-+ C]-+ D]-+ E]-+ F]-+ 00058 |41| |42| |43| |44| |45| |46| 00059 +--+ +--+ +--+ +--+ +--+ +--+ 00060 00061 G]-+ H]-+ I]-+ UP]+ 00062 |47| |53| |54| |49| 00063 +--+ +--+ +--+ LF]+ +--+ RT]+ 00064 |50| DN]+ |52| 00065 J]-+ K]-+ L]-+ +--+ |51| +--+ 00066 |55| |57| |58| +--+ 00067 +--+ +--+ +--+ 00068 00069 M]--+ N]--+ O]--+ P]--+ BKS]+ 00070 | 33| | 25| | 17| | 09| | 01| 00071 +---+ +---+ +---+ +---+ +---+ 00072 00073 Q]--+ R]--+ S]--+ T]--+ U]--+ 00074 | 34| | 26| | 18| | 10| | 02| 00075 +---+ +---+ +---+ +---+ +---+ 00076 00077 V]--+ W]--+ X]--+ Y]--+ /]--+ 00078 | 35| | 27| | 19| | 11| | 03| 00079 +---+ +---+ +---+ +---+ +---+ 00080 00081 AL]-+ 7]--+ 8]--+ 9]--+ *]--+ 00082 | 60| | 28| | 20| | 12| | 04| 00083 +---+ +---+ +---+ +---+ +---+ 00084 00085 LS]-+ 4]--+ 5]--+ 6]--+ -]--+ 00086 | 61| | 29| | 21| | 13| | 05| 00087 +---+ +---+ +---+ +---+ +---+ 00088 00089 RS]-+ 1]--+ 2]--+ 3]--+ +]--+ 00090 | 62| | 30| | 22| | 14| | 06| 00091 +---+ +---+ +---+ +---+ +---+ 00092 00093 ON]-+ 0]--+ .]--+ SP]-+ EN]-+ 00094 | 63| | 31| | 23| | 15| | 07| 00095 +---+ +---+ +---+ +---+ +---+ 00096 00097 */ 00098 00100 #define KB_A 41 00101 00102 #define KB_B 42 00103 00104 #define KB_C 43 00105 00106 #define KB_D 44 00107 00108 #define KB_E 45 00109 00110 #define KB_F 46 00111 00112 #define KB_G 47 00113 00114 #define KB_H 53 00115 00116 #define KB_I 54 00117 00118 #define KB_J 55 00119 00120 #define KB_K 57 00121 00122 #define KB_L 58 00123 00124 #define KB_M 33 00125 00126 #define KB_N 25 00127 00128 #define KB_O 17 00129 00130 #define KB_P 9 00131 00132 #define KB_Q 34 00133 00134 #define KB_R 26 00135 00136 #define KB_S 18 00137 00138 #define KB_T 10 00139 00140 #define KB_U 2 00141 00142 #define KB_V 35 00143 00144 #define KB_W 27 00145 00146 #define KB_X 19 00147 00148 #define KB_Y 11 00149 00150 #define KB_Z KB_DIV 00151 00152 #define KB_0 31 00153 00154 #define KB_1 30 00155 00156 #define KB_2 22 00157 00158 #define KB_3 14 00159 00160 #define KB_4 29 00161 00162 #define KB_5 21 00163 00164 #define KB_6 13 00165 00166 #define KB_7 28 00167 00168 #define KB_8 20 00169 00170 #define KB_9 12 00171 00172 #define KB_BKS 1 00173 00174 #define KB_DIV 3 00175 00176 #define KB_MUL 4 00177 00178 #define KB_ADD 6 00179 00180 #define KB_SUB 5 00181 00182 #define KB_DOT 23 00183 00184 #define KB_SPC 15 00185 00186 #define KB_ENT 7 00187 00188 #define KB_UP 49 00189 00190 #define KB_DN 51 00191 00192 #define KB_LF 50 00193 00194 #define KB_RT 52 00195 00196 #define KB_ALPHA 60 00197 00198 #define KB_LSHIFT 61 00199 00200 #define KB_RSHIFT 62 00201 00202 #define KB_ON 63 00203 00204 // MACROS TO CREATE KEYBOARD MASKS 00210 #define KB_MASK(a) (((ULONGLONG)1)<<(a)) 00211 00212 // COMMON KEYBOARD MASKS 00213 // ALL CURSOR KEYS 00214 00224 #define KB_CURS ((ULONGLONG)0x001e000000000000) 00225 00226 // ALL FUNCTION KEYS (A-F) 00236 #define KB_FUNC ((ULONGLONG)0x00007e0000000000) 00237 00238 00239 // SHIFT CONSTANTS FOR HIGH-LEVEL KEYBOARD FUNCTIONS 00240 00242 #define SHIFT_LS 0x40 00243 00244 #define SHIFT_LSHOLD 0x80 00245 00246 #define SHIFT_RS 0x100 00247 00248 #define SHIFT_RSHOLD 0x200 00249 00251 #define SHIFT_ALPHA 0x400 00252 00253 #define SHIFT_ALPHAHOLD 0x800 00254 00256 #define SHIFT_ONHOLD 0x1000 00257 00259 #define SHIFT_ANY 0x1fc0 00260 00261 00263 #define KEYCODE(SHIFTcode) ((SHIFTcode)&0x3f) 00264 00265 #define SHIFTPLANE(SHIFTcode) ((SHIFTcode)&SHIFT_ANY) 00266 00267 00268 // KEYMATRIX TYPE DEFINITION 00275 typedef ULONGLONG keymatrix; 00276 00277 // SCANS THE KEYBOARD AND STORES THE 64-BIT MATRIX 00287 keymatrix keyb_getmatrix(); 00288 00298 #define keyb_isKeyPressed(keycode) (keyb_getkey(0)==keycode) 00299 00306 #define keyb_isAnyKeyPressed() (keyb_getmatrix()!=0LL) 00307 00315 #define keyb_isLeft() ((keyb_getmatrix()&KB_MASK(KB_LF))!=0) 00316 00324 #define keyb_isRight() ((keyb_getmatrix()&KB_MASK(KB_RT))!=0) 00325 00333 #define keyb_isUp() ((keyb_getmatrix()&KB_MASK(KB_UP))!=0) 00334 00342 #define keyb_isDown() ((keyb_getmatrix()&KB_MASK(KB_DN))!=0) 00343 00352 #define keyb_isAlpha() ((keyb_getmatrix()&KB_MASK(KB_ALPHA))!=0) 00353 00362 #define keyb_isLS() ((keyb_getmatrix()&KB_MASK(KB_LSHIFT))!=0) 00363 00372 #define keyb_isRS() ((keyb_getmatrix()&KB_MASK(KB_RSHIFT))!=0) 00373 00381 #define keyb_isON() ((keyb_getmatrix()&KB_MASK(KB_ON))!=0) 00382 00383 00418 int keyb_getkey(int wait); 00419 00420 00421 // convenience macro 00422 // < ibl ; 2005-05-08 > 00423 00424 #define WAIT_CANCEL {while(keyb_isON()); while(! keyb_isON());} 00425 #define SLOW_WAIT_CANCEL {cpu_setspeed(6*1000000);while(keyb_isON()); while(! keyb_isON());} 00426 00427 // ************************************* 00428 // NEW HPGCC3 KEYBOARD MACHINERY 00429 // ************************************* 00430 00432 #define KM_PRESS 0x0000 00433 00434 #define KM_KEYDN 0x4000 00435 00436 #define KM_KEYUP 0x8000 00437 00438 #define KM_SHIFT 0xc000 00439 00441 #define KM_SHIFTMASK 0x1fc0 00442 00443 #define KM_KEYMASK 0x003f 00444 00445 #define KM_MSGMASK 0xc000 00446 00447 00449 #define KEYB_BUFFER 128 00450 00451 #define KEYB_SCANSPEED 20 00452 00454 #define KM_MESSAGE(a) ( (a) & KM_MSGMASK) 00455 00456 #define KM_KEY(a) ( (a) & KM_KEYMASK) 00457 00458 #define KM_SHIFTEDKEY(a) ( (a) & (KM_KEYMASK|KM_SHIFTMASK)) 00459 00460 #define KM_SHIFTPLANE(a) ( (a) & KM_SHIFTMASK) 00461 00462 00463 00479 void keyb_postmsg(unsigned int msg); 00480 00481 00508 unsigned int keyb_getmsg(); 00509 00510 00526 void keyb_settiming(int repeat,int longpress,int debounce); 00527 00528 00535 void keyb_setrepeat(int repeat); 00536 00537 00545 void keyb_setalphalock(int single_alpha_lock); 00546 00559 void keyb_setshiftplane(int leftshift,int rightshift,int alpha,int alphalock); 00560 00561 00562 #endif