Replaced USER32.DLL use by hardcoded tables for VkKeyScanA and
MapVirtualKeyA.
This commit is contained in:
parent
92643003cf
commit
e75902a555
|
@ -10,8 +10,6 @@
|
|||
/* FIXME:
|
||||
* - Completely lacks SCREENBUFFER interface.
|
||||
* - No abstraction for something other than xterm.
|
||||
* - Key input translation shouldn't use VkKeyScan and MapVirtualKey, since
|
||||
* they are window (USER) driver dependend.
|
||||
* - Output sometimes is buffered (We switched off buffering by ~ICANON ?)
|
||||
*/
|
||||
/* Reference applications:
|
||||
|
@ -54,6 +52,44 @@
|
|||
|
||||
DEFAULT_DEBUG_CHANNEL(console)
|
||||
|
||||
/* Ascii -> VK, generated by calling VkKeyScanA(i) */
|
||||
static int vkkeyscan_table[256] = {
|
||||
0,0,0,0,0,0,0,0,8,9,0,0,0,13,0,0,0,0,0,19,145,556,0,0,0,0,0,27,0,0,0,
|
||||
0,32,305,478,307,308,309,311,222,313,304,312,443,188,189,190,191,48,
|
||||
49,50,51,52,53,54,55,56,57,442,186,444,187,446,447,306,321,322,323,
|
||||
324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,
|
||||
341,342,343,344,345,346,219,220,221,310,445,192,65,66,67,68,69,70,71,
|
||||
72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,475,476,477,
|
||||
448,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,400,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
static int mapvkey_0[256]={
|
||||
0,0,0,0,0,0,0,0,14,15,0,0,0,28,0,0,42,29,56,69,58,0,0,0,0,0,0,1,0,0,
|
||||
0,0,57,73,81,79,71,75,72,77,80,0,0,0,55,82,83,0,11,2,3,4,5,6,7,8,9,
|
||||
10,0,0,0,0,0,0,0,30,48,46,32,18,33,34,35,23,36,37,38,50,49,24,25,16,
|
||||
19,31,20,22,47,17,45,21,44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,78,0,74,
|
||||
0,53,59,60,61,62,63,64,65,66,67,68,87,88,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,69,70,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,39,13,51,12,52,53,41,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,43,27,40,76,96,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
static int mapvkey_1[256]={
|
||||
0,27,49,50,51,52,53,54,55,56,57,48,189,187,8,9,81,87,69,82,84,89,85,
|
||||
73,79,80,219,221,13,17,65,83,68,70,71,72,74,75,76,186,222,192,16,220,
|
||||
90,88,67,86,66,78,77,188,190,191,16,106,18,32,20,112,113,114,115,116,
|
||||
117,118,119,120,121,144,145,36,38,33,109,37,223,39,107,35,40,34,45,
|
||||
46,0,0,0,122,123,0,0,0,0,0,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
/* FIXME: Should be in an internal header file. OK, so which one?
|
||||
Used by CONSOLE_makecomplex. */
|
||||
|
@ -102,22 +138,16 @@ CONSOLE_string_to_IR( HANDLE hConsoleInput,unsigned char *buf,int len) {
|
|||
ir.Event.KeyEvent.dwControlKeyState|=LEFT_ALT_PRESSED;
|
||||
inchar &= ~0x80;
|
||||
}
|
||||
#if 0 /* FIXME: cannot call USER functions here */
|
||||
ir.Event.KeyEvent.wVirtualKeyCode = VkKeyScan16(inchar);
|
||||
ir.Event.KeyEvent.wVirtualKeyCode = vkkeyscan_table[inchar];
|
||||
if (ir.Event.KeyEvent.wVirtualKeyCode & 0x0100)
|
||||
ir.Event.KeyEvent.dwControlKeyState|=SHIFT_PRESSED;
|
||||
if (ir.Event.KeyEvent.wVirtualKeyCode & 0x0200)
|
||||
ir.Event.KeyEvent.dwControlKeyState|=LEFT_CTRL_PRESSED;
|
||||
if (ir.Event.KeyEvent.wVirtualKeyCode & 0x0400)
|
||||
ir.Event.KeyEvent.dwControlKeyState|=LEFT_ALT_PRESSED;
|
||||
ir.Event.KeyEvent.wVirtualScanCode = MapVirtualKey16(
|
||||
ir.Event.KeyEvent.wVirtualKeyCode & 0x00ff,
|
||||
0 /* VirtualKeyCodes to ScanCode */
|
||||
);
|
||||
#else
|
||||
ir.Event.KeyEvent.wVirtualKeyCode = 0;
|
||||
ir.Event.KeyEvent.wVirtualScanCode = 0;
|
||||
#endif
|
||||
ir.Event.KeyEvent.wVirtualScanCode = mapvkey_0[
|
||||
ir.Event.KeyEvent.wVirtualKeyCode & 0x00ff
|
||||
]; /* VirtualKeyCodes to ScanCode */
|
||||
ir.Event.KeyEvent.uChar.AsciiChar = inchar;
|
||||
|
||||
if ((inchar==127)||(inchar=='\b')) { /* backspace */
|
||||
|
@ -150,15 +180,10 @@ CONSOLE_string_to_IR( HANDLE hConsoleInput,unsigned char *buf,int len) {
|
|||
ir.Event.KeyEvent.bKeyDown = 1;
|
||||
ir.Event.KeyEvent.wRepeatCount = 0;
|
||||
|
||||
#if 0 /* FIXME: cannot call USER functions here */
|
||||
ir.Event.KeyEvent.wVirtualKeyCode = VkKeyScan16(27);
|
||||
ir.Event.KeyEvent.wVirtualScanCode = MapVirtualKey16(
|
||||
ir.Event.KeyEvent.wVirtualKeyCode,0
|
||||
);
|
||||
#else
|
||||
ir.Event.KeyEvent.wVirtualKeyCode = VK_ESCAPE;
|
||||
ir.Event.KeyEvent.wVirtualScanCode = 1;
|
||||
#endif
|
||||
ir.Event.KeyEvent.wVirtualScanCode = mapvkey_0[
|
||||
ir.Event.KeyEvent.wVirtualKeyCode
|
||||
];
|
||||
ir.Event.KeyEvent.dwControlKeyState = 0;
|
||||
ir.Event.KeyEvent.uChar.AsciiChar = 27;
|
||||
assert(WriteConsoleInputA( hConsoleInput, &ir, 1, &junk ));
|
||||
|
@ -240,11 +265,7 @@ CONSOLE_string_to_IR( HANDLE hConsoleInput,unsigned char *buf,int len) {
|
|||
}
|
||||
if (scancode) {
|
||||
ir.Event.KeyEvent.wVirtualScanCode = scancode;
|
||||
#if 0 /* FIXME: cannot call USER functions here */
|
||||
ir.Event.KeyEvent.wVirtualKeyCode = MapVirtualKey16(scancode,1);
|
||||
#else
|
||||
ir.Event.KeyEvent.wVirtualKeyCode = 0;
|
||||
#endif
|
||||
ir.Event.KeyEvent.wVirtualKeyCode = mapvkey_1[scancode];
|
||||
assert(WriteConsoleInputA( hConsoleInput, &ir, 1, &junk ));
|
||||
ir.Event.KeyEvent.bKeyDown = 0;
|
||||
assert(WriteConsoleInputA( hConsoleInput, &ir, 1, &junk ));
|
||||
|
|
Loading…
Reference in New Issue