work to improve keyboard keycode -> scancode processing
Signed-off-by: Aric Stewart <aric@codeweavers.com>
This commit is contained in:
parent
38ebba8d8a
commit
2caf06d1ed
183
atKeynames.js
Normal file
183
atKeynames.js
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
"use strict";
|
||||||
|
/*
|
||||||
|
Copyright (C) 2012 by Aric Stewart <aric@codeweavers.com>
|
||||||
|
|
||||||
|
This file is part of spice-html5.
|
||||||
|
|
||||||
|
spice-html5 is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
spice-html5 is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with spice-html5. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
* documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
* the above copyright notice appear in all copies and that both that
|
||||||
|
* copyright notice and this permission notice appear in supporting
|
||||||
|
* documentation, and that the name of Thomas Roell not be used in
|
||||||
|
* advertising or publicity pertaining to distribution of the software without
|
||||||
|
* specific, written prior permission. Thomas Roell makes no representations
|
||||||
|
* about the suitability of this software for any purpose. It is provided
|
||||||
|
* "as is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
* THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||||
|
* EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||||
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||||
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1994-2003 by The XFree86 Project, Inc.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Except as contained in this notice, the name of the copyright holder(s)
|
||||||
|
* and author(s) shall not be used in advertising or otherwise to promote
|
||||||
|
* the sale, use or other dealings in this Software without prior written
|
||||||
|
* authorization from the copyright holder(s) and author(s).
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three)
|
||||||
|
* sets of scancodes. Set3 can only be generated by a MF keyboard.
|
||||||
|
* Set2 sends a makecode for keypress, and the same code prefixed by a
|
||||||
|
* F0 for keyrelease. This is a little bit ugly to handle. Thus we use
|
||||||
|
* here for X386 the PC/XT compatible Set1. This set uses 8bit scancodes.
|
||||||
|
* Bit 7 ist set if the key is released. The code E0 switches to a
|
||||||
|
* different meaning to add the new MF cursorkeys, while not breaking old
|
||||||
|
* applications. E1 is another special prefix. Since I assume that there
|
||||||
|
* will be further versions of PC/XT scancode compatible keyboards, we
|
||||||
|
* may be in trouble one day.
|
||||||
|
*
|
||||||
|
* IDEA: 1) Use Set2 on AT84 keyboards and translate it to MF Set3.
|
||||||
|
* 2) Use the keyboards native set and translate it to common keysyms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* definition of the AT84/MF101/MF102 Keyboard:
|
||||||
|
* ============================================================
|
||||||
|
* Defined Key Cap Glyphs Pressed value
|
||||||
|
* Key Name Main Also (hex) (dec)
|
||||||
|
* ---------------- ---------- ------- ------ ------
|
||||||
|
*/
|
||||||
|
|
||||||
|
var KEY_Escape =/* Escape 0x01 */ 1
|
||||||
|
var KEY_1 =/* 1 ! 0x02 */ 2
|
||||||
|
var KEY_2 =/* 2 @ 0x03 */ 3
|
||||||
|
var KEY_3 =/* 3 # 0x04 */ 4
|
||||||
|
var KEY_4 =/* 4 $ 0x05 */ 5
|
||||||
|
var KEY_5 =/* 5 % 0x06 */ 6
|
||||||
|
var KEY_6 =/* 6 ^ 0x07 */ 7
|
||||||
|
var KEY_7 =/* 7 & 0x08 */ 8
|
||||||
|
var KEY_8 =/* 8 * 0x09 */ 9
|
||||||
|
var KEY_9 =/* 9 ( 0x0a */ 10
|
||||||
|
var KEY_0 =/* 0 ) 0x0b */ 11
|
||||||
|
var KEY_Minus =/* - (Minus) _ (Under) 0x0c */ 12
|
||||||
|
var KEY_Equal =/* = (Equal) + 0x0d */ 13
|
||||||
|
var KEY_BackSpace =/* Back Space 0x0e */ 14
|
||||||
|
var KEY_Tab =/* Tab 0x0f */ 15
|
||||||
|
var KEY_Q =/* Q 0x10 */ 16
|
||||||
|
var KEY_W =/* W 0x11 */ 17
|
||||||
|
var KEY_E =/* E 0x12 */ 18
|
||||||
|
var KEY_R =/* R 0x13 */ 19
|
||||||
|
var KEY_T =/* T 0x14 */ 20
|
||||||
|
var KEY_Y =/* Y 0x15 */ 21
|
||||||
|
var KEY_U =/* U 0x16 */ 22
|
||||||
|
var KEY_I =/* I 0x17 */ 23
|
||||||
|
var KEY_O =/* O 0x18 */ 24
|
||||||
|
var KEY_P =/* P 0x19 */ 25
|
||||||
|
var KEY_LBrace =/* [ { 0x1a */ 26
|
||||||
|
var KEY_RBrace =/* ] } 0x1b */ 27
|
||||||
|
var KEY_Enter =/* Enter 0x1c */ 28
|
||||||
|
var KEY_LCtrl =/* Ctrl(left) 0x1d */ 29
|
||||||
|
var KEY_A =/* A 0x1e */ 30
|
||||||
|
var KEY_S =/* S 0x1f */ 31
|
||||||
|
var KEY_D =/* D 0x20 */ 32
|
||||||
|
var KEY_F =/* F 0x21 */ 33
|
||||||
|
var KEY_G =/* G 0x22 */ 34
|
||||||
|
var KEY_H =/* H 0x23 */ 35
|
||||||
|
var KEY_J =/* J 0x24 */ 36
|
||||||
|
var KEY_K =/* K 0x25 */ 37
|
||||||
|
var KEY_L =/* L 0x26 */ 38
|
||||||
|
var KEY_SemiColon =/* ;(SemiColon) :(Colon) 0x27 */ 39
|
||||||
|
var KEY_Quote =/* ' (Apostr) " (Quote) 0x28 */ 40
|
||||||
|
var KEY_Tilde =/* ` (Accent) ~ (Tilde) 0x29 */ 41
|
||||||
|
var KEY_ShiftL =/* Shift(left) 0x2a */ 42
|
||||||
|
var KEY_BSlash =/* \(BckSlash) |(VertBar)0x2b */ 43
|
||||||
|
var KEY_Z =/* Z 0x2c */ 44
|
||||||
|
var KEY_X =/* X 0x2d */ 45
|
||||||
|
var KEY_C =/* C 0x2e */ 46
|
||||||
|
var KEY_V =/* V 0x2f */ 47
|
||||||
|
var KEY_B =/* B 0x30 */ 48
|
||||||
|
var KEY_N =/* N 0x31 */ 49
|
||||||
|
var KEY_M =/* M 0x32 */ 50
|
||||||
|
var KEY_Comma =/* , (Comma) < (Less) 0x33 */ 51
|
||||||
|
var KEY_Period =/* . (Period) >(Greater)0x34 */ 52
|
||||||
|
var KEY_Slash =/* / (Slash) ? 0x35 */ 53
|
||||||
|
var KEY_ShiftR =/* Shift(right) 0x36 */ 54
|
||||||
|
var KEY_KP_Multiply =/* * 0x37 */ 55
|
||||||
|
var KEY_Alt =/* Alt(left) 0x38 */ 56
|
||||||
|
var KEY_Space =/* (SpaceBar) 0x39 */ 57
|
||||||
|
var KEY_CapsLock =/* CapsLock 0x3a */ 58
|
||||||
|
var KEY_F1 =/* F1 0x3b */ 59
|
||||||
|
var KEY_F2 =/* F2 0x3c */ 60
|
||||||
|
var KEY_F3 =/* F3 0x3d */ 61
|
||||||
|
var KEY_F4 =/* F4 0x3e */ 62
|
||||||
|
var KEY_F5 =/* F5 0x3f */ 63
|
||||||
|
var KEY_F6 =/* F6 0x40 */ 64
|
||||||
|
var KEY_F7 =/* F7 0x41 */ 65
|
||||||
|
var KEY_F8 =/* F8 0x42 */ 66
|
||||||
|
var KEY_F9 =/* F9 0x43 */ 67
|
||||||
|
var KEY_F10 =/* F10 0x44 */ 68
|
||||||
|
var KEY_NumLock =/* NumLock 0x45 */ 69
|
||||||
|
var KEY_ScrollLock =/* ScrollLock 0x46 */ 70
|
||||||
|
var KEY_KP_7 =/* 7 Home 0x47 */ 71
|
||||||
|
var KEY_KP_8 =/* 8 Up 0x48 */ 72
|
||||||
|
var KEY_KP_9 =/* 9 PgUp 0x49 */ 73
|
||||||
|
var KEY_KP_Minus =/* - (Minus) 0x4a */ 74
|
||||||
|
var KEY_KP_4 =/* 4 Left 0x4b */ 75
|
||||||
|
var KEY_KP_5 =/* 5 0x4c */ 76
|
||||||
|
var KEY_KP_6 =/* 6 Right 0x4d */ 77
|
||||||
|
var KEY_KP_Plus =/* + (Plus) 0x4e */ 78
|
||||||
|
var KEY_KP_1 =/* 1 End 0x4f */ 79
|
||||||
|
var KEY_KP_2 =/* 2 Down 0x50 */ 80
|
||||||
|
var KEY_KP_3 =/* 3 PgDown 0x51 */ 81
|
||||||
|
var KEY_KP_0 =/* 0 Insert 0x52 */ 82
|
||||||
|
var KEY_KP_Decimal =/* . (Decimal) Delete 0x53 */ 83
|
||||||
|
var KEY_SysReqest =/* SysReqest 0x54 */ 84
|
||||||
|
/* NOTUSED 0x55 */
|
||||||
|
var KEY_Less =/* < (Less) >(Greater) 0x56 */ 86
|
||||||
|
var KEY_F11 =/* F11 0x57 */ 87
|
||||||
|
var KEY_F12 =/* F12 0x58 */ 88
|
||||||
|
|
||||||
|
var KEY_Prefix0 =/* special 0x60 */ 96
|
||||||
|
var KEY_Prefix1 =/* specail 0x61 */ 97
|
260
utils.js
260
utils.js
@ -94,146 +94,168 @@ function hexdump_buffer(a)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------
|
||||||
** FIXME FIXME FIXME - web key code to scan code mapping
|
** Converting keycodes to AT scancodes is very hard.
|
||||||
** This is really atrocious code. At the end of the day, we need to
|
** luckly there are some resources on the web and in the Xorg driver that help
|
||||||
** map keystrokes generated by the browser into the scan codes required
|
** us figure out what browser depenend keycodes match to what scancodes.
|
||||||
** by spice. This table was literally built by me pressing keys on my keyboard
|
**
|
||||||
** and typing the resulting value in by hand.
|
** This will most likely not work for non US keyboard and browsers other than
|
||||||
** I'm sure Europeans will hate me, and the Chinese will likely *never*
|
** modern Chrome and FireFox.
|
||||||
** talk to me.
|
|
||||||
**--------------------------------------------------------------------------*/
|
**--------------------------------------------------------------------------*/
|
||||||
var scanmap = [];
|
var common_scanmap = [];
|
||||||
var codei = 1;
|
common_scanmap['Q'.charCodeAt(0)] = KEY_Q;
|
||||||
scanmap[27] = codei++;
|
common_scanmap['W'.charCodeAt(0)] = KEY_W;
|
||||||
scanmap['1'.charCodeAt(0)] = codei++;
|
common_scanmap['E'.charCodeAt(0)] = KEY_E;
|
||||||
scanmap['2'.charCodeAt(0)] = codei++;
|
common_scanmap['R'.charCodeAt(0)] = KEY_R;
|
||||||
scanmap['3'.charCodeAt(0)] = codei++;
|
common_scanmap['T'.charCodeAt(0)] = KEY_T;
|
||||||
scanmap['4'.charCodeAt(0)] = codei++;
|
common_scanmap['Y'.charCodeAt(0)] = KEY_Y;
|
||||||
scanmap['5'.charCodeAt(0)] = codei++;
|
common_scanmap['U'.charCodeAt(0)] = KEY_U;
|
||||||
scanmap['6'.charCodeAt(0)] = codei++;
|
common_scanmap['I'.charCodeAt(0)] = KEY_I;
|
||||||
scanmap['7'.charCodeAt(0)] = codei++;
|
common_scanmap['O'.charCodeAt(0)] = KEY_O;
|
||||||
scanmap['8'.charCodeAt(0)] = codei++;
|
common_scanmap['P'.charCodeAt(0)] = KEY_P;
|
||||||
scanmap['9'.charCodeAt(0)] = codei++;
|
common_scanmap['A'.charCodeAt(0)] = KEY_A;
|
||||||
scanmap['0'.charCodeAt(0)] = codei++;
|
common_scanmap['S'.charCodeAt(0)] = KEY_S;
|
||||||
scanmap[109] = codei++;
|
common_scanmap['D'.charCodeAt(0)] = KEY_D;
|
||||||
scanmap['='.charCodeAt(0)] = codei++;
|
common_scanmap['F'.charCodeAt(0)] = KEY_F;
|
||||||
scanmap[8] = codei++;
|
common_scanmap['G'.charCodeAt(0)] = KEY_G;
|
||||||
scanmap[9] = codei++;
|
common_scanmap['H'.charCodeAt(0)] = KEY_H;
|
||||||
scanmap['Q'.charCodeAt(0)] = codei++;
|
common_scanmap['J'.charCodeAt(0)] = KEY_J;
|
||||||
scanmap['W'.charCodeAt(0)] = codei++;
|
common_scanmap['K'.charCodeAt(0)] = KEY_K;
|
||||||
scanmap['E'.charCodeAt(0)] = codei++;
|
common_scanmap['L'.charCodeAt(0)] = KEY_L;
|
||||||
scanmap['R'.charCodeAt(0)] = codei++;
|
common_scanmap['Z'.charCodeAt(0)] = KEY_Z;
|
||||||
scanmap['T'.charCodeAt(0)] = codei++;
|
common_scanmap['X'.charCodeAt(0)] = KEY_X;
|
||||||
scanmap['Y'.charCodeAt(0)] = codei++;
|
common_scanmap['C'.charCodeAt(0)] = KEY_C;
|
||||||
scanmap['U'.charCodeAt(0)] = codei++;
|
common_scanmap['V'.charCodeAt(0)] = KEY_V;
|
||||||
scanmap['I'.charCodeAt(0)] = codei++;
|
common_scanmap['B'.charCodeAt(0)] = KEY_B;
|
||||||
scanmap['O'.charCodeAt(0)] = codei++;
|
common_scanmap['N'.charCodeAt(0)] = KEY_N;
|
||||||
scanmap['P'.charCodeAt(0)] = codei++;
|
common_scanmap['M'.charCodeAt(0)] = KEY_M;
|
||||||
scanmap[219] = codei++;
|
common_scanmap[' '.charCodeAt(0)] = KEY_Space;
|
||||||
scanmap[221] = codei++;
|
common_scanmap[13] = KEY_Enter;
|
||||||
scanmap[13] = codei++;
|
common_scanmap[27] = KEY_Escape;
|
||||||
scanmap[17] = codei++;
|
common_scanmap[8] = KEY_BackSpace;
|
||||||
scanmap['A'.charCodeAt(0)] = codei++;
|
common_scanmap[9] = KEY_Tab;
|
||||||
scanmap['S'.charCodeAt(0)] = codei++;
|
common_scanmap[16] = KEY_ShiftL;
|
||||||
scanmap['D'.charCodeAt(0)] = codei++;
|
common_scanmap[17] = KEY_LCtrl;
|
||||||
scanmap['F'.charCodeAt(0)] = codei++;
|
common_scanmap[18] = KEY_Alt;
|
||||||
scanmap['G'.charCodeAt(0)] = codei++;
|
common_scanmap[20] = KEY_CapsLock;
|
||||||
scanmap['H'.charCodeAt(0)] = codei++;
|
common_scanmap[144] = KEY_NumLock;
|
||||||
scanmap['J'.charCodeAt(0)] = codei++;
|
common_scanmap[112] = KEY_F1;
|
||||||
scanmap['K'.charCodeAt(0)] = codei++;
|
common_scanmap[113] = KEY_F2;
|
||||||
scanmap['L'.charCodeAt(0)] = codei++;
|
common_scanmap[114] = KEY_F3;
|
||||||
scanmap[';'.charCodeAt(0)] = codei++;
|
common_scanmap[115] = KEY_F4;
|
||||||
scanmap[222] = codei++;
|
common_scanmap[116] = KEY_F5;
|
||||||
scanmap[192] = codei++;
|
common_scanmap[117] = KEY_F6;
|
||||||
scanmap[16] = codei++;
|
common_scanmap[118] = KEY_F7;
|
||||||
scanmap[220] = codei++;
|
common_scanmap[119] = KEY_F8;
|
||||||
scanmap['Z'.charCodeAt(0)] = codei++;
|
common_scanmap[120] = KEY_F9;
|
||||||
scanmap['X'.charCodeAt(0)] = codei++;
|
common_scanmap[121] = KEY_F10;
|
||||||
scanmap['C'.charCodeAt(0)] = codei++;
|
common_scanmap[122] = KEY_F11;
|
||||||
scanmap['V'.charCodeAt(0)] = codei++;
|
common_scanmap[123] = KEY_F12;
|
||||||
scanmap['B'.charCodeAt(0)] = codei++;
|
|
||||||
scanmap['N'.charCodeAt(0)] = codei++;
|
|
||||||
scanmap['M'.charCodeAt(0)] = codei++;
|
|
||||||
scanmap[188] = codei++;
|
|
||||||
scanmap[190] = codei++;
|
|
||||||
scanmap[191] = codei++;
|
|
||||||
codei++; // right shift seems to be same
|
|
||||||
scanmap[106] = codei++;
|
|
||||||
scanmap[18] = codei++;
|
|
||||||
scanmap[' '.charCodeAt(0)] = codei++;
|
|
||||||
scanmap[20] = codei++;
|
|
||||||
scanmap[112] = codei++;
|
|
||||||
scanmap[113] = codei++;
|
|
||||||
scanmap[114] = codei++;
|
|
||||||
scanmap[115] = codei++;
|
|
||||||
scanmap[116] = codei++;
|
|
||||||
scanmap[117] = codei++;
|
|
||||||
scanmap[118] = codei++;
|
|
||||||
scanmap[119] = codei++;
|
|
||||||
scanmap[120] = codei++;
|
|
||||||
scanmap[121] = codei++;
|
|
||||||
scanmap[144] = codei++;
|
|
||||||
scanmap[145] = codei++; // Scroll lock
|
|
||||||
scanmap[103] = codei++;
|
|
||||||
scanmap[104] = codei++;
|
|
||||||
scanmap[105] = codei++;
|
|
||||||
codei++;// skip minus;
|
|
||||||
scanmap[100] = codei++;
|
|
||||||
scanmap[101] = codei++;
|
|
||||||
scanmap[102] = codei++;
|
|
||||||
scanmap[107] = codei++;
|
|
||||||
scanmap[97] = codei++;
|
|
||||||
scanmap[98] = codei++;
|
|
||||||
scanmap[99] = codei++;
|
|
||||||
scanmap[96] = codei++;
|
|
||||||
scanmap[110] = codei++;
|
|
||||||
|
|
||||||
// F11 + 12 go up at 87/88, after the less
|
/* These externded scancodes do not line up with values from atKeynames */
|
||||||
codei = 87;
|
common_scanmap[42] = 99;
|
||||||
scanmap[122] = codei++;
|
common_scanmap[19] = 101; // Break
|
||||||
scanmap[123] = codei++;
|
common_scanmap[111] = 0xE035; // KP_Divide
|
||||||
|
common_scanmap[106] = 0xE037; // KP_Multiply
|
||||||
|
common_scanmap[36] = 0xE047; // Home
|
||||||
|
common_scanmap[38] = 0xE048; // Up
|
||||||
|
common_scanmap[33] = 0xE049; // PgUp
|
||||||
|
common_scanmap[37] = 0xE04B; // Left
|
||||||
|
common_scanmap[39] = 0xE04D; // Right
|
||||||
|
common_scanmap[35] = 0xE04F; // End
|
||||||
|
common_scanmap[40] = 0xE050; // Down
|
||||||
|
common_scanmap[34] = 0xE051; // PgDown
|
||||||
|
common_scanmap[45] = 0xE052; // Insert
|
||||||
|
common_scanmap[46] = 0xE053; // Delete
|
||||||
|
common_scanmap[44] = 0x2A37; // Print
|
||||||
|
|
||||||
codei = 99;
|
/* These are not common between ALL browsers but are between Firefox and DOM3 */
|
||||||
scanmap[42] = codei++;
|
common_scanmap['1'.charCodeAt(0)] = KEY_1;
|
||||||
codei++; // skip alt
|
common_scanmap['2'.charCodeAt(0)] = KEY_2;
|
||||||
scanmap[19] = codei++; // break
|
common_scanmap['3'.charCodeAt(0)] = KEY_3;
|
||||||
|
common_scanmap['4'.charCodeAt(0)] = KEY_4;
|
||||||
|
common_scanmap['5'.charCodeAt(0)] = KEY_5;
|
||||||
|
common_scanmap['6'.charCodeAt(0)] = KEY_6;
|
||||||
|
common_scanmap['7'.charCodeAt(0)] = KEY_7;
|
||||||
|
common_scanmap['8'.charCodeAt(0)] = KEY_8;
|
||||||
|
common_scanmap['9'.charCodeAt(0)] = KEY_9;
|
||||||
|
common_scanmap['0'.charCodeAt(0)] = KEY_0;
|
||||||
|
common_scanmap[145] = KEY_ScrollLock;
|
||||||
|
common_scanmap[103] = KEY_KP_7;
|
||||||
|
common_scanmap[104] = KEY_KP_8;
|
||||||
|
common_scanmap[105] = KEY_KP_9;
|
||||||
|
common_scanmap[100] = KEY_KP_4;
|
||||||
|
common_scanmap[101] = KEY_KP_5;
|
||||||
|
common_scanmap[102] = KEY_KP_6;
|
||||||
|
common_scanmap[107] = KEY_KP_Plus;
|
||||||
|
common_scanmap[97] = KEY_KP_1;
|
||||||
|
common_scanmap[98] = KEY_KP_2;
|
||||||
|
common_scanmap[99] = KEY_KP_3;
|
||||||
|
common_scanmap[96] = KEY_KP_0;
|
||||||
|
common_scanmap[110] = KEY_KP_Decimal;
|
||||||
|
common_scanmap[191] = KEY_Slash;
|
||||||
|
common_scanmap[190] = KEY_Period;
|
||||||
|
common_scanmap[188] = KEY_Comma;
|
||||||
|
common_scanmap[220] = KEY_BSlash;
|
||||||
|
common_scanmap[192] = KEY_Tilde;
|
||||||
|
common_scanmap[222] = KEY_Quote;
|
||||||
|
common_scanmap[219] = KEY_LBrace;
|
||||||
|
common_scanmap[221] = KEY_RBrace;
|
||||||
|
|
||||||
scanmap[36] = codei++; // home
|
common_scanmap[91] = 0xE05B; //KEY_LMeta
|
||||||
scanmap[38] = codei++; // up
|
common_scanmap[92] = 0xE05C; //KEY_RMeta
|
||||||
scanmap[33] = codei++; // page up
|
common_scanmap[93] = 0xE05D; //KEY_Menu
|
||||||
scanmap[37] = codei++; // left
|
|
||||||
scanmap[39] = codei++; // right
|
/* Firefox/Mozilla codes */
|
||||||
scanmap[35] = codei++; // end
|
var firefox_scanmap = [];
|
||||||
scanmap[40] = codei++; // down
|
firefox_scanmap[109] = KEY_Minus;
|
||||||
scanmap[34] = codei++; // page down
|
firefox_scanmap[61] = KEY_Equal;
|
||||||
scanmap[45] = codei++; // insert
|
firefox_scanmap[59] = KEY_SemiColon;
|
||||||
scanmap[46] = codei++; // delete
|
|
||||||
|
/* DOM3 codes */
|
||||||
|
var DOM_scanmap = [];
|
||||||
|
DOM_scanmap[189] = KEY_Minus;
|
||||||
|
DOM_scanmap[187] = KEY_Equal;
|
||||||
|
DOM_scanmap[186] = KEY_SemiColon;
|
||||||
|
|
||||||
|
function get_scancode(code)
|
||||||
|
{
|
||||||
|
if (common_scanmap[code] === undefined)
|
||||||
|
{
|
||||||
|
if (navigator.userAgent.indexOf("Firefox") != -1)
|
||||||
|
return firefox_scanmap[code];
|
||||||
|
else
|
||||||
|
return DOM_scanmap[code];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return common_scanmap[code];
|
||||||
|
}
|
||||||
|
|
||||||
function keycode_to_start_scan(code)
|
function keycode_to_start_scan(code)
|
||||||
{
|
{
|
||||||
if (scanmap[code] === undefined)
|
var scancode = get_scancode(code);
|
||||||
|
if (scancode === undefined)
|
||||||
{
|
{
|
||||||
alert('no map for ' + code);
|
alert('no map for ' + code);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scanmap[code] < 0x100) {
|
if (scancode < 0x100) {
|
||||||
return scanmap[code];
|
return scancode;
|
||||||
} else {
|
} else {
|
||||||
return 0xe0 | ((scanmap[code] - 0x100) << 8);
|
return 0xe0 | ((scancode - 0x100) << 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function keycode_to_end_scan(code)
|
function keycode_to_end_scan(code)
|
||||||
{
|
{
|
||||||
if (scanmap[code] === undefined)
|
var scancode = get_scancode(code);
|
||||||
|
if (scancode === undefined)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (scanmap[code] < 0x100) {
|
if (scancode < 0x100) {
|
||||||
return scanmap[code] | 0x80;
|
return scancode | 0x80;
|
||||||
} else {
|
} else {
|
||||||
return 0x80e0 | ((scanmap[code] - 0x100) << 8);
|
return 0x80e0 | ((scancode - 0x100) << 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user