Fix: change key input value -> keyCode

This commit is contained in:
2018-06-13 23:05:39 +09:00
parent dc957debe9
commit eb497f59c8
6 changed files with 370 additions and 281 deletions
+26 -26
View File
@@ -3,34 +3,34 @@ class EnglishKeyMapper extends KeyMapper {
constructor() { constructor() {
super(); super();
this.registerKeyTextData("q", "q", "Q", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyQ", "q", "Q");
this.registerKeyTextData("w", "w", "W", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyW", "w", "W");
this.registerKeyTextData("e", "e", "E", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyE", "e", "E");
this.registerKeyTextData("r", "r", "R", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyR", "r", "R");
this.registerKeyTextData("t", "t", "T", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyT", "t", "T");
this.registerKeyTextData("y", "y", "Y", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyY", "y", "Y");
this.registerKeyTextData("u", "u", "U", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyU", "u", "U");
this.registerKeyTextData("i", "i", "I", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyI", "i", "I");
this.registerKeyTextData("o", "o", "O", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyO", "o", "O");
this.registerKeyTextData("p", "p", "P", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyP", "p", "P");
this.registerKeyTextData("a", "a", "A", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyA", "a", "A");
this.registerKeyTextData("s", "s", "S", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyS", "s", "S");
this.registerKeyTextData("d", "d", "D", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyD", "d", "D");
this.registerKeyTextData("f", "f", "F", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyF", "f", "F");
this.registerKeyTextData("g", "g", "G", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyG", "g", "G");
this.registerKeyTextData("h", "h", "H", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyH", "h", "H");
this.registerKeyTextData("j", "j", "J", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyJ", "j", "J");
this.registerKeyTextData("k", "k", "K", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyK", "k", "K");
this.registerKeyTextData("l", "l", "L", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyL", "l", "L");
this.registerKeyTextData("z", "z", "Z", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyZ", "z", "Z");
this.registerKeyTextData("x", "x", "X", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyX", "x", "X");
this.registerKeyTextData("c", "c", "C", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyC", "c", "C");
this.registerKeyTextData("v", "v", "V", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyV", "v", "V");
this.registerKeyTextData("b", "b", "B", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyB", "b", "B");
this.registerKeyTextData("n", "n", "N", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyN", "n", "N");
this.registerKeyTextData("m", "m", "M", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyM", "m", "M");
} }
} }
+103 -60
View File
@@ -11,68 +11,21 @@ class KeyButton {
this.setting.strokeWidthPx = 2; this.setting.strokeWidthPx = 2;
this.buttonSolid = this.makeButtonSolidSprite(this.setting); this.buttonSolid = this.makeButtonSolidSprite(this.setting);
if(handSide == KeyButton.LEFT_HAND) this.setNormalColor();
this.setNormalColor();
else
this.setPressedColor();
this.buttonStroke = this.makeButtonStrokeSprite(this.setting); this.buttonStroke = this.makeButtonStrokeSprite(this.setting);
this.baselineStroke = null;
if(fingerType == KeyButton.INDEX_FINGER_BASELINE) {
this.baselineStroke = this.makeBaselineStrokeSprite(this.setting, width, height);
this.buttonStroke.addChild(this.baselineStroke);
}
this.buttonText = this.makeText(this.setting, this.normalText); this.buttonText = this.makeText(this.setting, this.normalText);
if(this.normalText.length > 0) { if(this.normalText.length > 0) {
this.buttonStroke.addChild(this.buttonText); this.buttonStroke.addChild(this.buttonText);
} }
} }
setNormalColor() {
switch(this.fingerType) {
case KeyButton.THUMB:
this.buttonSolid.tint = 0x604d4d;
break;
case KeyButton.INDEX_FINGER:
this.buttonSolid.tint = 0x4d604d;
break;
case KeyButton.MIDDLE_FINGER:
this.buttonSolid.tint = 0x4d4d60;
break;
case KeyButton.RING_FINGER:
this.buttonSolid.tint = 0x60604d;
break;
case KeyButton.LITTLE_FINGER:
this.buttonSolid.tint = 0x4d6060;
break;
}
}
setPressedColor() {
switch(this.fingerType) {
case KeyButton.THUMB:
this.buttonSolid.tint = 0xff8080;
break;
case KeyButton.INDEX_FINGER:
this.buttonSolid.tint = 0x80ff80;
break;
case KeyButton.MIDDLE_FINGER:
this.buttonSolid.tint = 0x8080ff;
break;
case KeyButton.RING_FINGER:
this.buttonSolid.tint = 0xffff80;
break;
case KeyButton.LITTLE_FINGER:
this.buttonSolid.tint = 0x80ffff;
break;
}
}
makeButtonSolidSprite(setting) { makeButtonSolidSprite(setting) {
let btnTexture = new Phaser.Graphics() let btnTexture = new Phaser.Graphics()
.beginFill(0xffffff, 0.5) .beginFill(0xffffff, 0.5)
@@ -101,6 +54,27 @@ class KeyButton {
); );
} }
makeBaselineStrokeSprite(setting, width, height) {
let strokePx = setting.strokeWidthPx;
let baselineTexture = new Phaser.Graphics()
.lineStyle(2, 0x888888)
.moveTo(1, 1)
.lineTo(16, 1)
.lineStyle(2, 0xffffff)
.moveTo(0, 0)
.lineTo(15, 0)
.generateTexture();
let baselineSprite = game.add.sprite(
strokePx + setting.width / 2,
strokePx + setting.height - 6,
baselineTexture
);
baselineSprite.anchor.set(0.5);
return baselineSprite;
}
makeText(setting, textContent) { makeText(setting, textContent) {
let offsetX_px = 4; let offsetX_px = 4;
let offsetY_px = 5; let offsetY_px = 5;
@@ -138,6 +112,72 @@ class KeyButton {
} }
setNormalColor() {
switch(this.fingerType) {
case KeyButton.THUMB:
this.buttonSolid.tint = 0x604d4d;
break;
case KeyButton.INDEX_FINGER:
case KeyButton.INDEX_FINGER_BASELINE:
this.buttonSolid.tint = 0x4d604d;
break;
case KeyButton.MIDDLE_FINGER:
this.buttonSolid.tint = 0x4d4d60;
break;
case KeyButton.RING_FINGER:
this.buttonSolid.tint = 0x60604d;
break;
case KeyButton.LITTLE_FINGER:
this.buttonSolid.tint = 0x4d6060;
break;
default:
this.buttonSolid.tint = 0x4d4d4d;
// this.buttonSolid.alpha = 0;
}
}
setTargetColor() {
switch(this.fingerType) {
case KeyButton.THUMB:
this.buttonSolid.tint = 0xff8080;
break;
case KeyButton.INDEX_FINGER:
case KeyButton.INDEX_FINGER_BASELINE:
this.buttonSolid.tint = 0x80ff80;
break;
case KeyButton.MIDDLE_FINGER:
this.buttonSolid.tint = 0x8080ff;
break;
case KeyButton.RING_FINGER:
this.buttonSolid.tint = 0xffff80;
break;
case KeyButton.LITTLE_FINGER:
this.buttonSolid.tint = 0x80ffff;
break;
default:
this.buttonSolid.tint = 0x202020;
// this.buttonSolid.alpha = 0;
}
}
setGoodPressColor() {
this.buttonSolid.tint = 0x0000ff;
}
setBadPressColor() {
this.buttonSolid.tint = 0xff0000;
}
onShiftPressed() { onShiftPressed() {
this.buttonText.text = this.shiftText; this.buttonText.text = this.shiftText;
@@ -148,7 +188,7 @@ class KeyButton {
} }
/*
mouseOut() { mouseOut() {
this.text.fill = this.setting.textColors.out; this.text.fill = this.setting.textColors.out;
this.buttonStroke.tint = this.setting.strokeColors.out; this.buttonStroke.tint = this.setting.strokeColors.out;
@@ -184,6 +224,7 @@ class KeyButton {
this.buttonIcon.tint = this.setting.strokeColors.disabled; this.buttonIcon.tint = this.setting.strokeColors.disabled;
} }
} }
*/
} }
@@ -204,8 +245,10 @@ KeyButton.LEFT_HAND = 1;
KeyButton.RIGHT_HAND = 2; KeyButton.RIGHT_HAND = 2;
KeyButton.BOTH_HAND = 3; KeyButton.BOTH_HAND = 3;
KeyButton.THUMB = 0; KeyButton.NONE_FINGER = 0;
KeyButton.INDEX_FINGER = 1; KeyButton.THUMB = 1;
KeyButton.MIDDLE_FINGER = 2; KeyButton.INDEX_FINGER = 2;
KeyButton.RING_FINGER = 3; KeyButton.INDEX_FINGER_BASELINE = 3;
KeyButton.LITTLE_FINGER = 4; KeyButton.MIDDLE_FINGER = 4;
KeyButton.RING_FINGER = 5;
KeyButton.LITTLE_FINGER = 5;
+52 -38
View File
@@ -1,9 +1,8 @@
class KeyTextData { class KeyTextData {
constructor(normalText, shiftText, shiftHandSide) { constructor(normalText, shiftText) {
this.normalText = normalText; this.normalText = normalText;
this.shiftText = shiftText; this.shiftText = shiftText;
this.shiftHandSide = shiftHandSide;
} }
} }
@@ -14,50 +13,54 @@ class KeyMapper {
this.keyboardKeyMap = {}; this.keyboardKeyMap = {};
this.inputKeyMap = {}; this.inputKeyMap = {};
this.registerKeyTextData("`", "`", "~", KeyTextData.RIGHT_HAND); this.registerKeyTextData("Backquote", "`", "~");
this.registerKeyTextData("1", "1", "!", KeyTextData.RIGHT_HAND); this.registerKeyTextData("Digit1", "1", "!");
this.registerKeyTextData("2", "2", "@", KeyTextData.RIGHT_HAND); this.registerKeyTextData("Digit2", "2", "@");
this.registerKeyTextData("3", "3", "#", KeyTextData.RIGHT_HAND); this.registerKeyTextData("Digit3", "3", "#");
this.registerKeyTextData("4", "4", "$", KeyTextData.RIGHT_HAND); this.registerKeyTextData("Digit4", "4", "$");
this.registerKeyTextData("5", "5", "%", KeyTextData.RIGHT_HAND); this.registerKeyTextData("Digit5", "5", "%");
this.registerKeyTextData("6", "6", "^", KeyTextData.LEFT_HAND); this.registerKeyTextData("Digit6", "6", "^");
this.registerKeyTextData("7", "7", "&", KeyTextData.LEFT_HAND); this.registerKeyTextData("Digit7", "7", "&");
this.registerKeyTextData("8", "8", "*", KeyTextData.LEFT_HAND); this.registerKeyTextData("Digit8", "8", "*");
this.registerKeyTextData("9", "9", "(", KeyTextData.LEFT_HAND); this.registerKeyTextData("Digit9", "9", "(");
this.registerKeyTextData("0", "0", ")", KeyTextData.LEFT_HAND); this.registerKeyTextData("Digit0", "0", ")");
this.registerKeyTextData("-", "-", "_", KeyTextData.LEFT_HAND); this.registerKeyTextData("Minus", "-", "_");
this.registerKeyTextData("=", "=", "+", KeyTextData.LEFT_HAND); this.registerKeyTextData("Equal", "=", "+");
this.registerKeyTextData("backspace", "backspace", "backspace", KeyTextData.NONE_HAND); this.registerKeyTextData("Backspace", "backspace", "backspace");
this.registerKeyTextData("tab", "tab", "tab", KeyTextData.NONE_HAND); this.registerKeyTextData("Tab", "tab", "tab");
this.registerKeyTextData("[", "[", "{", KeyTextData.LEFT_HAND); this.registerKeyTextData("BracketLeft", "[", "{");
this.registerKeyTextData("]", "]", "}", KeyTextData.LEFT_HAND); this.registerKeyTextData("BracketRight", "]", "}");
this.registerKeyTextData("\\", "\\", "|", KeyTextData.LEFT_HAND); this.registerKeyTextData("Backslash", "\\", "|");
this.registerKeyTextData("caps_lock", "caps lock", "caps lock", KeyTextData.NONE_HAND); this.registerKeyTextData("CapsLock", "caps lock", "caps lock");
this.registerKeyTextData(";", ";", ":", KeyTextData.LEFT_HAND); this.registerKeyTextData("Semicolon", ";", ":");
this.registerKeyTextData("'", "'", "\"", KeyTextData.LEFT_HAND); this.registerKeyTextData("Quote", "'", "\"");
this.registerKeyTextData("enter", "enter", "enter", KeyTextData.NONE_HAND); this.registerKeyTextData("Enter", "enter", "enter");
this.registerKeyTextData("left_shift", "left_shift", "left_shift", KeyTextData.LEFT_HAND); this.registerKeyTextData("ShiftLeft", "left_shift", "left_shift");
this.registerKeyTextData("right_shift", "right_shift", "right_shift", KeyTextData.RIGHT_HAND); this.registerKeyTextData("ShiftRight", "right_shift", "right_shift");
this.registerKeyTextData(",", ",", "<", KeyTextData.LEFT_HAND); this.registerKeyTextData("Comma", ",", "<");
this.registerKeyTextData(".", ".", ">", KeyTextData.LEFT_HAND); this.registerKeyTextData("Period", ".", ">");
this.registerKeyTextData("/", "/", "?", KeyTextData.LEFT_HAND); this.registerKeyTextData("Slash", "/", "?");
this.registerKeyTextData("left_ctrl", "ctrl", "ctrl", KeyTextData.NONE_HAND); this.registerKeyTextData("ControlLeft", "ctrl", "ctrl");
this.registerKeyTextData("window", "window", "window", KeyTextData.NONE_HAND); this.registerKeyTextData("window", "window", "window");
this.registerKeyTextData("left_alt", "alt", "alt", KeyTextData.NONE_HAND); this.registerKeyTextData("AltLeft", "alt", "alt");
this.registerKeyTextData("chinese", "한자", "한자", KeyTextData.NONE_HAND); this.registerKeyTextData("chinese", "한자", "한자");
this.registerKeyTextData("space", "space", "space", KeyTextData.BOTH_HAND); this.registerKeyTextData("Space", "space", "space");
this.registerKeyTextData("korean_english", "한/영", "한/영", KeyTextData.NONE_HAND); this.registerKeyTextData("korean_english", "한/영", "한/영");
this.registerKeyTextData("right_alt", "alt", "alt", KeyTextData.NONE_HAND); this.registerKeyTextData("AltRight", "alt", "alt");
this.registerKeyTextData("right_ctrl", "ctrl", "ctrl", KeyTextData.NONE_HAND); this.registerKeyTextData("ControlRight", "ctrl", "ctrl");
console.log(this.keyboardKeyMap);
} }
registerKeyTextData(keyID, normalText, shiftText, shiftHandSide) { registerKeyTextData(keyID, normalText, shiftText, shiftHandSide) {
this.keyboardKeyMap[keyID] = new KeyTextData(normalText, shiftText, shiftHandSide); this.keyboardKeyMap[keyID] = new KeyTextData(normalText, shiftText, shiftHandSide);
if(this.inputKeyMap[keyID] === undefined)
this.inputKeyMap[keyID] = keyID;
if(this.inputKeyMap[normalText] === undefined) if(this.inputKeyMap[normalText] === undefined)
this.inputKeyMap[normalText] = keyID; this.inputKeyMap[normalText] = keyID;
if(this.inputKeyMap[shiftText] === undefined) if(this.inputKeyMap[shiftText] === undefined)
@@ -66,15 +69,26 @@ class KeyMapper {
getNormalText(keyID) { getNormalText(keyID) {
// console.log(this.keyboardKeyMap[keyID]); if(this.keyboardKeyMap[keyID] === undefined) {
console.log(keyID);
return "?";
}
return this.keyboardKeyMap[keyID].normalText; return this.keyboardKeyMap[keyID].normalText;
} }
getShiftText(keyID) { getShiftText(keyID) {
if(this.keyboardKeyMap[keyID] === undefined) {
console.log(keyID);
return "?";
}
return this.keyboardKeyMap[keyID].shiftText; return this.keyboardKeyMap[keyID].shiftText;
} }
getShiftHandSide(keyID) { getShiftHandSide(keyID) {
if(this.keyboardKeyMap[keyID] === undefined) {
console.log(keyID);
return "?";
}
return this.keyboardKeyMap[keyID].shiftHandSide; return this.keyboardKeyMap[keyID].shiftHandSide;
} }
+131 -101
View File
@@ -1,19 +1,24 @@
class Keyboard { class Keyboard {
constructor(keyMapper) { constructor(keyMapper) {
// let keyButton = new KeyButton(100, 400, 100, "A", "align_type"); this.keyMapper = keyMapper;
// let keyData = this.getKeyBoardData(keyMapper);
this.keyIndex = 0; this.keyIndex = 0;
this.keyDataList = []; this.keyDataList = [];
this.keyList = []; this.keyList = [];
this.keyHash = {};
this.allKeyHash = {};
this.normalKeyHash = {};
this.keyUpReservations = [];
game.input.keyboard.addCallbacks(this, this.keyDown, this.keyUp, null);
let shiftKey = game.input.keyboard.addKey(Phaser.KeyCode.SHIFT); let shiftKey = game.input.keyboard.addKey(Phaser.KeyCode.SHIFT);
shiftKey.onDown.add(this.shifted, this); shiftKey.onDown.add(this.shifted, this);
shiftKey.onUp.add(this.unshifted, this); shiftKey.onUp.add(this.unshifted, this);
this.initKeyData(keyMapper); this.initKeyData();
for(let i = 0; i < this.keyDataList.length; i++) { for(let i = 0; i < this.keyDataList.length; i++) {
this.keyList[i] = new KeyButton( this.keyList[i] = new KeyButton(
@@ -27,9 +32,46 @@ class Keyboard {
this.keyDataList[i].fingerType, this.keyDataList[i].fingerType,
this.keyDataList[i].alignType, this.keyDataList[i].alignType,
); );
this.allKeyHash[this.keyDataList[i].keyID] = this.keyList[i];
} }
} }
keyDown(char) {
let keyCode = char.code;
this.setPressedSprite(keyCode);
}
setPressedSprite(keyCode) {
let keyID = this.keyMapper.getKeyIDOfText(keyCode);
let key = this.allKeyHash[keyID];
if(key !== undefined) {
if(keyCode === "Tab" || keyCode === "CapsLock" || keyCode === "MetaLeft" || keyCode === "MetaRight") {
// game.time.events.add(Phaser.Timer.SECOND, () => this.onKeyUp(key), this);
console.log(keyCode + " is pressed but not show");
return;
}
key.setTargetColor();
} else {
console.log(keyCode+ " is pressed but not registered to KeyMapper");
}
}
keyUp(char) {
let keyCode = char.code;
this.setNormalSprite(keyCode);
}
setNormalSprite(keyCode) {
let keyID = this.keyMapper.getKeyIDOfText(keyCode);
let key = this.allKeyHash[keyID];
if(key !== undefined)
key.setNormalColor();
}
shifted() { shifted() {
for(let i = 0; i < this.keyDataList.length; i++) { for(let i = 0; i < this.keyDataList.length; i++) {
this.keyList[i].onShiftPressed(); this.keyList[i].onShiftPressed();
@@ -51,8 +93,9 @@ class Keyboard {
} }
makeKeyDataObject(normalText, shiftText, handSide, fingerType, x, y, width, height, alignType) { makeKeyDataObject(keyID, normalText, shiftText, handSide, fingerType, x, y, width, height, alignType) {
let keyDataObject = {}; let keyDataObject = {};
keyDataObject.keyID = keyID;
keyDataObject.normalText = normalText; keyDataObject.normalText = normalText;
keyDataObject.shiftText = shiftText; keyDataObject.shiftText = shiftText;
keyDataObject.handSide = handSide; keyDataObject.handSide = handSide;
@@ -66,8 +109,9 @@ class Keyboard {
return keyDataObject; return keyDataObject;
} }
makeNextNormalKeyDataObject(prevKeyData, normalText, shiftText, handSide, fingerType) { makeNextNormalKeyDataObject(keyID, prevKeyData, normalText, shiftText, handSide, fingerType) {
return this.makeKeyDataObject( return this.makeKeyDataObject(
keyID,
normalText, normalText,
shiftText, shiftText,
handSide, handSide,
@@ -81,11 +125,12 @@ class Keyboard {
} }
addFunctionKeyData(keyMapper, keyID, handSide, fingerType, x, y, width, height, type) { addFunctionKeyData(keyID, handSide, fingerType, x, y, width, height, type) {
let normalText = keyMapper.getNormalText(keyID); let normalText = this.keyMapper.getNormalText(keyID);
let shiftText = keyMapper.getShiftText(keyID); let shiftText = this.keyMapper.getShiftText(keyID);
let newKey = this.makeKeyDataObject( let newKey = this.makeKeyDataObject(
keyID,
normalText, shiftText, normalText, shiftText,
handSide, fingerType, handSide, fingerType,
x, y, x, y,
@@ -94,16 +139,15 @@ class Keyboard {
); );
this.keyDataList[this.keyIndex] = newKey; this.keyDataList[this.keyIndex] = newKey;
this.keyIndex++; this.keyIndex++;
this.keyHash[keyID] = newKey;
} }
addNextFunctionKeyData(keyMapper, keyID, handSide, fingerType, width, height, type) { addNextFunctionKeyData(keyID, handSide, fingerType, width, height, type) {
let prevKey = this.keyDataList[this.keyIndex - 1]; let prevKey = this.keyDataList[this.keyIndex - 1];
let normalText = keyMapper.getNormalText(keyID); let normalText = this.keyMapper.getNormalText(keyID);
let shiftText = keyMapper.getShiftText(keyID); let shiftText = this.keyMapper.getShiftText(keyID);
let newKey = this.makeKeyDataObject( let newKey = this.makeKeyDataObject(
keyID,
normalText, shiftText, normalText, shiftText,
handSide, fingerType, handSide, fingerType,
prevKey.x + prevKey.width + Keyboard.KEY_GAP_PX, prevKey.y, prevKey.x + prevKey.width + Keyboard.KEY_GAP_PX, prevKey.y,
@@ -113,15 +157,16 @@ class Keyboard {
this.keyDataList[this.keyIndex] = newKey; this.keyDataList[this.keyIndex] = newKey;
this.keyIndex++; this.keyIndex++;
this.keyHash[keyID] = newKey; // this.normalKeyHash[keyID] = newKey;
} }
addNextNormalKeyData(keyMapper, keyID, handSide, fingerType) { addNextNormalKeyData(keyID, handSide, fingerType) {
let prevKey = this.keyDataList[this.keyIndex - 1]; let prevKey = this.keyDataList[this.keyIndex - 1];
let normalText = keyMapper.getNormalText(keyID); let normalText = this.keyMapper.getNormalText(keyID);
let shiftText = keyMapper.getShiftText(keyID); let shiftText = this.keyMapper.getShiftText(keyID);
let newKey = this.makeNextNormalKeyDataObject( let newKey = this.makeNextNormalKeyDataObject(
keyID,
prevKey, prevKey,
normalText, shiftText, normalText, shiftText,
handSide, fingerType handSide, fingerType
@@ -129,7 +174,7 @@ class Keyboard {
this.keyDataList[this.keyIndex] = newKey; this.keyDataList[this.keyIndex] = newKey;
this.keyIndex++; this.keyIndex++;
this.keyHash[keyID] = newKey; this.normalKeyHash[keyID] = newKey;
} }
@@ -137,8 +182,7 @@ class Keyboard {
initKeyData(keyMapper) { initKeyData(keyMapper) {
// row 1 // row 1
this.addFunctionKeyData( this.addFunctionKeyData(
keyMapper, "Backquote",
"`",
KeyButton.LEFT_HAND, KeyButton.LEFT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.LITTLE_FINGER,
Keyboard.KEYBOARD_OFFSET__POX_X, Keyboard.KEYBOARD_OFFSET__POX_X,
@@ -147,21 +191,20 @@ class Keyboard {
Keyboard.DEFAULT_KEY_SIZE_PX, Keyboard.DEFAULT_KEY_SIZE_PX,
KeyButton.NORMAL_FUNCTION_KEY KeyButton.NORMAL_FUNCTION_KEY
); );
this.addNextNormalKeyData(keyMapper, "1", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("Digit1", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER);
this.addNextNormalKeyData(keyMapper, "2", KeyButton.LEFT_HAND, KeyButton.RING_FINGER); this.addNextNormalKeyData("Digit2", KeyButton.LEFT_HAND, KeyButton.RING_FINGER);
this.addNextNormalKeyData(keyMapper, "3", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER); this.addNextNormalKeyData("Digit3", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER);
this.addNextNormalKeyData(keyMapper, "4", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("Digit4", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "5", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("Digit5", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "6", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("Digit6", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "7", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("Digit7", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "8", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER); this.addNextNormalKeyData("Digit8", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER);
this.addNextNormalKeyData(keyMapper, "9", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER); this.addNextNormalKeyData("Digit9", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER);
this.addNextNormalKeyData(keyMapper, "0", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("Digit0", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
this.addNextNormalKeyData(keyMapper, "-", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("Minus", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
this.addNextNormalKeyData(keyMapper, "=", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("Equal", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
this.addNextFunctionKeyData( this.addNextFunctionKeyData(
keyMapper, "Backspace",
"backspace",
KeyButton.RIGHT_HAND, KeyButton.RIGHT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.LITTLE_FINGER,
Keyboard.BACKSPACE_KEY_WIDTH_PX, Keyboard.BACKSPACE_KEY_WIDTH_PX,
@@ -171,56 +214,53 @@ class Keyboard {
// row 2 // row 2
this.addFunctionKeyData( this.addFunctionKeyData(
keyMapper, "Tab",
"tab",
KeyButton.LEFT_HAND, KeyButton.LEFT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.NONE_FINGER,
Keyboard.KEYBOARD_OFFSET__POX_X, Keyboard.KEYBOARD_OFFSET__POX_X,
Keyboard.ROW_2_POX_Y, Keyboard.ROW_2_POX_Y,
Keyboard.TAB_KEY_WIDTH_PX, Keyboard.TAB_KEY_WIDTH_PX,
Keyboard.DEFAULT_KEY_SIZE_PX, Keyboard.DEFAULT_KEY_SIZE_PX,
KeyButton.LEFT_FUNCTION_KEY KeyButton.LEFT_FUNCTION_KEY
); );
this.addNextNormalKeyData(keyMapper, "q", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("KeyQ", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER);
this.addNextNormalKeyData(keyMapper, "w", KeyButton.LEFT_HAND, KeyButton.RING_FINGER); this.addNextNormalKeyData("KeyW", KeyButton.LEFT_HAND, KeyButton.RING_FINGER);
this.addNextNormalKeyData(keyMapper, "e", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER); this.addNextNormalKeyData("KeyE", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER);
this.addNextNormalKeyData(keyMapper, "r", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("KeyR", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "t", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("KeyT", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "y", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("KeyY", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "u", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("KeyU", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "i", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER); this.addNextNormalKeyData("KeyI", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER);
this.addNextNormalKeyData(keyMapper, "o", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER); this.addNextNormalKeyData("KeyO", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER);
this.addNextNormalKeyData(keyMapper, "p", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("KeyP", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
this.addNextNormalKeyData(keyMapper, "[", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("BracketLeft", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
this.addNextNormalKeyData(keyMapper, "]", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("BracketRight", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
this.addNextNormalKeyData(keyMapper, "\\", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("Backslash", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
// row 3 // row 3
this.addFunctionKeyData( this.addFunctionKeyData(
keyMapper, "CapsLock",
"caps_lock",
KeyButton.LEFT_HAND, KeyButton.LEFT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.NONE_FINGER,
Keyboard.KEYBOARD_OFFSET__POX_X, Keyboard.KEYBOARD_OFFSET__POX_X,
Keyboard.ROW_3_POX_Y, Keyboard.ROW_3_POX_Y,
Keyboard.CAPS_LOCK_KEY_WIDTH_PX, Keyboard.CAPS_LOCK_KEY_WIDTH_PX,
Keyboard.DEFAULT_KEY_SIZE_PX, Keyboard.DEFAULT_KEY_SIZE_PX,
KeyButton.LEFT_FUNCTION_KEY KeyButton.LEFT_FUNCTION_KEY
); );
this.addNextNormalKeyData(keyMapper, "a", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("KeyA", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER);
this.addNextNormalKeyData(keyMapper, "s", KeyButton.LEFT_HAND, KeyButton.RING_FINGER); this.addNextNormalKeyData("KeyS", KeyButton.LEFT_HAND, KeyButton.RING_FINGER);
this.addNextNormalKeyData(keyMapper, "d", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER); this.addNextNormalKeyData("KeyD", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER);
this.addNextNormalKeyData(keyMapper, "f", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("KeyF", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER_BASELINE);
this.addNextNormalKeyData(keyMapper, "g", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("KeyG", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "h", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("KeyH", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "j", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("KeyJ", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER_BASELINE);
this.addNextNormalKeyData(keyMapper, "k", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER); this.addNextNormalKeyData("KeyK", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER);
this.addNextNormalKeyData(keyMapper, "l", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER); this.addNextNormalKeyData("KeyL", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER);
this.addNextNormalKeyData(keyMapper, ";", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("Semicolon", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
this.addNextNormalKeyData(keyMapper, "'", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("Quote", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
this.addNextFunctionKeyData( this.addNextFunctionKeyData(
keyMapper, "Enter",
"enter",
KeyButton.RIGHT_HAND, KeyButton.RIGHT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.LITTLE_FINGER,
Keyboard.ENTER_KEY_WIDTH_PX, Keyboard.ENTER_KEY_WIDTH_PX,
@@ -230,8 +270,7 @@ class Keyboard {
// row 4 // row 4
this.addFunctionKeyData( this.addFunctionKeyData(
keyMapper, "ShiftLeft",
"left_shift",
KeyButton.LEFT_HAND, KeyButton.LEFT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.LITTLE_FINGER,
Keyboard.KEYBOARD_OFFSET__POX_X, Keyboard.KEYBOARD_OFFSET__POX_X,
@@ -240,19 +279,18 @@ class Keyboard {
Keyboard.DEFAULT_KEY_SIZE_PX, Keyboard.DEFAULT_KEY_SIZE_PX,
KeyButton.LEFT_FUNCTION_KEY KeyButton.LEFT_FUNCTION_KEY
); );
this.addNextNormalKeyData(keyMapper, "z", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("KeyZ", KeyButton.LEFT_HAND, KeyButton.LITTLE_FINGER);
this.addNextNormalKeyData(keyMapper, "x", KeyButton.LEFT_HAND, KeyButton.RING_FINGER); this.addNextNormalKeyData("KeyX", KeyButton.LEFT_HAND, KeyButton.RING_FINGER);
this.addNextNormalKeyData(keyMapper, "c", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER); this.addNextNormalKeyData("KeyC", KeyButton.LEFT_HAND, KeyButton.MIDDLE_FINGER);
this.addNextNormalKeyData(keyMapper, "v", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("KeyV", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "b", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("KeyB", KeyButton.LEFT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "n", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("KeyN", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, "m", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER); this.addNextNormalKeyData("KeyM", KeyButton.RIGHT_HAND, KeyButton.INDEX_FINGER);
this.addNextNormalKeyData(keyMapper, ",", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER); this.addNextNormalKeyData("Comma", KeyButton.RIGHT_HAND, KeyButton.MIDDLE_FINGER);
this.addNextNormalKeyData(keyMapper, ".", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER); this.addNextNormalKeyData("Period", KeyButton.RIGHT_HAND, KeyButton.RING_FINGER);
this.addNextNormalKeyData(keyMapper, "/", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER); this.addNextNormalKeyData("Slash", KeyButton.RIGHT_HAND, KeyButton.LITTLE_FINGER);
this.addNextFunctionKeyData( this.addNextFunctionKeyData(
keyMapper, "ShiftRight",
"right_shift",
KeyButton.RIGHT_HAND, KeyButton.RIGHT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.LITTLE_FINGER,
Keyboard.SHIFT_KEY_WIDTH_PX, Keyboard.SHIFT_KEY_WIDTH_PX,
@@ -262,10 +300,9 @@ class Keyboard {
// row 5 // row 5
this.addFunctionKeyData( this.addFunctionKeyData(
keyMapper, "ControlLeft",
"left_ctrl",
KeyButton.LEFT_HAND, KeyButton.LEFT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.NONE_FINGER,
Keyboard.KEYBOARD_OFFSET__POX_X, Keyboard.KEYBOARD_OFFSET__POX_X,
Keyboard.ROW_5_POX_Y, Keyboard.ROW_5_POX_Y,
Keyboard.CTRL_KEY_WIDTH_PX, Keyboard.CTRL_KEY_WIDTH_PX,
@@ -273,35 +310,31 @@ class Keyboard {
KeyButton.LEFT_FUNCTION_KEY KeyButton.LEFT_FUNCTION_KEY
); );
this.addNextFunctionKeyData( this.addNextFunctionKeyData(
keyMapper,
"window", "window",
KeyButton.LEFT_HAND, KeyButton.LEFT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.NONE_FINGER,
Keyboard.WINDOW_KEY_WIDTH_PX, Keyboard.WINDOW_KEY_WIDTH_PX,
Keyboard.DEFAULT_KEY_SIZE_PX, Keyboard.DEFAULT_KEY_SIZE_PX,
KeyButton.LEFT_FUNCTION_KEY KeyButton.LEFT_FUNCTION_KEY
); );
this.addNextFunctionKeyData( this.addNextFunctionKeyData(
keyMapper, "AltLeft",
"left_alt",
KeyButton.LEFT_HAND, KeyButton.LEFT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.NONE_FINGER,
Keyboard.ALT_KEY_WIDTH_PX, Keyboard.ALT_KEY_WIDTH_PX,
Keyboard.DEFAULT_KEY_SIZE_PX, Keyboard.DEFAULT_KEY_SIZE_PX,
KeyButton.LEFT_FUNCTION_KEY KeyButton.LEFT_FUNCTION_KEY
); );
this.addNextFunctionKeyData( this.addNextFunctionKeyData(
keyMapper,
"chinese", "chinese",
KeyButton.LEFT_HAND, KeyButton.LEFT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.NONE_FINGER,
Keyboard.CHINESE_KEY_WIDTH_PX, Keyboard.CHINESE_KEY_WIDTH_PX,
Keyboard.DEFAULT_KEY_SIZE_PX, Keyboard.DEFAULT_KEY_SIZE_PX,
KeyButton.LEFT_FUNCTION_KEY KeyButton.LEFT_FUNCTION_KEY
); );
this.addNextFunctionKeyData( this.addNextFunctionKeyData(
keyMapper, "Space",
"space",
KeyButton.BOTH_HAND, KeyButton.BOTH_HAND,
KeyButton.THUMB, KeyButton.THUMB,
Keyboard.SPACE_KEY_WIDTH_PX, Keyboard.SPACE_KEY_WIDTH_PX,
@@ -309,28 +342,25 @@ class Keyboard {
KeyButton.CENTER_FUNCTION_KEY KeyButton.CENTER_FUNCTION_KEY
); );
this.addNextFunctionKeyData( this.addNextFunctionKeyData(
keyMapper,
"korean_english", "korean_english",
KeyButton.RIGHT_HAND, KeyButton.RIGHT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.NONE_FINGER,
Keyboard.KOREAN_ENGLISH_KEY_WIDTH_PX, Keyboard.KOREAN_ENGLISH_KEY_WIDTH_PX,
Keyboard.DEFAULT_KEY_SIZE_PX, Keyboard.DEFAULT_KEY_SIZE_PX,
KeyButton.RIGHT_FUNCTION_KEY KeyButton.RIGHT_FUNCTION_KEY
); );
this.addNextFunctionKeyData( this.addNextFunctionKeyData(
keyMapper, "AltRight",
"right_alt",
KeyButton.RIGHT_HAND, KeyButton.RIGHT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.NONE_FINGER,
Keyboard.ALT_KEY_WIDTH_PX, Keyboard.ALT_KEY_WIDTH_PX,
Keyboard.DEFAULT_KEY_SIZE_PX, Keyboard.DEFAULT_KEY_SIZE_PX,
KeyButton.RIGHT_FUNCTION_KEY KeyButton.RIGHT_FUNCTION_KEY
); );
this.addNextFunctionKeyData( this.addNextFunctionKeyData(
keyMapper, "ControlRight",
"right_ctrl",
KeyButton.RIGHT_HAND, KeyButton.RIGHT_HAND,
KeyButton.LITTLE_FINGER, KeyButton.NONE_FINGER,
Keyboard.CTRL_KEY_WIDTH_PX, Keyboard.CTRL_KEY_WIDTH_PX,
Keyboard.DEFAULT_KEY_SIZE_PX, Keyboard.DEFAULT_KEY_SIZE_PX,
KeyButton.RIGHT_FUNCTION_KEY KeyButton.RIGHT_FUNCTION_KEY
+26 -26
View File
@@ -3,34 +3,34 @@ class KoreanKeyMapper extends KeyMapper {
constructor() { constructor() {
super(); super();
this.registerKeyTextData("q", "ㅂ", "ㅃ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyQ", "ㅂ", "ㅃ");
this.registerKeyTextData("w", "ㅈ", "ㅉ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyR", "ㅈ", "ㅉ");
this.registerKeyTextData("e", "ㄷ", "ㄸ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyEe", "ㄷ", "ㄸ");
this.registerKeyTextData("r", "ㄱ", "ㄲ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyR", "ㄱ", "ㄲ");
this.registerKeyTextData("t", "ㅅ", "ㅆ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyT", "ㅅ", "ㅆ");
this.registerKeyTextData("y", "ㅛ", "ㅛ", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyY", "ㅛ", "ㅛ");
this.registerKeyTextData("u", "ㅕ", "ㅕ", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyU", "ㅕ", "ㅕ");
this.registerKeyTextData("i", "ㅑ", "ㅑ", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyI", "ㅑ", "ㅑ");
this.registerKeyTextData("o", "ㅐ", "ㅒ", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyO", "ㅐ", "ㅒ");
this.registerKeyTextData("p", "ㅔ", "ㅖ", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyP", "ㅔ", "ㅖ");
this.registerKeyTextData("a", "ㅁ", "ㅁ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyA", "ㅁ", "ㅁ");
this.registerKeyTextData("s", "ㄴ", "ㄴ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyS", "ㄴ", "ㄴ");
this.registerKeyTextData("d", "ㅇ", "ㅇ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyD", "ㅇ", "ㅇ");
this.registerKeyTextData("f", "ㄹ", "ㄹ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyF", "ㄹ", "ㄹ");
this.registerKeyTextData("g", "ㅎ", "ㅎ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyG”", "ㅎ", "ㅎ");
this.registerKeyTextData("h", "ㅗ", "ㅗ", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyH", "ㅗ", "ㅗ");
this.registerKeyTextData("j", "ㅓ", "ㅓ", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyJ", "ㅓ", "ㅓ");
this.registerKeyTextData("k", "ㅏ", "ㅏ", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyJ", "ㅏ", "ㅏ");
this.registerKeyTextData("l", "ㅣ", "ㅣ", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyL", "ㅣ", "ㅣ");
this.registerKeyTextData("z", "ㅋ", "ㅋ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyZ", "ㅋ", "ㅋ");
this.registerKeyTextData("x", "ㅌ", "ㅌ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyX", "ㅌ", "ㅌ");
this.registerKeyTextData("c", "ㅊ", "ㅊ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyC", "ㅊ", "ㅊ");
this.registerKeyTextData("v", "ㅍ", "ㅍ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyV", "ㅍ", "ㅍ");
this.registerKeyTextData("b", "ㅠ", "ㅠ", KeyTextData.RIGHT_HAND); this.registerKeyTextData("KeyB", "ㅠ", "ㅠ");
this.registerKeyTextData("n", "ㅜ", "ㅜ", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyN", "ㅜ", "ㅜ");
this.registerKeyTextData("m", "ㅡ", "ㅡ", KeyTextData.LEFT_HAND); this.registerKeyTextData("KeyM", "ㅡ", "ㅡ");
} }
} }
+32 -30
View File
@@ -4,56 +4,58 @@ let koreanKeyMapper = new KoreanKeyMapper();
QUnit.test( "getNormalText", function( assert ) { QUnit.test( "getNormalText", function( assert ) {
assert.equal(englishKeyMapper.getNormalText("`"), "`", "getNormalText - `"); assert.equal(englishKeyMapper.getNormalText("Backquote"), "`", "getNormalText - `");
assert.equal(englishKeyMapper.getNormalText("/"), "/", "getNormalText - /"); assert.equal(englishKeyMapper.getNormalText("Slash"), "/", "getNormalText - /");
assert.equal(englishKeyMapper.getNormalText("q"), "q", "getNormalText - q"); assert.equal(englishKeyMapper.getNormalText("KeyQ"), "q", "getNormalText - q");
assert.equal(englishKeyMapper.getNormalText("m"), "m", "getNormalText - m"); assert.equal(englishKeyMapper.getNormalText("KeyM"), "m", "getNormalText - m");
assert.equal(koreanKeyMapper.getNormalText("q"), "ㅂ", "getNormalText - ㅂ"); assert.equal(koreanKeyMapper.getNormalText("KeyQ"), "ㅂ", "getNormalText - ㅂ");
assert.equal(koreanKeyMapper.getNormalText("m"), "ㅡ", "getNormalText - ㅡ"); assert.equal(koreanKeyMapper.getNormalText("KeyM"), "ㅡ", "getNormalText - ㅡ");
}); });
QUnit.test( "getShiftText", function( assert ) { QUnit.test( "getShiftText", function( assert ) {
assert.equal(englishKeyMapper.getShiftText("`"), "~", "getShiftText - ~"); assert.equal(englishKeyMapper.getShiftText("Backquote"), "~", "getShiftText - ~");
assert.equal(englishKeyMapper.getShiftText("/"), "?", "getShiftText - ?"); assert.equal(englishKeyMapper.getShiftText("Slash"), "?", "getShiftText - ?");
assert.equal(englishKeyMapper.getShiftText("q"), "Q", "getShiftText - Q"); assert.equal(englishKeyMapper.getShiftText("KeyQ"), "Q", "getShiftText - Q");
assert.equal(englishKeyMapper.getShiftText("m"), "M", "getShiftText - M"); assert.equal(englishKeyMapper.getShiftText("KeyM"), "M", "getShiftText - M");
assert.equal(koreanKeyMapper.getShiftText("q"), "ㅃ", "getShiftText - ㅃ"); assert.equal(koreanKeyMapper.getShiftText("KeyQ"), "ㅃ", "getShiftText - ㅃ");
assert.equal(koreanKeyMapper.getShiftText("m"), "ㅡ", "getShiftText - ㅡ"); assert.equal(koreanKeyMapper.getShiftText("KeyM"), "ㅡ", "getShiftText - ㅡ");
}); });
QUnit.test( "getShiftHandSide", function( assert ) { QUnit.test( "getShiftHandSide", function( assert ) {
assert.equal(englishKeyMapper.getShiftHandSide("`"), KeyTextData.RIGHT_HAND, "getShiftHandSide - `"); assert.equal(englishKeyMapper.getShiftHandSide("Backquote"), KeyTextData.RIGHT_HAND, "getShiftHandSide - `");
assert.equal(englishKeyMapper.getShiftHandSide("/"), KeyTextData.LEFT_HAND, "getShiftHandSide - /"); assert.equal(englishKeyMapper.getShiftHandSide("Slash"), KeyTextData.LEFT_HAND, "getShiftHandSide - /");
assert.equal(englishKeyMapper.getShiftHandSide("space"), KeyTextData.BOTH_HAND, "getShiftHandSide - space"); assert.equal(englishKeyMapper.getShiftHandSide("Space"), KeyTextData.BOTH_HAND, "getShiftHandSide - space");
assert.equal(englishKeyMapper.getShiftHandSide("q"), KeyTextData.RIGHT_HAND, "getShiftHandSide - q"); assert.equal(englishKeyMapper.getShiftHandSide("KeyQ"), KeyTextData.RIGHT_HAND, "getShiftHandSide - q");
assert.equal(englishKeyMapper.getShiftHandSide("m"), KeyTextData.LEFT_HAND, "getShiftHandSide - m"); assert.equal(englishKeyMapper.getShiftHandSide("KeyM"), KeyTextData.LEFT_HAND, "getShiftHandSide - m");
assert.equal(koreanKeyMapper.getShiftHandSide("q"), KeyTextData.RIGHT_HAND, "getShiftHandSide - q"); assert.equal(koreanKeyMapper.getShiftHandSide("KeyQ"), KeyTextData.RIGHT_HAND, "getShiftHandSide - q");
assert.equal(koreanKeyMapper.getShiftHandSide("m"), KeyTextData.LEFT_HAND, "getShiftHandSide - m"); assert.equal(koreanKeyMapper.getShiftHandSide("KeyM"), KeyTextData.LEFT_HAND, "getShiftHandSide - m");
}); });
QUnit.test( "getKeyIDOfText", function( assert ) { QUnit.test( "getKeyIDOfText", function( assert ) {
assert.equal(englishKeyMapper.getKeyIDOfText("`"), "`", "getKeyIDOfText - `"); assert.equal(englishKeyMapper.getKeyIDOfText("`"), "Backquote", "getKeyIDOfText - `");
assert.equal(englishKeyMapper.getKeyIDOfText("~"), "`", "getKeyIDOfText - ~"); assert.equal(englishKeyMapper.getKeyIDOfText("~"), "Backquote", "getKeyIDOfText - ~");
assert.equal(englishKeyMapper.getKeyIDOfText("/"), "/", "getKeyIDOfText - /"); assert.equal(englishKeyMapper.getKeyIDOfText("/"), "Slash", "getKeyIDOfText - /");
assert.equal(englishKeyMapper.getKeyIDOfText("?"), "/", "getKeyIDOfText - ?"); assert.equal(englishKeyMapper.getKeyIDOfText("?"), "Slash", "getKeyIDOfText - ?");
assert.equal(englishKeyMapper.getKeyIDOfText("q"), "q", "getKeyIDOfText - q"); assert.equal(englishKeyMapper.getKeyIDOfText("q"), "KeyQ", "getKeyIDOfText - q");
assert.equal(englishKeyMapper.getKeyIDOfText("Q"), "q", "getKeyIDOfText - Q"); assert.equal(englishKeyMapper.getKeyIDOfText("Q"), "KeyQ", "getKeyIDOfText - Q");
assert.equal(englishKeyMapper.getKeyIDOfText("m"), "m", "getKeyIDOfText - m"); assert.equal(englishKeyMapper.getKeyIDOfText("m"), "KeyM", "getKeyIDOfText - m");
assert.equal(englishKeyMapper.getKeyIDOfText("M"), "m", "getKeyIDOfText - M"); assert.equal(englishKeyMapper.getKeyIDOfText("M"), "KeyM", "getKeyIDOfText - M");
assert.equal(koreanKeyMapper.getKeyIDOfText("ㅂ"), "q", "getKeyIDOfText - ㅂ"); assert.equal(koreanKeyMapper.getKeyIDOfText("ㅂ"), "KeyQ", "getKeyIDOfText - ㅂ");
assert.equal(koreanKeyMapper.getKeyIDOfText("ㅃ"), "q", "getKeyIDOfText - ㅃ"); assert.equal(koreanKeyMapper.getKeyIDOfText("ㅃ"), "KeyQ", "getKeyIDOfText - ㅃ");
assert.equal(koreanKeyMapper.getKeyIDOfText("ㅡ"), "m", "getKeyIDOfText - ㅡ"); assert.equal(koreanKeyMapper.getKeyIDOfText("ㅡ"), "KeyM", "getKeyIDOfText - ㅡ");
assert.equal(koreanKeyMapper.getKeyIDOfText("Backspace"), "Backspace", "getKeyIDOfText - ㅂ");
}); });
QUnit.test( "getShiftTypeOfText", function( assert ) { QUnit.test( "getShiftTypeOfText", function( assert ) {