Browse Source

finish music control

screenshot
Backpack 2 months ago
parent
commit
8ed4a68e12
1 changed files with 62 additions and 34 deletions
  1. +62
    -34
      src/hand_landmark/gesture_handler.ts

+ 62
- 34
src/hand_landmark/gesture_handler.ts View File

@ -368,18 +368,20 @@ export class GestureHandler {
}
}
/**
*
*/
private handleDelete() {
const now = Date.now();
if (now - this.lastDeleteTime < 300) {
return;
}
this.lastDeleteTime = now;
this.triggerAction.sendKeys("backspace");
}
// /**
// * 处理删除手势
// */
// private handleDelete() {
// const now = Date.now();
// if (now - this.lastDeleteTime < 300) {
// return;
// }
// this.lastDeleteTime = now;
// this.triggerAction.sendKeys("backspace");
// }
/////////////////////游戏/////////////////////////
// // 键盘长按 -> 人物移动
// private handleArrowRight() {
// const now = Date.now();
@ -390,39 +392,65 @@ export class GestureHandler {
// this.holdKey("right", 50);
// }
// 音乐播放 下一曲
private handleArrowRight() {
// // 人物跳跃
// private handleJump() {
// const now = Date.now();
// if (now - this.lastDeleteTime < 300) {
// return;
// }
// this.lastDeleteTime = now;
// this.holdKey("up", 20); // 模拟上键长按
// }
// // 人物动跳
// private handleRightJump() {
// const now = Date.now();
// if (now - this.lastDeleteTime < 300) {
// return;
// }
// this.lastDeleteTime = now;
// // 先按右,再按上,模拟组合跳跃(可根据游戏实际逻辑调整)
// this.holdKey("right", 50);
// setTimeout(() => {
// this.holdKey("up", 20);
// }, 100); // 延迟一点时间再跳
// }
// 音乐播放 上一曲
private handleDelete() {
const now = Date.now();
if (now - this.lastDeleteTime < 300) {
return;
return;
}
this.lastDeleteTime = now;
this.triggerAction.sendKeys("ctrl+right");
this.triggerAction.sendKeys("ctrl+alt+left");
}
// 人物跳跃
private handleJump() {
// 音乐播放 下一曲
private handleArrowRight() {
const now = Date.now();
if (now - this.lastDeleteTime < 300) {
return;
}
this.lastDeleteTime = now;
this.holdKey("up", 20); // 模拟上键长按
this.triggerAction.sendKeys("ctrl+alt+right");
}
// 音乐暂停
private _jumpLock = false;
private handleJump() {
if (this._jumpLock) return;
// 人物动跳
private handleRightJump() {
const now = Date.now();
if (now - this.lastDeleteTime < 300) {
return;
}
this.lastDeleteTime = now;
// 先按右,再按上,模拟组合跳跃(可根据游戏实际逻辑调整)
this.holdKey("right", 50);
this._jumpLock = true;
this.triggerAction.sendKeys("ctrl+alt+p");
// 解锁时间:3 秒后
setTimeout(() => {
this.holdKey("up", 20);
}, 100); // 延迟一点时间再跳
}
this._jumpLock = false;
}, 3000);
}
/**
*
@ -530,9 +558,9 @@ export class GestureHandler {
this.handleJump();
break;
case HandGesture.RIGHTJUMP:
this.handleRightJump();
break;
// case HandGesture.RIGHTJUMP:
// this.handleRightJump();
// break;
}
}

Loading…
Cancel
Save