mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-30 19:33:45 +08:00
Add CC Main and LKAS buttons to Wheel Controls
Clean up so all buttons are handled from wheel controls
This commit is contained in:
@@ -223,6 +223,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
{"CustomPersonalities", {PERSISTENT, BOOL, "0", "0", 2}},
|
||||
{"CancelButtonControl", {PERSISTENT, INT, "1", "0", 2}},
|
||||
{"CancelButtonControlsMigrated", {PERSISTENT, BOOL, "0", "0"}},
|
||||
{"AOLLKASMigratedToButtonControl", {PERSISTENT, BOOL, "0", "0"}},
|
||||
{"TrafficPersonalityProfile", {PERSISTENT, BOOL, "1", "1", 2}},
|
||||
{"AggressivePersonalityProfile", {PERSISTENT, BOOL, "1", "1", 2}},
|
||||
{"StandardPersonalityProfile", {PERSISTENT, BOOL, "1", "1", 2}},
|
||||
@@ -368,6 +369,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
{"LongitudinalTune", {PERSISTENT, BOOL, "1", "0", 0}},
|
||||
{"LoudBlindspotAlert", {PERSISTENT, BOOL, "0", "0", 0}},
|
||||
{"LowVoltageShutdown", {PERSISTENT, FLOAT, "11.8", "11.8", 3}},
|
||||
{"MainCruiseButtonControl", {PERSISTENT, INT, "9", "9", 2}},
|
||||
{"ManualUpdateInitiated", {CLEAR_ON_MANAGER_START, BOOL, "0", "0"}},
|
||||
{"AMapKey1", {PERSISTENT | DONT_LOG, STRING, "", "", 0}},
|
||||
{"AMapKey2", {PERSISTENT | DONT_LOG, STRING, "", "", 0}},
|
||||
|
||||
@@ -243,7 +243,8 @@ class CarInterfaceBase(ABC):
|
||||
if hyundai_has_lda_button:
|
||||
fp_ret.safetyConfigs[-1].safetyParam |= HyundaiStarPilotSafetyFlags.HAS_LDA_BUTTON.value
|
||||
|
||||
if params.get_bool("AlwaysOnLateral") and params.get_bool("AlwaysOnLateralLKAS"):
|
||||
# LKASButtonControl == 9 means BUTTON_FUNCTIONS["AOL_TOGGLE"] in starpilot_variables.
|
||||
if params.get_bool("AlwaysOnLateral") and params.get_int("LKASButtonControl") == 9:
|
||||
fp_ret.safetyConfigs[-1].safetyParam |= HyundaiStarPilotSafetyFlags.AOL_LKAS_ON_ENGAGE.value
|
||||
elif platform in TOYOTA:
|
||||
fp_ret.canUsePedal = not CP.autoResumeSng
|
||||
|
||||
@@ -150,11 +150,6 @@ class StarPilotLateralLayout(_SettingsPage):
|
||||
subtitle=tr_noop("Keep lateral control active even without openpilot engaged."),
|
||||
get_state=lambda: self._params.get_bool("AlwaysOnLateral"),
|
||||
set_state=lambda s: _confirm_reboot_toggle(self._params, "AlwaysOnLateral", s) if s else self._params.put_bool("AlwaysOnLateral", False)),
|
||||
SettingRow("AlwaysOnLateralLKAS", "toggle", tr_noop("Enable With LKAS"),
|
||||
subtitle="",
|
||||
get_state=lambda: self._params.get_bool("AlwaysOnLateralLKAS"),
|
||||
set_state=lambda s: self._params.put_bool("AlwaysOnLateralLKAS", s),
|
||||
visible=lambda: self._params.get_bool("AlwaysOnLateral") and starpilot_state.car_state.lkasAllowedForAOL),
|
||||
SettingRow("PauseAOLOnBrake", "value", tr_noop("Pause Below"),
|
||||
subtitle="",
|
||||
get_value=lambda: f"{self._params.get_int('PauseAOLOnBrake')} mph",
|
||||
|
||||
@@ -49,6 +49,8 @@ ACTION_OPTIONS = [
|
||||
{"id": 6, "name": tr_noop("Toggle Traffic"), "requires_longitudinal": True},
|
||||
{"id": 7, "name": tr_noop("Toggle Switchback")},
|
||||
{"id": 8, "name": tr_noop("Create Bookmark")},
|
||||
{"id": 9, "name": tr_noop("Toggle Always On Lateral")},
|
||||
{"id": 10, "name": tr_noop("Adopt Current Speed Limit")},
|
||||
]
|
||||
ACTION_NAMES = [o["name"] for o in ACTION_OPTIONS]
|
||||
ACTION_IDS = {o["name"]: o["id"] for o in ACTION_OPTIONS}
|
||||
@@ -144,8 +146,8 @@ class VehicleSettingsManagerView(AetherInteractiveMixin, Widget):
|
||||
if cs.isHKGCanFd and cs.hasOpenpilotLongitudinal: count += 1
|
||||
return tr("{} settings").format(count)
|
||||
if tab_id == "controls":
|
||||
count = 7
|
||||
if not cs.isSubaru and not (cs.lkasAllowedForAOL and self._controller._params.get_bool("AlwaysOnLateral") and self._controller._params.get_bool("AlwaysOnLateralLKAS")):
|
||||
count = 8
|
||||
if not cs.isSubaru:
|
||||
count += 1
|
||||
if cs.hasModeStarButtons: count += 6
|
||||
return tr("{} buttons").format(count)
|
||||
@@ -426,9 +428,11 @@ class VehicleSettingsManagerView(AetherInteractiveMixin, Widget):
|
||||
for key in ("CancelButtonControl", "LongCancelButtonControl", "VeryLongCancelButtonControl"):
|
||||
rows.append({"target_id": f"select:{key}", "type": "select", "title": tr(self._controller._action_title(key)),
|
||||
"get_value": lambda k=key: self._controller._get_action_name(k), "pill_width": 140})
|
||||
if not cs.isSubaru and not (cs.lkasAllowedForAOL and self._controller._params.get_bool("AlwaysOnLateral") and self._controller._params.get_bool("AlwaysOnLateralLKAS")):
|
||||
if not cs.isSubaru:
|
||||
rows.append({"target_id": "select:LKASButtonControl", "type": "select", "title": tr("LKAS Button"),
|
||||
"get_value": lambda: self._controller._get_action_name("LKASButtonControl"), "pill_width": 140})
|
||||
rows.append({"target_id": "select:MainCruiseButtonControl", "type": "select", "title": tr("CC Main Button"),
|
||||
"get_value": lambda: self._controller._get_action_name("MainCruiseButtonControl"), "pill_width": 140})
|
||||
if cs.hasModeStarButtons:
|
||||
for key in ("ModeButtonControl", "LongModeButtonControl", "VeryLongModeButtonControl",
|
||||
"StarButtonControl", "LongStarButtonControl", "VeryLongStarButtonControl"):
|
||||
@@ -453,6 +457,7 @@ class StarPilotVehicleSettingsLayout(_SettingsPage):
|
||||
"VeryLongCancelButtonControl": "Cancel (Very Long)",
|
||||
"VeryLongDistanceButtonControl": "Distance (Very Long)",
|
||||
"LKASButtonControl": "LKAS Button",
|
||||
"MainCruiseButtonControl": "CC Main Button",
|
||||
"ModeButtonControl": "Mode Button",
|
||||
"LongModeButtonControl": "Mode (Long Press)",
|
||||
"VeryLongModeButtonControl": "Mode (Very Long)",
|
||||
@@ -468,7 +473,14 @@ class StarPilotVehicleSettingsLayout(_SettingsPage):
|
||||
|
||||
def _get_available_actions(self, key: str | None = None) -> list[str]:
|
||||
cs = starpilot_state.car_state
|
||||
return [tr(o["name"]) for o in ACTION_OPTIONS if cs.hasOpenpilotLongitudinal or not o.get("requires_longitudinal", False)]
|
||||
if key == "MainCruiseButtonControl":
|
||||
allowed_ids = {0, 9, 10}
|
||||
return [tr(o["name"]) for o in ACTION_OPTIONS if o["id"] in allowed_ids]
|
||||
allowed_ids = set(range(9))
|
||||
if key == "LKASButtonControl" and cs.lkasAllowedForAOL:
|
||||
allowed_ids.add(9)
|
||||
return [tr(o["name"]) for o in ACTION_OPTIONS
|
||||
if o["id"] in allowed_ids and (cs.hasOpenpilotLongitudinal or not o.get("requires_longitudinal", False))]
|
||||
|
||||
def _on_toggle(self, param_key: str):
|
||||
if param_key == "DisableOpenpilotLongitudinal":
|
||||
|
||||
@@ -135,6 +135,8 @@ BUTTON_FUNCTIONS = {
|
||||
"TRAFFIC_MODE": 6,
|
||||
"SWITCHBACK_MODE": 7,
|
||||
"BOOKMARK": 8,
|
||||
"AOL_TOGGLE": 9,
|
||||
"SLC_ADOPT": 10,
|
||||
}
|
||||
|
||||
CANCEL_BUTTON_MIGRATION_KEY = "CancelButtonControlsMigrated"
|
||||
@@ -144,6 +146,8 @@ CANCEL_BUTTON_MAPPINGS = (
|
||||
("VeryLongDistanceButtonControl", "VeryLongCancelButtonControl"),
|
||||
)
|
||||
|
||||
AOL_LKAS_MIGRATION_KEY = "AOLLKASMigratedToButtonControl"
|
||||
|
||||
DEVELOPER_SIDEBAR_METRICS = {
|
||||
"NONE": 0,
|
||||
"ACCELERATION_CURRENT": 1,
|
||||
@@ -341,12 +345,26 @@ def migrate_cancel_button_controls(params: Params | None = None) -> bool:
|
||||
params.put_bool(CANCEL_BUTTON_MIGRATION_KEY, True)
|
||||
return True
|
||||
|
||||
|
||||
def migrate_aol_lkas_to_button_control(params: Params | None = None) -> bool:
|
||||
params = params or Params(return_defaults=True)
|
||||
if params.get_bool(AOL_LKAS_MIGRATION_KEY):
|
||||
return False
|
||||
|
||||
if params.get_bool("AlwaysOnLateral") and params.get_bool("AlwaysOnLateralLKAS"):
|
||||
params.put_int("LKASButtonControl", BUTTON_FUNCTIONS["AOL_TOGGLE"])
|
||||
|
||||
params.put_bool(AOL_LKAS_MIGRATION_KEY, True)
|
||||
return True
|
||||
|
||||
|
||||
class StarPilotVariables:
|
||||
def __init__(self):
|
||||
self.params = Params(return_defaults=True)
|
||||
self.params_raw = Params()
|
||||
self.params_memory = Params(memory=True)
|
||||
migrate_cancel_button_controls(self.params)
|
||||
migrate_aol_lkas_to_button_control(self.params)
|
||||
|
||||
self.starpilot_toggles = SimpleNamespace()
|
||||
toggle = self.starpilot_toggles
|
||||
@@ -665,10 +683,15 @@ class StarPilotVariables:
|
||||
toggle.warningImmediate_volume = max(self.get_value("WarningImmediateVolume", cast=float, condition=toggle.alert_volume_controller, default=25), 25)
|
||||
|
||||
toggle.always_on_lateral = self.get_value("AlwaysOnLateral")
|
||||
toggle.always_on_lateral_lkas = toggle.always_on_lateral and toggle.lkas_allowed_for_aol and self.get_value("AlwaysOnLateralLKAS")
|
||||
lkas_button_assigned_to_aol = self.get_value("LKASButtonControl", cast=float) == BUTTON_FUNCTIONS["AOL_TOGGLE"]
|
||||
toggle.always_on_lateral_lkas = toggle.always_on_lateral and toggle.lkas_allowed_for_aol and lkas_button_assigned_to_aol
|
||||
toggle.always_on_lateral_main = toggle.always_on_lateral and not prohibited_main_aol and not toggle.always_on_lateral_lkas
|
||||
toggle.always_on_lateral_pause_speed = self.get_value("PauseAOLOnBrake", cast=float, condition=toggle.always_on_lateral)
|
||||
|
||||
main_cruise_button_control = self.get_value("MainCruiseButtonControl", cast=float)
|
||||
toggle.main_cruise_aol_toggle = main_cruise_button_control == BUTTON_FUNCTIONS["AOL_TOGGLE"]
|
||||
toggle.main_cruise_slc_adopt = main_cruise_button_control == BUTTON_FUNCTIONS["SLC_ADOPT"]
|
||||
|
||||
toggle.automatic_updates = self.get_value("AutomaticUpdates") and not BACKUP_PATH.is_file()
|
||||
|
||||
car_model = normalize_legacy_car_model(self.params.get("CarModel"))
|
||||
|
||||
@@ -85,9 +85,6 @@ class StarPilotCard:
|
||||
|
||||
def update(self, carState, starpilotCarState, sm, starpilot_toggles):
|
||||
self.switchback_mode_enabled = self.params_memory.get_bool("SwitchbackModeEnabled")
|
||||
hyundai_main_cruise_can_toggle_aol = self.CP.brand == "hyundai" and starpilot_toggles.always_on_lateral and (
|
||||
starpilot_toggles.always_on_lateral_lkas or starpilot_toggles.always_on_lateral_main
|
||||
)
|
||||
|
||||
if self.CP.brand == "hyundai" or starpilot_toggles.lkas_allowed_for_aol:
|
||||
for be in carState.buttonEvents:
|
||||
@@ -96,12 +93,9 @@ class StarPilotCard:
|
||||
if carState.cruiseState.enabled or self.pause_lateral:
|
||||
self.pause_lateral = not self.always_on_lateral_allowed
|
||||
elif be.type == ButtonType.mainCruise and be.pressed:
|
||||
# Hyundai owners use both the LKAS button and the cruise main button
|
||||
# as AOL engage inputs. Keep the safety-derived LKAS capability while
|
||||
# still honoring the cruise main button as a shared AOL toggle.
|
||||
if hyundai_main_cruise_can_toggle_aol or starpilot_toggles.always_on_lateral_main:
|
||||
if starpilot_toggles.main_cruise_aol_toggle or starpilot_toggles.always_on_lateral_main:
|
||||
self.always_on_lateral_allowed = not self.always_on_lateral_allowed
|
||||
elif starpilot_toggles.speed_limit_controller:
|
||||
elif starpilot_toggles.main_cruise_slc_adopt and starpilot_toggles.speed_limit_controller:
|
||||
self.params_memory.put_bool("SLCAdoptSpeedLimit", True)
|
||||
elif starpilot_toggles.always_on_lateral_main:
|
||||
if pacifica_hybrid_aol_requires_set_press(self.CP.carFingerprint, self.CP.pcmCruise):
|
||||
|
||||
@@ -55,6 +55,8 @@ def make_toggles(**overrides):
|
||||
"experimental_mode_via_lkas": False,
|
||||
"force_coast_via_lkas": False,
|
||||
"lkas_allowed_for_aol": False,
|
||||
"main_cruise_aol_toggle": False,
|
||||
"main_cruise_slc_adopt": False,
|
||||
"pause_lateral_via_lkas": False,
|
||||
"pause_longitudinal_via_lkas": False,
|
||||
"speed_limit_controller": False,
|
||||
@@ -116,7 +118,7 @@ def test_hyundai_lkas_button_still_toggles_aol_with_cruise_button_events(monkeyp
|
||||
assert ret.pauseLateral is False
|
||||
|
||||
|
||||
def test_hyundai_main_cruise_button_toggles_aol_while_lkas_mode_is_enabled(monkeypatch, tmp_path):
|
||||
def test_hyundai_main_cruise_button_toggles_aol_when_assigned_to_aol(monkeypatch, tmp_path):
|
||||
monkeypatch.setattr(spc, "Params", FakeParams)
|
||||
monkeypatch.setattr(spc, "is_FrogsGoMoo", lambda: False)
|
||||
monkeypatch.setattr(spc, "ERROR_LOGS_PATH", tmp_path)
|
||||
@@ -126,7 +128,7 @@ def test_hyundai_main_cruise_button_toggles_aol_while_lkas_mode_is_enabled(monke
|
||||
car_state = make_car_state(button_events=[SimpleNamespace(type=spc.ButtonType.mainCruise, pressed=True)])
|
||||
starpilot_car_state = SimpleNamespace(distancePressed=False)
|
||||
sm = make_sm()
|
||||
toggles = make_toggles(always_on_lateral=True, always_on_lateral_lkas=True)
|
||||
toggles = make_toggles(always_on_lateral=True, always_on_lateral_lkas=True, main_cruise_aol_toggle=True)
|
||||
|
||||
ret = card.update(car_state, starpilot_car_state, sm, toggles)
|
||||
assert ret.alwaysOnLateralAllowed is True
|
||||
@@ -135,6 +137,26 @@ def test_hyundai_main_cruise_button_toggles_aol_while_lkas_mode_is_enabled(monke
|
||||
assert ret.alwaysOnLateralAllowed is False
|
||||
|
||||
|
||||
def test_hyundai_main_cruise_button_adopts_slc_when_assigned_to_slc(monkeypatch, tmp_path):
|
||||
monkeypatch.setattr(spc, "Params", FakeParams)
|
||||
monkeypatch.setattr(spc, "is_FrogsGoMoo", lambda: False)
|
||||
monkeypatch.setattr(spc, "ERROR_LOGS_PATH", tmp_path)
|
||||
|
||||
card = spc.StarPilotCard(SimpleNamespace(brand="hyundai"), SimpleNamespace(alternativeExperience=0))
|
||||
|
||||
car_state = make_car_state(button_events=[SimpleNamespace(type=spc.ButtonType.mainCruise, pressed=True)])
|
||||
starpilot_car_state = SimpleNamespace(distancePressed=False)
|
||||
sm = make_sm()
|
||||
toggles = make_toggles(always_on_lateral=True, always_on_lateral_lkas=True,
|
||||
main_cruise_slc_adopt=True, speed_limit_controller=True)
|
||||
|
||||
initial_allowed = card.always_on_lateral_allowed
|
||||
card.update(car_state, starpilot_car_state, sm, toggles)
|
||||
|
||||
assert card.always_on_lateral_allowed is initial_allowed
|
||||
assert card.params_memory.get_bool("SLCAdoptSpeedLimit") is True
|
||||
|
||||
|
||||
def test_honda_lkas_button_pauses_lateral_when_cruise_is_active(monkeypatch, tmp_path):
|
||||
monkeypatch.setattr(spc, "Params", FakeParams)
|
||||
monkeypatch.setattr(spc, "is_FrogsGoMoo", lambda: False)
|
||||
|
||||
@@ -97,14 +97,6 @@
|
||||
"ui_type": "toggle",
|
||||
"is_parent_toggle": true
|
||||
},
|
||||
{
|
||||
"key": "AlwaysOnLateralLKAS",
|
||||
"label": "Enable With LKAS",
|
||||
"description": "Enable \"Always On Lateral\" whenever \"LKAS\" is on, even when openpilot is not engaged.",
|
||||
"data_type": "bool",
|
||||
"ui_type": "toggle",
|
||||
"parent_key": "AlwaysOnLateral"
|
||||
},
|
||||
{
|
||||
"key": "PauseAOLOnBrake",
|
||||
"label": "Pause on Brake Press Below",
|
||||
@@ -2693,6 +2685,31 @@
|
||||
{
|
||||
"value": 8,
|
||||
"label": "Create Bookmark"
|
||||
},
|
||||
{
|
||||
"value": 9,
|
||||
"label": "Toggle Always On Lateral"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "MainCruiseButtonControl",
|
||||
"label": "CC Main Button",
|
||||
"description": "Action performed when the cruise control main button is pressed.",
|
||||
"data_type": "int",
|
||||
"ui_type": "dropdown",
|
||||
"options": [
|
||||
{
|
||||
"value": 0,
|
||||
"label": "No Action"
|
||||
},
|
||||
{
|
||||
"value": 9,
|
||||
"label": "Toggle Always On Lateral"
|
||||
},
|
||||
{
|
||||
"value": 10,
|
||||
"label": "Adopt Current Speed Limit"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -42,7 +42,6 @@ StarPilotLateralPanel::StarPilotLateralPanel(StarPilotSettingsWindow *parent, bo
|
||||
{"ForceTorqueController", tr("Force Torque Controller"), tr("<b>Use torque-based steering control instead of angle-based control for smoother lane keeping, especially in curves.</b>"), ""},
|
||||
|
||||
{"AlwaysOnLateral", tr("Always On Lateral"), tr("<b>openpilot's steering remains active even when the accelerator or brake pedals are pressed.</b>"), "../../starpilot/assets/toggle_icons/icon_always_on_lateral.png"},
|
||||
{"AlwaysOnLateralLKAS", tr("Enable With LKAS"), tr("<b>Enable \"Always On Lateral\" whenever \"LKAS\" is on, even when openpilot is not engaged.</b>"), ""},
|
||||
{"PauseAOLOnBrake", tr("Pause on Brake Press Below"), tr("<b>Pause \"Always On Lateral\" below the set speed while the brake pedal is pressed.</b>"), ""},
|
||||
|
||||
{"LaneChanges", tr("Lane Changes"), tr("<b>Allow openpilot to change lanes.</b>"), "../../starpilot/assets/toggle_icons/icon_lane.png"},
|
||||
@@ -358,11 +357,7 @@ void StarPilotLateralPanel::updateToggles() {
|
||||
bool setVisible = showAllToggles || parent->tuningLevel >= parent->starpilotToggleLevels[key].toDouble();
|
||||
|
||||
if (!showAllToggles) {
|
||||
if (key == "AlwaysOnLateralLKAS") {
|
||||
setVisible &= parent->lkasAllowedForAOL;
|
||||
}
|
||||
|
||||
else if (key == "ForceAutoTune") {
|
||||
if (key == "ForceAutoTune") {
|
||||
setVisible &= !parent->hasAutoTune;
|
||||
setVisible &= !parent->isAngleCar;
|
||||
setVisible &= parent->isTorqueCar || forcingTorqueController || usingNNFF;
|
||||
|
||||
@@ -25,7 +25,7 @@ private:
|
||||
std::map<QString, AbstractControl*> toggles;
|
||||
|
||||
QSet<QString> advancedLateralTuneKeys = {"ForceAutoTune", "ForceAutoTuneOff", "ForceTorqueController", "SteerDelay", "SteerFriction", "SteerLatAccel", "SteerKP", "SteerRatio"};
|
||||
QSet<QString> aolKeys = {"AlwaysOnLateralLKAS", "PauseAOLOnBrake"};
|
||||
QSet<QString> aolKeys = {"PauseAOLOnBrake"};
|
||||
QSet<QString> laneChangeKeys = {"LaneChangeSmoothing", "LaneChangeTime", "LaneDetectionWidth", "MinimumLaneChangeSpeed", "NudgelessLaneChange", "OneLaneChange"};
|
||||
QSet<QString> lateralTuneKeys = {"NNFF", "NNFFLite", "TurnDesires", "NavDesiresAllowed"};
|
||||
QSet<QString> qolKeys = {"PauseLateralSpeed", "LateralResumeDelay"};
|
||||
|
||||
@@ -30,8 +30,24 @@ QMap<int, QString> getMergedWheelFunctionsMap() {
|
||||
return functionsMap;
|
||||
}
|
||||
|
||||
QString getWheelFunctionLabel(Params ¶ms, const QString &key) {
|
||||
const QMap<int, QString> functionsMap = getMergedWheelFunctionsMap();
|
||||
QMap<int, QString> getMainCruiseFunctionsMap() {
|
||||
return {
|
||||
{0, QObject::tr("No Action")},
|
||||
{9, QObject::tr("Toggle Always On Lateral")},
|
||||
{10, QObject::tr("Adopt Current Speed Limit")},
|
||||
};
|
||||
}
|
||||
|
||||
QString getWheelFunctionLabel(Params ¶ms, const QString &key, bool lkasAllowedForAOL = false) {
|
||||
QMap<int, QString> functionsMap;
|
||||
if (key == "MainCruiseButtonControl") {
|
||||
functionsMap = getMainCruiseFunctionsMap();
|
||||
} else {
|
||||
functionsMap = getMergedWheelFunctionsMap();
|
||||
if (key == "LKASButtonControl" && lkasAllowedForAOL) {
|
||||
functionsMap[9] = QObject::tr("Toggle Always On Lateral");
|
||||
}
|
||||
}
|
||||
return functionsMap.value(params.getInt(key.toStdString()), QObject::tr("No Action"));
|
||||
}
|
||||
|
||||
@@ -63,6 +79,7 @@ StarPilotWheelPanel::StarPilotWheelPanel(StarPilotSettingsWindow *parent, bool f
|
||||
{"VeryLongCancelButtonControl", tr("Cancel Button (Very Long Press)"), tr("<b>Action performed when the remapped \"Cancel\" button is pressed for more than 2.5 seconds.</b>"), "../../starpilot/assets/toggle_icons/icon_mute.png"},
|
||||
{"VeryLongDistanceButtonControl", tr("Distance Button (Very Long Press)"), tr("<b>Action performed when the \"Distance\" button is pressed for more than 2.5 seconds.</b>"), "../../starpilot/assets/toggle_icons/icon_mute.png"},
|
||||
{"LKASButtonControl", tr("LKAS Button"), tr("<b>Action performed when the \"LKAS\" button is pressed.</b>"), "../../starpilot/assets/toggle_icons/icon_mute.png"},
|
||||
{"MainCruiseButtonControl", tr("CC Main Button"), tr("<b>Action performed when the cruise control main button is pressed.</b>"), "../../starpilot/assets/toggle_icons/icon_mute.png"},
|
||||
{"ModeButtonControl", tr("Mode Button"), tr("<b>Action performed when the \"Mode\" button is pressed.</b>"), "../../starpilot/assets/toggle_icons/icon_mute.png"},
|
||||
{"LongModeButtonControl", tr("Mode Button (Long Press)"), tr("<b>Action performed when the \"Mode\" button is pressed for more than 0.5 seconds.</b>"), "../../starpilot/assets/toggle_icons/icon_mute.png"},
|
||||
{"VeryLongModeButtonControl", tr("Mode Button (Very Long Press)"), tr("<b>Action performed when the \"Mode\" button is pressed for more than 2.5 seconds.</b>"), "../../starpilot/assets/toggle_icons/icon_mute.png"},
|
||||
@@ -74,11 +91,19 @@ StarPilotWheelPanel::StarPilotWheelPanel(StarPilotSettingsWindow *parent, bool f
|
||||
for (const auto &[param, title, desc, icon] : wheelToggles) {
|
||||
ButtonControl *wheelToggle = new ButtonControl(title, tr("SELECT"), desc);
|
||||
QObject::connect(wheelToggle, &ButtonControl::clicked, [key = param, parent, wheelToggle, this]() {
|
||||
QMap<int, QString> functionsMap = getWheelFunctionsMap();
|
||||
if (parent->hasOpenpilotLongitudinal) {
|
||||
const QMap<int, QString> longitudinalFunctionsMap = getLongitudinalWheelFunctionsMap();
|
||||
for (auto it = longitudinalFunctionsMap.constBegin(); it != longitudinalFunctionsMap.constEnd(); ++it) {
|
||||
functionsMap[it.key()] = it.value();
|
||||
QMap<int, QString> functionsMap;
|
||||
if (key == "MainCruiseButtonControl") {
|
||||
functionsMap = getMainCruiseFunctionsMap();
|
||||
} else {
|
||||
functionsMap = getWheelFunctionsMap();
|
||||
if (parent->hasOpenpilotLongitudinal) {
|
||||
const QMap<int, QString> longitudinalFunctionsMap = getLongitudinalWheelFunctionsMap();
|
||||
for (auto it = longitudinalFunctionsMap.constBegin(); it != longitudinalFunctionsMap.constEnd(); ++it) {
|
||||
functionsMap[it.key()] = it.value();
|
||||
}
|
||||
}
|
||||
if (key == "LKASButtonControl" && parent->lkasAllowedForAOL) {
|
||||
functionsMap[9] = tr("Toggle Always On Lateral");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +114,7 @@ StarPilotWheelPanel::StarPilotWheelPanel(StarPilotSettingsWindow *parent, bool f
|
||||
updateStarPilotToggles();
|
||||
}
|
||||
});
|
||||
wheelToggle->setValue(getWheelFunctionLabel(params, param));
|
||||
wheelToggle->setValue(getWheelFunctionLabel(params, param, parent->lkasAllowedForAOL));
|
||||
|
||||
toggles[param] = wheelToggle;
|
||||
|
||||
@@ -118,7 +143,6 @@ void StarPilotWheelPanel::updateToggles() {
|
||||
|
||||
if (!showAllToggles && key == "LKASButtonControl") {
|
||||
setVisible &= !parent->isSubaru;
|
||||
setVisible &= !parent->lkasAllowedForAOL || !(params.getBool("AlwaysOnLateral") && params.getBool("AlwaysOnLateralLKAS"));
|
||||
}
|
||||
|
||||
if (!showAllToggles && (
|
||||
@@ -146,7 +170,7 @@ void StarPilotWheelPanel::updateToggles() {
|
||||
}
|
||||
|
||||
if (ButtonControl *wheelToggle = qobject_cast<ButtonControl*>(toggle)) {
|
||||
wheelToggle->setValue(getWheelFunctionLabel(params, key));
|
||||
wheelToggle->setValue(getWheelFunctionLabel(params, key, parent->lkasAllowedForAOL));
|
||||
}
|
||||
|
||||
toggle->setVisible(setVisible);
|
||||
|
||||
Reference in New Issue
Block a user