From 0b8a6cf00e536e752871707b8b3494896420480e Mon Sep 17 00:00:00 2001 From: myperworld Date: Sat, 6 Dec 2025 11:27:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8D=95=E6=89=8B=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=89=8D=E5=90=8E=E5=B7=A6=E5=8F=B3=E8=BF=90=E5=8A=A8?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=88=E9=BE=99=E5=A4=B4=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v1.3/src/main.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/v1.3/src/main.cpp b/v1.3/src/main.cpp index 6af022b..1b27d2d 100644 --- a/v1.3/src/main.cpp +++ b/v1.3/src/main.cpp @@ -57,6 +57,8 @@ bool last_btnDirDown = 0; bool last_btnSelect = 0; bool last_btnStart = 0; bool last_btnShare = 0; +bool last_joyRHori = 0; +bool last_joyLHori = 0; /************实例定义*************/ @@ -1059,7 +1061,10 @@ void processControllerData(const XboxControllerNotificationParser& remoteData) { map(remoteData.joyLHori, 0, 65535, -100, 100), -100, 100 ); - if(abs(convertedJ1PotX) > deadZone) { // 左右运动 -100 到 100 + if(abs(convertedJ1PotX) > deadZone + && ( (last_joyLHori > 0 && ( remoteData.joyLHori- last_joyLHori)> 0 ) + || (last_joyLHori <0 && ( remoteData.joyLHori- last_joyLHori)< 0 ) + )) { // 左右运动 -100 到 100 wrobot.joyx = convertedJ1PotX; } else { wrobot.joyx = 0; @@ -1070,12 +1075,18 @@ void processControllerData(const XboxControllerNotificationParser& remoteData) { map(remoteData.joyRHori, 0, 65535, -100, 100), -100, 100 ); - if(abs(convertedJ2PotX) > deadZone) { // 左右运动 -100 到 100 + if(abs(convertedJ2PotX) > deadZone + && ( (last_joyRHori > 0 && ( remoteData.joyRHori- last_joyRHori)> 0 ) + || (last_joyRHori <0 && ( remoteData.joyRHori- last_joyRHori)< 0 ) + )) { // 左右运动 -100 到 100 wrobot.joyx = convertedJ2PotX * 0.3; } else { wrobot.joyx = 0; } } + last_joyRHori = remoteData.joyRHori; + last_joyLHori = remoteData.joyLHori; + // 智能计算wrobot.height ,根据前后速度, // convertedJ2PotY 范围-100到100,默认0,输出范围30(最矮)-50(最高), 默认 50