Browse Source

fix rock mode

finalv3
Backpack 2 months ago
parent
commit
0c991f7163
1 changed files with 11 additions and 4 deletions
  1. +11
    -4
      src/hand_landmark/gesture_handler.ts

+ 11
- 4
src/hand_landmark/gesture_handler.ts View File

@ -500,6 +500,8 @@ export class GestureHandler {
* landmark * landmark
* fingerIndex: 0=, 1=, 2=, ... * fingerIndex: 0=, 1=, 2=, ...
*/ */
private lastModeSwitchTime: number = 0;
private readonly MODE_SWITCH_INTERVAL = 3000; // 3秒
private getFingerTip(hand: HandInfo, fingerIndex: number) { private getFingerTip(hand: HandInfo, fingerIndex: number) {
if (!hand) return null; if (!hand) return null;
@ -519,9 +521,14 @@ export class GestureHandler {
this.previousGestureCount = 1; this.previousGestureCount = 1;
} }
const app_store = use_app_store();
if (gesture === HandGesture.ROCK_SWITCH_MODE) {
const app_store = use_app_store();
if (gesture === HandGesture.ROCK_SWITCH_MODE) {
const now = Date.now();
if (now - this.lastModeSwitchTime >= this.MODE_SWITCH_INTERVAL) {
this.lastModeSwitchTime = now;
if (app_store.mode === 'normal') { if (app_store.mode === 'normal') {
app_store.mode = 'music'; app_store.mode = 'music';
app_store.sub_window_info("🎵 切换到音乐模式"); app_store.sub_window_info("🎵 切换到音乐模式");
@ -529,9 +536,9 @@ export class GestureHandler {
app_store.mode = 'normal'; app_store.mode = 'normal';
app_store.sub_window_info("💼 切换到普通模式"); app_store.sub_window_info("💼 切换到普通模式");
} }
return; // 切换后不继续处理其他手势
} }
return; // 不管有没有切换,都返回,不再处理其他手势
}

Loading…
Cancel
Save