|
@@ -151,14 +151,14 @@ module Controls.KeyHandler {
|
|
|
"keyCodesRoom",
|
|
|
createKeyCodes( ["Digit1", "Digit2", "Digit3", "Digit4", "Digit5"],
|
|
|
["1", "2", "3", "4", "5"],
|
|
|
- [true, true, true, true])
|
|
|
+ [true, true, true, false])
|
|
|
);
|
|
|
|
|
|
export var keyCodes2 = new StoredMemory(
|
|
|
"keyCodesActions",
|
|
|
createKeyCodes( ["KeyQ", "KeyW", "KeyE", "KeyR", "KeyT"],
|
|
|
["Q", "W", "E", "R", "T"],
|
|
|
- [true, true, true, true])
|
|
|
+ [true, true, true, false])
|
|
|
);
|
|
|
|
|
|
|
|
@@ -167,7 +167,7 @@ module Controls.KeyHandler {
|
|
|
"keyCodesGlobal",
|
|
|
createKeyCodes( ["KeyF", "KeyV", "KeyG", "KeyB"],
|
|
|
["F", "V", "G", "B"],
|
|
|
- [true, true, true, true])
|
|
|
+ [true, true, true, false])
|
|
|
);
|
|
|
|
|
|
export var keyCodeNorth = new StoredMemory(
|
|
@@ -230,6 +230,7 @@ module Controls.KeyHandler {
|
|
|
return directionCodeByIndex[index].getValue();
|
|
|
}
|
|
|
|
|
|
+ export var keyRows = 3;
|
|
|
export var available1 : Array<KeyCode> = [];
|
|
|
export var available2 : Array<KeyCode> = [];
|
|
|
export var available3 : Array<KeyCode> = [];
|
|
@@ -314,4 +315,55 @@ module Controls.KeyHandler {
|
|
|
rejectPromise(promiseStack[index]);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ export function addKey (row : number, ev : KeyboardEvent) {
|
|
|
+ let keyName = ev.key.toUpperCase();
|
|
|
+ if (["ALT", "CONTROL", "SHIFT", " ", "TAB"].includes(keyName)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (keyName == "BACKSPACE") {
|
|
|
+ clearKeys(row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (row >= 1 && row <= Controls.KeyHandler.keyRows) {
|
|
|
+ let rowArray : StoredMemory<Array<KeyCode>> = Controls.KeyHandler["keyCodes" + row];
|
|
|
+ let keyArray = rowArray.getValue().splice(0);
|
|
|
+ keyArray.push(...
|
|
|
+ createKeyCodes( [ev.code],
|
|
|
+ [keyName],
|
|
|
+ [true, true, true, false])
|
|
|
+ );
|
|
|
+
|
|
|
+ let modNumber = (name : string) => {
|
|
|
+ if (name.indexOf("Shift") != -1) {
|
|
|
+ return 1;
|
|
|
+ } else if (name.indexOf("Control") != -1) {
|
|
|
+ return 2;
|
|
|
+ } else if (name.indexOf("Alt") != -1) {
|
|
|
+ return 3;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ };
|
|
|
+
|
|
|
+ keyArray.sort((a, b) => {
|
|
|
+ let ma = modNumber(a.name);
|
|
|
+ let mb = modNumber(b.name);
|
|
|
+ if (ma != mb) {
|
|
|
+ return ma - mb;
|
|
|
+ }
|
|
|
+ if (a.representation < b.representation) return -1;
|
|
|
+ else if (a.representation > b.representation) return 1;
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+
|
|
|
+ rowArray.storeValue(keyArray);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ export function clearKeys (row : number) {
|
|
|
+ if (row >= 1 && row <= Controls.KeyHandler.keyRows) {
|
|
|
+ let rowArray: StoredMemory<Array<KeyCode>> = Controls.KeyHandler["keyCodes" + row];
|
|
|
+ rowArray.storeValue([]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|