From 56d9111e795d94c91a9fd20460b003fb718c8b67 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 28 Aug 2023 12:18:50 +0100 Subject: [PATCH] ctrlpad: inline activate/deactivate --- apps/ctrlpad/wid.ts | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/apps/ctrlpad/wid.ts b/apps/ctrlpad/wid.ts index 61a0ba075..ac22051ae 100644 --- a/apps/ctrlpad/wid.ts +++ b/apps/ctrlpad/wid.ts @@ -146,7 +146,11 @@ console.log("topdrag stopped, distance: " + (e.y - startY)); if(e.y > startY + dragDistance){ console.log("activating"); - activate(); + state = State.Active; + startY = 0; + Bangle.prependListener("touch", onTouch); + Bangle.buzz(20); + overlay!.setBottom(g.getHeight()); break; } console.log("returning to idle"); @@ -186,10 +190,12 @@ overlay = undefined; return; } - overlay?.setBottom(bottom) + overlay?.setBottom(bottom); bottom -= 10; }, 50) - deactivate(); + + Bangle.removeListener("touch", onTouch); + state = State.Idle; } break; } @@ -200,19 +206,6 @@ // TODO: button presses }) satisfies TouchCallback; - const activate = () => { - state = State.Active; - startY = 0; - Bangle.prependListener("touch", onTouch); - Bangle.buzz(20); - overlay!.setBottom(g.getHeight()); - }; - - const deactivate = () => { - Bangle.removeListener("touch", onTouch); - state = State.Idle; - }; - Bangle.prependListener("drag", onDrag); WIDGETS["hid"] = {