Skip to content

Commit

Permalink
modify how button and touchpad double tap window is retrieved, add de…
Browse files Browse the repository at this point in the history
…bug alert to figure out why touchpad double tap is broken on iPhone
  • Loading branch information
Nerwyn committed Dec 13, 2024
1 parent 83934d2 commit 201bcb9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 34 deletions.
6 changes: 3 additions & 3 deletions dist/universal-remote-card.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "universal-remote-card",
"version": "4.3.0",
"version": "4.3.1",
"description": "Universal Remote Card",
"main": "./dist/universal-remote-card.min.js",
"scripts": {
Expand Down
12 changes: 5 additions & 7 deletions src/classes/remote-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ export class RemoteButton extends BaseRemoteElement {
} else {
// Single tap action is triggered if double tap is not within window
if (!this.clickTimer) {
const doubleTapWindow: number = this.config
.double_tap_action?.double_tap_window
? (this.renderTemplate(
this.config.double_tap_action
?.double_tap_window as unknown as string,
) as number)
: DOUBLE_TAP_WINDOW;
const doubleTapWindow: number =
(this.renderTemplate(
this.config.double_tap_action
?.double_tap_window as number,
) as number) ?? DOUBLE_TAP_WINDOW;
this.clickTimer = setTimeout(() => {
this.fireHapticEvent('light');
this.sendAction('tap_action');
Expand Down
40 changes: 19 additions & 21 deletions src/classes/remote-touchpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,24 @@ export class RemoteTouchpad extends BaseRemoteElement {
} else {
// Single tap action is triggered if double tap is not within window
if (!this.clickTimer) {
let doubleTapWindow: number =
'double_tap_window' in
(this.config[doubleTapAction] ?? {})
? (this.renderTemplate(
this.config[doubleTapAction]
?.double_tap_window as unknown as string,
) as number)
: DOUBLE_TAP_WINDOW;
if (
multiPrefix == 'multi_' &&
this.config.multi_double_tap_action
) {
doubleTapWindow = this.renderTemplate(
this.config.multi_double_tap_action
?.double_tap_window ?? DOUBLE_TAP_WINDOW,
) as number;
}
const doubleTapWindow =
(this.renderTemplate(
this.config[doubleTapAction]?.double_tap_window ??
(this.config.double_tap_action
?.double_tap_window as number),
) as number) ?? DOUBLE_TAP_WINDOW;
this.clickTimer = setTimeout(() => {
this.fireHapticEvent('light');
this.sendAction(`${multiPrefix}tap_action`);

// DEBUG REMOVE LATER
const clickCount = this.clickCount;
const touchesCount = this.targetTouches?.length ?? 0;
setTimeout(() => {
alert(
`Clicks: ${clickCount}\nTouches: ${touchesCount}`,
);
}, 1000);
this.endAction();
}, doubleTapWindow);
}
Expand Down Expand Up @@ -230,19 +228,19 @@ export class RemoteTouchpad extends BaseRemoteElement {
}

endAction() {
clearTimeout(this.holdTimer as ReturnType<typeof setTimeout>);
clearInterval(this.holdInterval as ReturnType<typeof setInterval>);
clearTimeout(this.clickTimer as ReturnType<typeof setTimeout>);
this.clickTimer = undefined;
this.clickCount = 0;

clearTimeout(this.holdTimer as ReturnType<typeof setTimeout>);
clearInterval(this.holdInterval as ReturnType<typeof setInterval>);
this.holdTimer = undefined;
this.holdInterval = undefined;
this.clickTimer = undefined;

this.hold = false;
this.holdStart = false;
this.holdMove = false;
this.direction = undefined;
this.clickCount = 0;

super.endAction();
}
Expand Down

0 comments on commit 201bcb9

Please sign in to comment.