From 84e4d04377602998da9217a77a0b045f3240f298 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 31 Mar 2022 12:40:45 -0600 Subject: [PATCH] leftControl behavior depends on active input tab --- publish.sh | 10 +++++++++- static/index.html | 4 ++-- static/inputs.mjs | 19 +++++++++++++++++-- static/repeaters.mjs | 1 + static/vail.mjs | 18 ++++++++++++++++++ 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/publish.sh b/publish.sh index 7ed02d0..36b841b 100755 --- a/publish.sh +++ b/publish.sh @@ -1,3 +1,11 @@ #! /bin/sh -rsync -va static melville.woozle.org:/srv/vail/ +case "$1" in + -prod|--prod) + echo "Push to main branch, then update stack." + #rsync -va static melville.woozle.org:/srv/vail/ + ;; + "") + rsync -va static/ melville.woozle.org:/srv/vail/testing/ + ;; +esac diff --git a/static/index.html b/static/index.html index 1bec217..6f1dafe 100644 --- a/static/index.html +++ b/static/index.html @@ -98,8 +98,8 @@
diff --git a/static/inputs.mjs b/static/inputs.mjs index fbf1a1b..f64429a 100644 --- a/static/inputs.mjs +++ b/static/inputs.mjs @@ -37,6 +37,9 @@ export class Keyboard { // Listen for keystrokes document.addEventListener("keydown", e => this.keyboard(e)) document.addEventListener("keyup", e => this.keyboard(e)) + + // VBand: the keyboard input needs to know whether vband's "left" should be dit or straight + this.iambic = false } keyboard(event) { @@ -54,7 +57,6 @@ export class Keyboard { if ((event.code == "KeyX") || (event.code == "Period") || (event.code == "BracketLeft") || - (event.code == "ControlLeft") || (event.key == "[")) { event.preventDefault() this.keyer.Dit(down) @@ -62,7 +64,7 @@ export class Keyboard { if ((event.code == "KeyZ") || (event.code == "Slash") || (event.code == "BracketRight") || - (event.code == "ControlRight") || + (event.code == "ControlRight") || // VBand only: don't display this option to the user (event.key == "]")) { event.preventDefault() this.keyer.Dah(down) @@ -74,6 +76,19 @@ export class Keyboard { event.preventDefault() this.keyer.Straight(down) } + + if ((event.code == "ControlLeft")) { + // VBand and the VBand adapter take a different approach to inputs: + // There is a "left" key, and a "right" key, and the computer decides what those mean. + // Users expect "left" to be a straight key or dit, depending on some screen control. + // "right" is always dah. + event.preventDefault() + if (this.iambic) { + this.keyer.Dit(down) + } else { + this.keyer.Straight(down) + } + } } } diff --git a/static/repeaters.mjs b/static/repeaters.mjs index 541ef68..2e72c09 100644 --- a/static/repeaters.mjs +++ b/static/repeaters.mjs @@ -13,6 +13,7 @@ export class Vail { this.wsUrl = new URL("chat", window.location) this.wsUrl.protocol = this.wsUrl.protocol.replace("http", "ws") + this.wsUrl.pathname = this.wsUrl.pathname.replace("testing/", "") // Allow staging deploys this.wsUrl.searchParams.set("repeater", name) this.reopen() diff --git a/static/vail.mjs b/static/vail.mjs index 9c45037..ce040b8 100644 --- a/static/vail.mjs +++ b/static/vail.mjs @@ -51,6 +51,11 @@ class VailClient { // Set up various input methods this.inputs = Inputs.SetupAll(this.keyer) + // VBand: Keep track of how the user wants the single key to behave + for (let e of document.querySelectorAll("[data-singlekey]")) { + e.addEventListener("click", e => this.singlekeyChange(e)) + } + // Maximize button for (let e of document.querySelectorAll("button.maximize")) { e.addEventListener("click", e => this.maximize(e)) @@ -84,6 +89,19 @@ class VailClient { this.setRepeater(decodeURIComponent(hashParts[1] || "")) } + /** + * VBand: Called when something happens to change what a single key does + * + * @param {Event} event What caused this + */ + singlekeyChange(event) { + for (let e of event.path) { + if (e.dataset && e.dataset.singlekey) { + this.inputs.Keyboard.iambic = (e.dataset.singlekey == "iambic") + } + } + } + /** * Connect to a repeater by name. *