修改按钮控制

This commit is contained in:
lixiaopeng
2022-09-01 17:45:33 +08:00
parent e5fe556c92
commit 3cda59195c

View File

@@ -233,7 +233,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
return true;
}
Log.e("liyz", "onKeyDown keyCode = " + keyCode + "--action = " + event.getAction() + "---" + event);
// Log.e("liyz", "onKeyDown keyCode = " + keyCode + "--action = " + event.getAction() + "---" + event);
return super.onKeyDown(keyCode, event);
}
@@ -246,15 +246,15 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
numberA++;
if (numberA > 2) {
if (!isLongPressA) {
ToastUtils.showShort("方块 长按A -1 ");
sendAcc(true, -1);
// ToastUtils.showShort("方块 长按A -2 ");
sendAcc(true, -2);
isLongPressA = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberA == 1) {
ToastUtils.showShort("方块 击A ← 向左变道 ");
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneLeft();
// ToastUtils.showShort("方块 击A -1 ");
sendAcc(true, -1);
}
numberA = 0;
isLongPressA = false;
@@ -265,15 +265,14 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
numberB++;
if (numberB > 2) {
if (!isLongPressB) {
ToastUtils.showShort("方块 长按B -2 ");
sendAcc(true, -2);
// ToastUtils.showShort("方块 长按B 无操作 ");
isLongPressB = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberB == 1) {
ToastUtils.showShort("方块 单击B → 向右变道 ");
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneRight();
// ToastUtils.showShort("方块 单击B 复原 ");
sendAcc(false, 0.0);
}
numberB = 0;
isLongPressB = false;
@@ -284,24 +283,14 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
numberC++;
if (numberC > 2) {
if (!isLongPressC) {
ToastUtils.showShort("方块 长按 C ");
// ToastUtils.showShort("方块 长按C 无操作");
isLongPressC = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberC == 1) {
ToastUtils.showShort("方块 单击C 单击鸣笛 ");
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(1);
if (timerHorn == null) {
timerHorn = new Timer();
}
timerHorn.schedule(new TimerTask() {
@Override
public void run() {
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(2);
timerHorn = null;
}
}, 500);
// ToastUtils.showShort("方块 单击C ← 向左变道 ");
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneLeft();
}
numberC = 0;
isLongPressC = false;
@@ -312,14 +301,14 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
numberD++;
if (numberD > 2) {
if (!isLongPressD) {
ToastUtils.showShort("方块 长按 D ");
// ToastUtils.showShort("方块 长按D 无操作");
isLongPressD = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberD == 1) {
ToastUtils.showShort("方块 单击D 开启自动驾驶 ");
CallerAutoPilotManager.INSTANCE.setControlAutopilotCarAuto(true);
// ToastUtils.showShort("方块 单击D → 向右变道 ");
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneRight();
}
numberD = 0;
isLongPressD = false;
@@ -330,14 +319,25 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
numberE++;
if (numberE > 2) {
if (!isLongPressE) {
ToastUtils.showShort("方块 长按 E ");
// ToastUtils.showShort("方块 长按E 鸣笛 ");
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(1);
if (timerHorn == null) {
timerHorn = new Timer();
}
timerHorn.schedule(new TimerTask() {
@Override
public void run() {
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(2);
timerHorn = null;
}
}, 500);
isLongPressE = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberE == 1) {
ToastUtils.showShort("方块 单击E 复原 ");
sendAcc(false, 0.0);
// ToastUtils.showShort("方块 单击E 开启自动驾驶 ");
CallerAutoPilotManager.INSTANCE.setControlAutopilotCarAuto(true);
}
numberE = 0;
isLongPressE = false;