score: simplify bangle1-bangle2 logic
parent
f764b0a7e5
commit
a49266e053
|
|
@ -44,30 +44,36 @@ function setupDisplay() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupInputWatchers(init) {
|
function setupInputWatchers(init) {
|
||||||
Bangle.setUI('updown', v => {
|
Bangle.setUI('updown',
|
||||||
if (v) {
|
isBangle1
|
||||||
if (isBangle1) {
|
? (v => {
|
||||||
|
if (v) {
|
||||||
let i = settings.mirrorScoreButtons ? v : v * -1;
|
let i = settings.mirrorScoreButtons ? v : v * -1;
|
||||||
handleInput(Math.floor((i+2)/2));
|
handleInput(Math.floor((i+2)/2));
|
||||||
} else {
|
}
|
||||||
|
})
|
||||||
|
: (v => {
|
||||||
|
if (v) {
|
||||||
// +1 -> 4
|
// +1 -> 4
|
||||||
// -1 -> 3
|
// -1 -> 3
|
||||||
handleInput(Math.floor((v+2)/2)+3);
|
handleInput(Math.floor((v+2)/2)+3);
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
});
|
);
|
||||||
if (init) {
|
if (init) {
|
||||||
if (isBangle1) {
|
if (isBangle1) {
|
||||||
setWatch(() => handleInput(2), BTN2, { repeat: true });
|
setWatch(() => handleInput(2), BTN2, { repeat: true });
|
||||||
}
|
}
|
||||||
Bangle.on('touch', (b, e) => {
|
Bangle.on('touch',
|
||||||
if (isBangle1) {
|
isBangle1
|
||||||
|
? ((b, e) => {
|
||||||
if (b === 1) {
|
if (b === 1) {
|
||||||
handleInput(3);
|
handleInput(3);
|
||||||
} else {
|
} else {
|
||||||
handleInput(4);
|
handleInput(4);
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
|
: ((b, e) => {
|
||||||
if (e.y > 18) {
|
if (e.y > 18) {
|
||||||
if (e.x < getXCoord(w => w/2)) {
|
if (e.x < getXCoord(w => w/2)) {
|
||||||
handleInput(0);
|
handleInput(0);
|
||||||
|
|
@ -99,8 +105,8 @@ function setupInputWatchers(init) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,7 +145,7 @@ function showSettingsMenu() {
|
||||||
if (reset) {
|
if (reset) {
|
||||||
setupMatch();
|
setupMatch();
|
||||||
}
|
}
|
||||||
if (isBangle1 || (!isBangle1 && back)) {
|
if (isBangle1 || back) {
|
||||||
settingsMenuOpened = null;
|
settingsMenuOpened = null;
|
||||||
|
|
||||||
draw();
|
draw();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue