From 8f63d7c0b5d295290c925fec0f4ca5d32b3b3a68 Mon Sep 17 00:00:00 2001 From: Nik Rozman Date: Tue, 3 Mar 2026 08:34:43 +0100 Subject: [PATCH] UI improvements, prepare for config overriding --- web/app.js | 38 +++++++++++++++++++++++++++----------- web/index.html | 12 ++++++++---- web/style.css | 7 ++----- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/web/app.js b/web/app.js index 035afad..f1093e2 100644 --- a/web/app.js +++ b/web/app.js @@ -11,7 +11,7 @@ const CHR = { // Local shadow of the current config (kept in sync with device) const config = { sensitivity:600, deadZone:0.06, accelStrength:0.08, curve:0, axisFlip:0, chargeMode:1, - tapThreshold:12, tapAction:0, tapKey:0, tapMod:0, jerkThreshold:2000 }; + tapThreshold:12, tapAction:0, tapKey:0, tapMod:0, tapFreezeEnabled:1, jerkThreshold:2000 }; let device=null, server=null, chars={}, userDisconnected=false; let currentChargeStatus=0, currentBattPct=null, currentBattVoltage=null; @@ -200,10 +200,11 @@ async function checkHashMatch() { } // ── ConfigBlob read / write ────────────────────────────────────────────────── -// ConfigBlob layout (20 bytes LE): +// ConfigBlob layout (24 bytes LE): // float sensitivity [0], float deadZone [4], float accelStrength [8] // uint8 curve [12], uint8 axisFlip [13], uint8 chargeMode [14] -// uint8 tapThreshold [15], uint8 tapAction [16], uint8 tapKey [17], uint8 tapMod [18], uint8 pad [19] +// uint8 tapThreshold [15], uint8 tapAction [16], uint8 tapKey [17], uint8 tapMod [18], uint8 tapFreezeEnabled [19] +// float jerkThreshold [20] async function readConfigBlob() { if (!chars.configBlob) return; @@ -217,10 +218,11 @@ async function readConfigBlob() { config.axisFlip = view.getUint8(13); config.chargeMode = view.getUint8(14); if (view.byteLength >= 20) { - config.tapThreshold = view.getUint8(15); - config.tapAction = view.getUint8(16); - config.tapKey = view.getUint8(17); - config.tapMod = view.getUint8(18); + config.tapThreshold = view.getUint8(15); + config.tapAction = view.getUint8(16); + config.tapKey = view.getUint8(17); + config.tapMod = view.getUint8(18); + config.tapFreezeEnabled = view.getUint8(19); } if (view.byteLength >= 24) { config.jerkThreshold = view.getFloat32(20, true); @@ -241,8 +243,10 @@ function applyConfigToUI() { document.getElementById('flipX').checked = !!(config.axisFlip & 1); document.getElementById('flipY').checked = !!(config.axisFlip & 2); setChargeModeUI(config.chargeMode); + document.getElementById('tapFreezeEnabled').checked = !!config.tapFreezeEnabled; document.getElementById('slJerkThreshold').value = config.jerkThreshold; updateDisplay('jerkThreshold', config.jerkThreshold); + updateTapFreezeUI(!!config.tapFreezeEnabled); document.getElementById('slTapThreshold').value = config.tapThreshold; updateDisplay('tapThreshold', config.tapThreshold); setTapActionUI(config.tapAction); @@ -272,6 +276,7 @@ async function _doWriteConfigBlob() { | (document.getElementById('tapModShift').checked ? 0x02 : 0) | (document.getElementById('tapModAlt').checked ? 0x04 : 0) | (document.getElementById('tapModGui').checked ? 0x08 : 0); + config.tapFreezeEnabled = document.getElementById('tapFreezeEnabled').checked ? 1 : 0; config.jerkThreshold = +document.getElementById('slJerkThreshold').value; // config.curve, config.chargeMode, config.tapAction, config.tapKey updated directly @@ -287,7 +292,7 @@ async function _doWriteConfigBlob() { view.setUint8(16, config.tapAction); view.setUint8(17, config.tapKey); view.setUint8(18, config.tapMod); - view.setUint8(19, 0); + view.setUint8(19, config.tapFreezeEnabled); view.setFloat32(20, config.jerkThreshold, true); try { @@ -325,6 +330,17 @@ function setChargeModeUI(val) { document.getElementById('ciMode').textContent = ['Off (0mA)','50 mA','100 mA'][val] ?? '--'; } +function onTapFreezeChange(enabled) { + config.tapFreezeEnabled = enabled ? 1 : 0; + updateTapFreezeUI(enabled); + writeConfigBlob(); +} +function updateTapFreezeUI(enabled) { + const slider = document.getElementById('slJerkThreshold'); + // Only grey out when connected (on disconnect, setStatus handles all inputs) + if (device) slider.disabled = !enabled; +} + function setTapAction(val) { config.tapAction = val; setTapActionUI(val); @@ -820,12 +836,12 @@ let orientLastT = 0; function initOrientViewer() { const el = document.getElementById('orientCanvas'); - const W = el.clientWidth || 340, H = 160; + const W = el.clientWidth || 340, H = el.clientHeight || W; el.width = W; el.height = H; orientScene = new THREE.Scene(); - orientCamera = new THREE.PerspectiveCamera(40, W / H, 0.01, 10); - orientCamera.position.set(0.6, 0.5, 0.9); + orientCamera = new THREE.PerspectiveCamera(55, W / H, 0.01, 10); + orientCamera.position.set(0.75, 0.60, 1.10); orientCamera.lookAt(0, 0, 0); orientRenderer = new THREE.WebGLRenderer({ canvas: el, antialias: true, alpha: true }); diff --git a/web/index.html b/web/index.html index 2875a58..09d07bf 100644 --- a/web/index.html +++ b/web/index.html @@ -32,6 +32,8 @@ AUTO-RECONNECT + + ADVANCED @@ -93,14 +95,16 @@
--%
Level
-
- - ADVANCED -
Tap Configuration
+
+
Tap Freeze
Freeze cursor during tap impacts (jerk detection)
+
+ +
+
Tap Freeze Sensitivity
Jerk² threshold — lower = more aggressive cursor freeze during taps