From 1cccd4adf57d3d62f1357260334ec9ffd9457e15 Mon Sep 17 00:00:00 2001 From: "PolicyChanges1@gmail.com" Date: Mon, 1 Mar 2021 19:04:23 -0500 Subject: [PATCH] keyboard stuff --- dist/tetrion.js | 27 +++++++++++++-------------- src/input.js | 27 +++++++++++++-------------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/dist/tetrion.js b/dist/tetrion.js index 4e12a69..867bbfc 100644 --- a/dist/tetrion.js +++ b/dist/tetrion.js @@ -544,13 +544,13 @@ var UserInputs = { }, // doing a lot of back and forth between strings and integers to represtent the same thing -- todo: fix processKeys() { - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Harddrop"))); //32); // Space - hard drop - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Rotate"))); //88); // X - rotate - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Rotateccw"))); //90); // Z - rotateccw - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Hold"))); //16); // shift - push hold stack - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Pophold"))); // ctrl - pop hold stack - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Background"))); // q - turn off background - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Reset"))); // r - reset + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Harddrop"))); + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Rotate"))); + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Rotateccw"))); + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Hold"))); + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Pophold"))); + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Background"))); + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Reset"))); //this.processKeyDown(this.settingsMap.get("Keyboard hold"))); // c - pop hold stack }, @@ -589,14 +589,14 @@ var UserInputs = { }, // Process applicable key inputs processKeyShift() { - this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Left"))); //39); // right - this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Right"))); //37); // left - this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Down"))); // down + this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Left"))); + this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Right"))); + this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Down"))); }, // Direction arrows processKeyboardArrowKeys(key) { - var DAS = parseInt(this.settingsMap.get("Keyboard DAS")); //65.0; - var ARR = parseInt(this.settingsMap.get("Keyboard ARR")); //20.0; + var DAS = parseInt(this.settingsMap.get("Keyboard DAS")); + var ARR = parseInt(this.settingsMap.get("Keyboard ARR")); if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) { // Not being held yet @@ -608,7 +608,6 @@ var UserInputs = { this.inputQueue.push(key); } - var deltaTime = (new Date()).getTime() - this.keyboardShiftTimer.getTime(); if (!this.isPassedDelayKeyboardShift) { @@ -626,7 +625,7 @@ var UserInputs = { }, keyDown(event) { - + if(event.keyCode != 38) if (! ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 8)) event.preventDefault(); diff --git a/src/input.js b/src/input.js index 9a3b804..15f007b 100644 --- a/src/input.js +++ b/src/input.js @@ -120,13 +120,13 @@ var UserInputs = { }, // doing a lot of back and forth between strings and integers to represtent the same thing -- todo: fix processKeys() { - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Harddrop"))); //32); // Space - hard drop - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Rotate"))); //88); // X - rotate - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Rotateccw"))); //90); // Z - rotateccw - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Hold"))); //16); // shift - push hold stack - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Pophold"))); // ctrl - pop hold stack - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Background"))); // q - turn off background - this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Reset"))); // r - reset + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Harddrop"))); + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Rotate"))); + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Rotateccw"))); + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Hold"))); + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Pophold"))); + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Background"))); + this.processKeyDown(parseInt(this.settingsMap.get("Keyboard Reset"))); //this.processKeyDown(this.settingsMap.get("Keyboard hold"))); // c - pop hold stack }, @@ -165,14 +165,14 @@ var UserInputs = { }, // Process applicable key inputs processKeyShift() { - this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Left"))); //39); // right - this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Right"))); //37); // left - this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Down"))); // down + this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Left"))); + this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Right"))); + this.processKeyboardArrowKeys(parseInt(this.settingsMap.get("Keyboard Down"))); }, // Direction arrows processKeyboardArrowKeys(key) { - var DAS = parseInt(this.settingsMap.get("Keyboard DAS")); //65.0; - var ARR = parseInt(this.settingsMap.get("Keyboard ARR")); //20.0; + var DAS = parseInt(this.settingsMap.get("Keyboard DAS")); + var ARR = parseInt(this.settingsMap.get("Keyboard ARR")); if(this.prevKeyboardKeys[key] != this.keyboardKeys[key]) { // Not being held yet @@ -184,7 +184,6 @@ var UserInputs = { this.inputQueue.push(key); } - var deltaTime = (new Date()).getTime() - this.keyboardShiftTimer.getTime(); if (!this.isPassedDelayKeyboardShift) { @@ -202,7 +201,7 @@ var UserInputs = { }, keyDown(event) { - + if(event.keyCode != 38) if (! ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 8)) event.preventDefault();