diff --git a/index.html b/index.html
index ea90997..da7461b 100644
--- a/index.html
+++ b/index.html
@@ -6710,7 +6710,8 @@
gpsBackupInterval = null;
}
- // Show WASD controls
+ // Reset WASD state and show controls
+ resetWasdState();
const wasdControls = document.getElementById('wasdControls');
if (wasdControls) wasdControls.classList.remove('hidden');
@@ -6722,7 +6723,16 @@
// Hide WASD controls when disabling test mode
const wasdControls = document.getElementById('wasdControls');
if (wasdControls) wasdControls.classList.add('hidden');
- updateStatus('GPS Test Mode disabled', 'info');
+
+ // Clean up any active WASD movement state
+ resetWasdState();
+
+ // Restart GPS tracking since user wants to use real GPS
+ if (gpsWatchId === null) {
+ toggleGPS();
+ }
+
+ updateStatus('GPS Test Mode disabled - starting GPS', 'info');
}
}
@@ -6924,6 +6934,23 @@
}
});
+ // Handle lost pointer capture (e.g., when element is hidden)
+ btn.addEventListener('lostpointercapture', (e) => {
+ if (isPressed) {
+ isPressed = false;
+ stopMove();
+ }
+ });
+
+ // Handle pointer leaving button area
+ btn.addEventListener('pointerleave', (e) => {
+ // Only stop if we have capture (otherwise normal hover exit)
+ if (isPressed && !btn.hasPointerCapture(e.pointerId)) {
+ isPressed = false;
+ stopMove();
+ }
+ });
+
// Prevent context menu on long press
btn.addEventListener('contextmenu', (e) => {
e.preventDefault();
@@ -6931,6 +6958,15 @@
});
}
+ // Function to reset WASD state (call when showing/hiding controls)
+ function resetWasdState() {
+ if (wasdMoveInterval) {
+ clearInterval(wasdMoveInterval);
+ wasdMoveInterval = null;
+ }
+ wasdCurrentDir = null;
+ }
+
// Initialize WASD controls after DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initWasdControls);