From 1614fea76a6fc1f4d70ddb14b95e3004c79365ef Mon Sep 17 00:00:00 2001
From: Kit La Touche <kit@transneptune.net>
Date: Mon, 4 Nov 2024 22:31:27 -0500
Subject: Set up framework for testing touch events

This includes a change to tools/run that exposes the dev server on my
local network. This change should not make it into the final form of
this branch.

This is so I can use actual for real touch events on my actual for real
phone, hooked up for remote debugging to my computer so I can see
console events etc.
---
 ui/routes/(app)/+layout.svelte | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

(limited to 'ui/routes/(app)/+layout.svelte')

diff --git a/ui/routes/(app)/+layout.svelte b/ui/routes/(app)/+layout.svelte
index ae3dc6a..acaea53 100644
--- a/ui/routes/(app)/+layout.svelte
+++ b/ui/routes/(app)/+layout.svelte
@@ -25,6 +25,40 @@
     messages.update((value) => value.setMessages(boot.messages));
   }
 
+  function setTouchEvents() {
+      document.addEventListener("touchstart", processTouchStart);
+      document.addEventListener("touchmove", processTouchMove);
+      document.addEventListener("touchcancel", processTouchCancel);
+      document.addEventListener("touchend", processTouchEnd);
+  }
+
+  function processTouchStart(ev) {
+      ev.preventDefault();
+      switch (ev.touches.length) {
+          case 1:
+              console.log("touch: single");
+              break;
+          case 2:
+              console.log("touch: double");
+              break;
+          case 3:
+              console.log("touch: triple");
+              break;
+          default:
+              console.log("touch: unsupported");
+              break;
+      }
+  }
+
+  function processTouchMove(ev) {
+  }
+
+  function processTouchCancel(ev) {
+  }
+
+  function processTouchEnd(ev) {
+  }
+
   onMount(async () => {
     let response = await boot();
     switch (response.status) {
@@ -45,6 +79,7 @@
         break;
     }
     loading = false;
+    setTouchEvents();
   });
 
   onDestroy(async () => {
-- 
cgit v1.2.3

