ctrlpad: permit drag in any BLE state

pull/3383/head
Rob Pilling 2023-08-28 12:18:31 +01:00
parent db52196fcc
commit 5e8cdc3a16
1 changed files with 3 additions and 35 deletions

View File

@ -102,13 +102,12 @@
delete settings; delete settings;
const enum State { const enum State {
NoConn,
Idle, Idle,
TopDrag, TopDrag,
IgnoreCurrent, IgnoreCurrent,
Active, Active,
} }
let state = State.NoConn; let state = State.Idle;
let startY = 0; let startY = 0;
let startedUpDrag = false; let startedUpDrag = false;
let upDragAnim: IntervalId | undefined; let upDragAnim: IntervalId | undefined;
@ -121,9 +120,6 @@
if (e.b === 0) touchDown = startedUpDrag = false; if (e.b === 0) touchDown = startedUpDrag = false;
switch (state) { switch (state) {
case State.NoConn:
break;
case State.IgnoreCurrent: case State.IgnoreCurrent:
if(e.b === 0){ if(e.b === 0){
state = State.Idle; state = State.Idle;
@ -219,41 +215,13 @@
Bangle.prependListener("drag", onDrag); Bangle.prependListener("drag", onDrag);
const redraw = () => setTimeout(Bangle.drawWidgets, 10);
const connected = NRF.getSecurityStatus().connected;
WIDGETS["hid"] = { WIDGETS["hid"] = {
area: "tr", area: "tr",
sortorder: -20, sortorder: -20,
draw: function() { draw: () => {},
if(this.width === 0) return; width: 0,
g.drawImage(
state === State.Active
? require("heatshrink").decompress(atob("jEYxH+AEfH44XXAAYXXDKIXZDYp3pC/6KHUMwWHC/4XvUy4YGdqoA/AFoA=="))
: require("heatshrink").decompress(atob("jEYxH+AEcdjoXXAAYXXDKIXZDYp3pC/6KHUMwWHC/4XvUy4YGdqoA/AFoA==")),
this.x! + 2,
this.y! + 2
);
},
width: connected ? 24 : 0,
}; };
state = connected ? State.Idle : State.NoConn;
// @ts-ignore
delete connected;
NRF.on("connect", () => {
WIDGETS["hid"]!.width = 24;
state = State.Idle;
redraw();
});
NRF.on("disconnect", () => {
WIDGETS["hid"]!.width = 0;
state = State.NoConn;
redraw();
});
//const DEBUG = true; //const DEBUG = true;
/* /*
const sendHid = (code: number) => { const sendHid = (code: number) => {