kbswipe: Compat w backswipe on newer firmwares

pull/2945/head
thyttan 2023-08-02 00:15:06 +02:00
parent 4061bd2f5e
commit 8ba3c68b59
3 changed files with 28 additions and 16 deletions

View File

@ -6,3 +6,5 @@
0.06: Support input of numbers and uppercase characters.
0.07: Support input of symbols.
0.08: Redone patterns a,e,m,w,z.
0.09: Catch and discard swipe events on fw2v19 and up (as well as some cutting
edge 2v18 ones), allowing compatability with the Back Swipe app.

View File

@ -253,28 +253,38 @@ exports.input = function(options) {
};
Bangle.drawWidgets();
let dragHandlerKB = e=>{
"ram";
if (isInside(R, e)) {
if (lastDrag) g.reset().setColor("#f00").drawLine(lastDrag.x,lastDrag.y,e.x,e.y);
lastDrag = e.b ? e : 0;
}
}
let touchHandlerKB = (n,e) => {
if (WIDGETS.kbswipe && isInside({x: WIDGETS.kbswipe.x, y: WIDGETS.kbswipe.y, w: WIDGETS.kbswipe.width, h: 24}, e)) {
// touch inside widget
cycleInput();
} else if (isInside(R, e)) {
// touch inside app area
show();
}
}
let catchSwipe = ()=>{
E.stopEventPropagation&&E.stopEventPropagation();
};
return new Promise((resolve,reject) => {
Bangle.setUI({mode:"custom", drag:e=>{
"ram";
if (isInside(R, e)) {
if (lastDrag) g.reset().setColor("#f00").drawLine(lastDrag.x,lastDrag.y,e.x,e.y);
lastDrag = e.b ? e : 0;
}
},touch:(n,e) => {
if (WIDGETS.kbswipe && isInside({x: WIDGETS.kbswipe.x, y: WIDGETS.kbswipe.y, w: WIDGETS.kbswipe.width, h: 24}, e)) {
// touch inside widget
cycleInput();
} else if (isInside(R, e)) {
// touch inside app area
show();
}
}, back:()=>{
Bangle.setUI({mode:"custom", drag:dragHandlerKB, touch:touchHandlerKB, back:()=>{
delete WIDGETS.kbswipe;
Bangle.removeListener("stroke", strokeHandler);
Bangle.prependListener&&Bangle.removeListener('swipe', catchSwipe); // Remove swipe lister if it was added with `Bangle.prependListener()` (fw2v19 and up).
if (flashInterval) clearInterval(flashInterval);
Bangle.setUI();
g.clearRect(Bangle.appRect);
resolve(text);
}});
Bangle.prependListener&&Bangle.prependListener('swipe', catchSwipe); // Intercept swipes on fw2v19 and later. Should not break on older firmwares.
});
};

View File

@ -1,6 +1,6 @@
{ "id": "kbswipe",
"name": "Swipe keyboard",
"version":"0.08",
"version":"0.09",
"description": "A library for text input via PalmOS style swipe gestures (beta!)",
"icon": "app.png",
"type":"textinput",