2.19
This commit is contained in:
parent
960a08f25d
commit
e3eea4bd54
@ -21,6 +21,7 @@ class GamepadController {
|
||||
this.directionAxis0_1 = "";
|
||||
this.directionAxis9 = "";
|
||||
this.angle = 0;
|
||||
this.rightJoystickPressed = false;
|
||||
// 初始化按钮状态
|
||||
this.buttons = this.options.buttonsConfig.map(button => ({
|
||||
...button,
|
||||
@ -104,22 +105,28 @@ class GamepadController {
|
||||
const axis9 = axes[9];
|
||||
const roundedAxis9 = Math.round(axis9 * 100) / 100;
|
||||
if (roundedAxis9 <= -0.9) {
|
||||
this.directionAxis9 = "上";
|
||||
this.directionAxis9 = 0;
|
||||
} else if (roundedAxis9 >= 0.0 && roundedAxis9 <= 0.2) {
|
||||
this.directionAxis9 = "下";
|
||||
} else if (roundedAxis9 >= 0.6 && roundedAxis9 <= 0.8) {
|
||||
this.directionAxis9 = "左";
|
||||
} else if (roundedAxis9 >= -0.5 && roundedAxis9 <= -0.4) {
|
||||
this.directionAxis9 = "右";
|
||||
} else {
|
||||
this.directionAxis9 = "未定义";
|
||||
this.directionAxis9 = 1;
|
||||
// } else if (roundedAxis9 >= 0.6 && roundedAxis9 <= 0.8) {
|
||||
// this.directionAxis9 = "左";
|
||||
// } else if (roundedAxis9 >= -0.5 && roundedAxis9 <= -0.4) {
|
||||
// this.directionAxis9 = "右";
|
||||
}
|
||||
else {
|
||||
this.directionAxis9 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pressKey(buttons) {
|
||||
this.buttons.forEach(button => {
|
||||
this.buttons.forEach(button => {
|
||||
const buttonData = buttons[button.index];
|
||||
button.pressed = buttonData ? buttonData.value === 1 : false;
|
||||
button.pressed = buttonData ? buttonData.value === 1 : false;
|
||||
|
||||
// 特别检查 Right Joystick Press 按钮
|
||||
if (button.name === "Right Joystick Press") {
|
||||
this.rightJoystickPressed = button.pressed;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,9 @@ export default {
|
||||
connectionCheckInterval: null,
|
||||
sendInterval: null,
|
||||
lastDirection: 0,
|
||||
lastSpeed: 0
|
||||
lastSpeed: 0,
|
||||
platform_fun:0,
|
||||
button:"",
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@ -219,12 +221,17 @@ export default {
|
||||
// 更新手柄数据
|
||||
updateGamepadData() {
|
||||
if (this.gamepadController) {
|
||||
// 直接获取 angle 值并打印验证
|
||||
// 获取手柄数据
|
||||
const angle = this.gamepadController.angle;
|
||||
console.log('当前角度:', angle);
|
||||
const directionAxis9 = this.gamepadController.directionAxis9;
|
||||
|
||||
// 更新控制按钮状态
|
||||
this.isControlPressed = this.gamepadController.rightJoystickPressed;
|
||||
|
||||
// 更新其他数据
|
||||
this.lastDirection = angle;
|
||||
// 这里可以添加速度的计算逻辑
|
||||
this.lastSpeed = 0; // 暂时设为0
|
||||
this.platform_fun = directionAxis9;
|
||||
this.lastSpeed = 0;
|
||||
}
|
||||
},
|
||||
sendCarInfo() {
|
||||
@ -290,7 +297,7 @@ export default {
|
||||
"get_info": 1,
|
||||
"get_attribute": 1,
|
||||
"function": {
|
||||
"platform_fun": 2,
|
||||
"platform_fun": this.platform_fun,
|
||||
"screen_en": this.screenStatus ? 1 : 0,
|
||||
"warn_light_en": this.warningLightStatus ? 1 : 0,
|
||||
"follow_en": this.followStatus ? 1 : 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user