Controls - Experimental Mode Activation - Double Tap the UI
Enable/disable 'Experimental Mode' by double tapping the onroad UI within a 0.5 second time frame.
This commit is contained in:
parent
60ace13f77
commit
f7fc476f88
@ -6,6 +6,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
@ -66,6 +67,12 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent), scene(uiState()->
|
|||||||
QObject::connect(uiState(), &UIState::uiUpdate, this, &OnroadWindow::updateState);
|
QObject::connect(uiState(), &UIState::uiUpdate, this, &OnroadWindow::updateState);
|
||||||
QObject::connect(uiState(), &UIState::offroadTransition, this, &OnroadWindow::offroadTransition);
|
QObject::connect(uiState(), &UIState::offroadTransition, this, &OnroadWindow::offroadTransition);
|
||||||
QObject::connect(uiState(), &UIState::primeChanged, this, &OnroadWindow::primeChanged);
|
QObject::connect(uiState(), &UIState::primeChanged, this, &OnroadWindow::primeChanged);
|
||||||
|
|
||||||
|
QObject::connect(&clickTimer, &QTimer::timeout, this, [this]() {
|
||||||
|
clickTimer.stop();
|
||||||
|
QMouseEvent *event = new QMouseEvent(QEvent::MouseButtonPress, timeoutPoint, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
||||||
|
QApplication::postEvent(this, event);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnroadWindow::updateState(const UIState &s) {
|
void OnroadWindow::updateState(const UIState &s) {
|
||||||
@ -93,6 +100,24 @@ void OnroadWindow::updateState(const UIState &s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OnroadWindow::mousePressEvent(QMouseEvent* e) {
|
void OnroadWindow::mousePressEvent(QMouseEvent* e) {
|
||||||
|
// FrogPilot clickable widgets
|
||||||
|
if (scene.experimental_mode_via_screen && e->pos() != timeoutPoint) {
|
||||||
|
if (clickTimer.isActive()) {
|
||||||
|
clickTimer.stop();
|
||||||
|
|
||||||
|
if (scene.conditional_experimental) {
|
||||||
|
int override_value = (scene.conditional_status >= 1 && scene.conditional_status <= 6) ? 0 : (scene.conditional_status >= 7 ? 5 : 6);
|
||||||
|
paramsMemory.putIntNonBlocking("CEStatus", override_value);
|
||||||
|
} else {
|
||||||
|
bool experimentalMode = params.getBool("ExperimentalMode");
|
||||||
|
params.putBoolNonBlocking("ExperimentalMode", !experimentalMode);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
clickTimer.start(500);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MAPS
|
#ifdef ENABLE_MAPS
|
||||||
if (map != nullptr) {
|
if (map != nullptr) {
|
||||||
// Switch between map and sidebar when using navigate on openpilot
|
// Switch between map and sidebar when using navigate on openpilot
|
||||||
|
@ -207,6 +207,9 @@ private:
|
|||||||
Params params;
|
Params params;
|
||||||
Params paramsMemory{"/dev/shm/params"};
|
Params paramsMemory{"/dev/shm/params"};
|
||||||
|
|
||||||
|
QPoint timeoutPoint = QPoint(420, 69);
|
||||||
|
QTimer clickTimer;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void offroadTransition(bool offroad);
|
void offroadTransition(bool offroad);
|
||||||
void primeChanged(bool prime);
|
void primeChanged(bool prime);
|
||||||
|
@ -272,6 +272,8 @@ void ui_update_frogpilot_params(UIState *s) {
|
|||||||
bool driving_personalities = scene.longitudinal_control && params.getBool("DrivingPersonalities");
|
bool driving_personalities = scene.longitudinal_control && params.getBool("DrivingPersonalities");
|
||||||
scene.onroad_distance_button = driving_personalities && params.getBool("OnroadDistanceButton");
|
scene.onroad_distance_button = driving_personalities && params.getBool("OnroadDistanceButton");
|
||||||
scene.use_kaofui_icons = scene.onroad_distance_button && params.getBool("KaofuiIcons");
|
scene.use_kaofui_icons = scene.onroad_distance_button && params.getBool("KaofuiIcons");
|
||||||
|
|
||||||
|
scene.experimental_mode_via_screen = scene.longitudinal_control && params.getBool("ExperimentalModeActivation") && params.getBool("ExperimentalModeViaTap");
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIState::updateStatus() {
|
void UIState::updateStatus() {
|
||||||
|
@ -188,6 +188,7 @@ typedef struct UIScene {
|
|||||||
bool conditional_experimental;
|
bool conditional_experimental;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
bool experimental_mode;
|
bool experimental_mode;
|
||||||
|
bool experimental_mode_via_screen;
|
||||||
bool map_open;
|
bool map_open;
|
||||||
bool online;
|
bool online;
|
||||||
bool onroad_distance_button;
|
bool onroad_distance_button;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user