Branch data Line data Source code
1 : : #include "GuiLayer.h"
2 : : #include "Version.h"
3 : : #include "Config.h"
4 : : #include "Tooltips.h"
5 : : #include "StringUtils.h" // Added StringUtils.h
6 : : #include "DirectInputFFB.h"
7 : : #include "GameConnector.h"
8 : : #include "GuiWidgets.h"
9 : : #include "AsyncLogger.h"
10 : : #include "VehicleUtils.h"
11 : : #include "HealthMonitor.h"
12 : : #include <iostream>
13 : : #include <vector>
14 : : #include <cmath>
15 : : #include <algorithm>
16 : : #include <mutex>
17 : : #include <chrono>
18 : : #include <ctime>
19 : : #include <filesystem>
20 : :
21 : : #ifdef ENABLE_IMGUI
22 : : #include "imgui.h"
23 : :
24 : : #ifdef _WIN32
25 : : #define WIN32_LEAN_AND_MEAN
26 : : #include <windows.h>
27 : : #endif
28 : :
29 : 372 : static void DisplayRate(const char* label, double rate, double target) {
30 [ + - ]: 372 : ImGui::Text("%s", label);
31 : :
32 : : // Status colors for performance metrics
33 : : static const ImVec4 COLOR_RED(1.0F, 0.4F, 0.4F, 1.0F);
34 : : static const ImVec4 COLOR_GREEN(0.4F, 1.0F, 0.4F, 1.0F);
35 : : static const ImVec4 COLOR_YELLOW(1.0F, 1.0F, 0.4F, 1.0F);
36 : :
37 : 372 : ImVec4 color = COLOR_RED;
38 [ + + ]: 372 : if (rate >= target * 0.95) {
39 : 6 : color = COLOR_GREEN;
40 [ - + ]: 366 : } else if (rate >= target * 0.75) {
41 : 0 : color = COLOR_YELLOW;
42 : : }
43 : :
44 [ + - ]: 372 : ImGui::TextColored(color, "%.1f Hz", rate);
45 : 372 : }
46 : :
47 : :
48 : : // External linkage to FFB loop status
49 : : extern std::atomic<bool> g_running;
50 : : extern std::recursive_mutex g_engine_mutex;
51 : :
52 : : float GuiLayer::m_latest_steering_range = 0.0f;
53 : : float GuiLayer::m_latest_steering_angle = 0.0f;
54 : :
55 : : static const float CONFIG_PANEL_WIDTH = 500.0f;
56 : : static const int LATENCY_WARNING_THRESHOLD_MS = 15;
57 : :
58 : : // Professional "Flat Dark" Theme
59 : 1 : void GuiLayer::SetupGUIStyle() {
60 [ + - ]: 1 : ImGuiStyle& style = ImGui::GetStyle();
61 : :
62 : 1 : style.WindowRounding = 5.0f;
63 : 1 : style.ChildRounding = 5.0f;
64 : 1 : style.PopupRounding = 5.0f;
65 : 1 : style.FrameRounding = 4.0f;
66 : 1 : style.GrabRounding = 4.0f;
67 : 1 : style.WindowPadding = ImVec2(10, 10);
68 : 1 : style.FramePadding = ImVec2(8, 4);
69 : 1 : style.ItemSpacing = ImVec2(8, 6);
70 : :
71 : 1 : ImVec4* colors = style.Colors;
72 : :
73 : 1 : colors[ImGuiCol_WindowBg] = ImVec4(0.12f, 0.12f, 0.12f, 1.00f);
74 : 1 : colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f);
75 : 1 : colors[ImGuiCol_PopupBg] = ImVec4(0.15f, 0.15f, 0.15f, 0.98f);
76 : :
77 : 1 : colors[ImGuiCol_Header] = ImVec4(0.20f, 0.20f, 0.20f, 0.00f);
78 : 1 : colors[ImGuiCol_HeaderHovered] = ImVec4(0.25f, 0.25f, 0.25f, 0.50f);
79 : 1 : colors[ImGuiCol_HeaderActive] = ImVec4(0.30f, 0.30f, 0.30f, 0.50f);
80 : :
81 : 1 : colors[ImGuiCol_FrameBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
82 : 1 : colors[ImGuiCol_FrameBgHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
83 : 1 : colors[ImGuiCol_FrameBgActive] = ImVec4(0.30f, 0.30f, 0.30f, 1.00f);
84 : :
85 : 1 : ImVec4 accent = ImVec4(0.00f, 0.60f, 0.85f, 1.00f);
86 : 1 : colors[ImGuiCol_SliderGrab] = accent;
87 : 1 : colors[ImGuiCol_SliderGrabActive] = ImVec4(0.00f, 0.70f, 0.95f, 1.00f);
88 : 1 : colors[ImGuiCol_Button] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
89 : 1 : colors[ImGuiCol_ButtonHovered] = accent;
90 : 1 : colors[ImGuiCol_ButtonActive] = ImVec4(0.00f, 0.50f, 0.75f, 1.00f);
91 : 1 : colors[ImGuiCol_CheckMark] = accent;
92 : :
93 : 1 : colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
94 : 1 : colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
95 : 1 : colors[ImGuiCol_MenuBarBg] = ImVec4(0.12f, 0.12f, 0.12f, 1.00f);
96 : 1 : }
97 : :
98 : 1 : void GuiLayer::DrawMenuBar(FFBEngine& engine) {
99 [ + - ]: 1 : if (ImGui::BeginMainMenuBar()) {
100 [ - + ]: 1 : if (ImGui::BeginMenu("Logs")) {
101 [ # # ]: 0 : if (ImGui::MenuItem("Analyze last log")) {
102 : : namespace fs = std::filesystem;
103 : 0 : fs::path latest_path;
104 : 0 : fs::file_time_type latest_time;
105 : 0 : bool found = false;
106 : :
107 [ # # # # : 0 : fs::path search_path = Config::m_log_path.empty() ? "." : Config::m_log_path;
# # # # #
# # # ]
108 : :
109 : : try {
110 [ # # # # ]: 0 : if (fs::exists(search_path)) {
111 [ # # # # : 0 : for (const auto& entry : fs::directory_iterator(search_path)) {
# # ]
112 [ # # # # ]: 0 : if (entry.is_regular_file()) {
113 [ # # # # ]: 0 : std::string filename = entry.path().filename().string();
114 : 0 : bool looks_like_log = filename.find("lmuffb_log_") == 0;
115 [ # # # # : 0 : bool has_ext = (filename.length() >= 4 && (filename.substr(filename.length() - 4) == ".bin" || filename.substr(filename.length() - 4) == ".csv"));
# # # # #
# # # # #
# # # # #
# # # ]
116 [ # # # # ]: 0 : if (looks_like_log && has_ext) {
117 [ # # ]: 0 : auto ftime = fs::last_write_time(entry);
118 [ # # # # : 0 : if (!found || ftime > latest_time) {
# # # # ]
119 : 0 : latest_time = ftime;
120 [ # # ]: 0 : latest_path = entry.path();
121 : 0 : found = true;
122 : : }
123 : : }
124 : 0 : }
125 : 0 : }
126 : : }
127 [ - - ]: 0 : } catch (const std::exception& e) {
128 [ - - - - : 0 : std::cerr << "Log analysis error: " << e.what() << "\n";
- - ]
129 : 0 : } catch (...) {
130 [ - - ]: 0 : std::cerr << "Log analysis unknown error\n";
131 [ - - ]: 0 : }
132 : :
133 [ # # ]: 0 : if (found) {
134 [ # # ]: 0 : std::string log_file = latest_path.string();
135 : :
136 : : // Get executable directory to find tools/ relative to the binary
137 [ # # ]: 0 : fs::path exe_dir = fs::current_path();
138 : : #ifdef _WIN32
139 : : char buffer[MAX_PATH];
140 : : if (GetModuleFileNameA(NULL, buffer, MAX_PATH)) {
141 : : exe_dir = fs::path(buffer).parent_path();
142 : : }
143 : : #endif
144 : :
145 : : // Robust PYTHONPATH lookup
146 [ # # # # : 0 : std::string python_path = (exe_dir / "tools").string();
# # ]
147 [ # # # # : 0 : if (!fs::exists(exe_dir / "tools/lmuffb_log_analyzer")) {
# # # # ]
148 : : // Dev environment fallbacks from CWD
149 [ # # # # : 0 : if (fs::exists("tools/lmuffb_log_analyzer")) python_path = "tools";
# # # # ]
150 [ # # # # : 0 : else if (fs::exists("../tools/lmuffb_log_analyzer")) python_path = "../tools";
# # # # ]
151 [ # # # # : 0 : else if (fs::exists("../../tools/lmuffb_log_analyzer")) python_path = "../../tools";
# # # # ]
152 : : }
153 : :
154 [ # # # # : 0 : std::string cmd = "start cmd /c \"set PYTHONPATH=" + python_path + " && python -m lmuffb_log_analyzer.cli analyze-full \"" + log_file + "\" & pause\"";
# # # # ]
155 [ # # ]: 0 : system(cmd.c_str());
156 : 0 : }
157 : 0 : }
158 : 0 : ImGui::EndMenu();
159 : : }
160 : 1 : ImGui::EndMainMenuBar();
161 : : }
162 : 1 : }
163 : :
164 : :
165 : : static constexpr std::chrono::seconds CONNECT_ATTEMPT_INTERVAL(2);
166 : :
167 : 377 : void GuiLayer::DrawTuningWindow(FFBEngine& engine) {
168 [ + - ]: 377 : std::lock_guard<std::recursive_mutex> lock(g_engine_mutex);
169 : :
170 [ + - ]: 377 : ImGuiViewport* viewport = ImGui::GetMainViewport();
171 [ + + ]: 377 : float current_width = Config::show_graphs ? CONFIG_PANEL_WIDTH : viewport->WorkSize.x;
172 : :
173 [ + - ]: 377 : ImGui::SetNextWindowPos(viewport->WorkPos);
174 [ + - ]: 377 : ImGui::SetNextWindowSize(ImVec2(current_width, viewport->WorkSize.y));
175 : :
176 : 377 : ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
177 [ + - ]: 377 : ImGui::Begin("MainUI", nullptr, flags);
178 : :
179 [ + + + - ]: 377 : static std::chrono::steady_clock::time_point last_check_time = std::chrono::steady_clock::now();
180 : :
181 [ + - + - : 377 : if (!GameConnector::Get().IsConnected()) {
+ + ]
182 [ + - ]: 208 : ImGui::TextColored(ImVec4(1, 1, 0, 1), "Connecting to LMU...");
183 [ + - + - : 208 : if (std::chrono::steady_clock::now() - last_check_time > CONNECT_ATTEMPT_INTERVAL) {
- + ]
184 : 0 : last_check_time = std::chrono::steady_clock::now();
185 [ # # # # ]: 0 : GameConnector::Get().TryConnect();
186 : : }
187 : : } else {
188 [ + - ]: 169 : ImGui::TextColored(ImVec4(0, 1, 0, 1), "Connected to LMU");
189 : : }
190 : :
191 [ + + + - ]: 377 : static std::vector<DeviceInfo> devices;
192 : : static int selected_device_idx = -1;
193 : :
194 [ + + ]: 377 : if (devices.empty()) {
195 [ + - + - ]: 1 : devices = DirectInputFFB::Get().EnumerateDevices();
196 [ + - + - : 1 : if (selected_device_idx == -1 && !Config::m_last_device_guid.empty()) {
+ - ]
197 [ + - ]: 1 : GUID target = DirectInputFFB::StringToGuid(Config::m_last_device_guid);
198 [ + - ]: 1 : for (int i = 0; i < (int)devices.size(); i++) {
199 [ + - ]: 1 : if (memcmp(&devices[i].guid, &target, sizeof(GUID)) == 0) {
200 : 1 : selected_device_idx = i;
201 [ + - + - ]: 1 : DirectInputFFB::Get().SelectDevice(devices[i].guid);
202 : 1 : break;
203 : : }
204 : : }
205 : : }
206 : : }
207 : :
208 [ + - + - ]: 377 : ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.4f);
209 [ + - + - : 377 : if (ImGui::BeginCombo("FFB Device", selected_device_idx >= 0 ? devices[selected_device_idx].name.c_str() : "Select Device...")) {
- + ]
210 [ # # ]: 0 : for (int i = 0; i < (int)devices.size(); i++) {
211 : 0 : bool is_selected = (selected_device_idx == i);
212 [ # # ]: 0 : ImGui::PushID(i);
213 [ # # # # ]: 0 : if (ImGui::Selectable(devices[i].name.c_str(), is_selected)) {
214 : 0 : selected_device_idx = i;
215 [ # # # # ]: 0 : DirectInputFFB::Get().SelectDevice(devices[i].guid);
216 [ # # ]: 0 : Config::m_last_device_guid = DirectInputFFB::GuidToString(devices[i].guid);
217 [ # # # # ]: 0 : Config::Save(engine);
218 : : }
219 [ # # # # ]: 0 : if (is_selected) ImGui::SetItemDefaultFocus();
220 [ # # ]: 0 : ImGui::PopID();
221 : : }
222 [ # # ]: 0 : ImGui::EndCombo();
223 : : }
224 [ + - + + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::DEVICE_SELECT);
+ - ]
225 : :
226 [ + - ]: 377 : ImGui::SameLine();
227 [ + - - + ]: 377 : if (ImGui::Button("Rescan")) {
228 [ # # # # ]: 0 : devices = DirectInputFFB::Get().EnumerateDevices();
229 : 0 : selected_device_idx = -1;
230 : : }
231 [ + - + + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::DEVICE_RESCAN);
+ - ]
232 [ + - ]: 377 : ImGui::SameLine();
233 [ + - - + ]: 377 : if (ImGui::Button("Unbind")) {
234 [ # # # # ]: 0 : DirectInputFFB::Get().ReleaseDevice();
235 : 0 : selected_device_idx = -1;
236 : : }
237 [ + - - + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::DEVICE_UNBIND);
- - ]
238 : :
239 [ + - + - ]: 377 : if (DirectInputFFB::Get().IsActive()) {
240 [ + - + - ]: 377 : if (DirectInputFFB::Get().IsExclusive()) {
241 [ + - ]: 377 : ImGui::TextColored(ImVec4(0.4f, 1.0f, 0.4f, 1.0f), "Mode: EXCLUSIVE (Game FFB Blocked)");
242 [ + - + + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::MODE_EXCLUSIVE);
+ - ]
243 : : } else {
244 [ # # ]: 0 : ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.4f, 1.0f), "Mode: SHARED (Potential Conflict)");
245 [ # # # # : 0 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::MODE_SHARED);
# # ]
246 : : }
247 : : } else {
248 [ # # ]: 0 : ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "No device selected.");
249 [ # # # # : 0 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::NO_DEVICE);
# # ]
250 : : }
251 : :
252 [ + - - + ]: 377 : if (ImGui::Checkbox("Always on Top", &Config::m_always_on_top)) {
253 [ # # ]: 0 : SetWindowAlwaysOnTopPlatform(Config::m_always_on_top);
254 [ # # # # ]: 0 : Config::Save(engine);
255 : : }
256 [ + - + + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::ALWAYS_ON_TOP);
+ - ]
257 [ + - ]: 377 : ImGui::SameLine();
258 : :
259 : 377 : bool toggled = Config::show_graphs;
260 [ + - - + ]: 377 : if (ImGui::Checkbox("Graphs", &toggled)) {
261 [ # # ]: 0 : SaveCurrentWindowGeometryPlatform(Config::show_graphs);
262 : 0 : Config::show_graphs = toggled;
263 [ # # ]: 0 : int target_w = Config::show_graphs ? Config::win_w_large : Config::win_w_small;
264 [ # # ]: 0 : int target_h = Config::show_graphs ? Config::win_h_large : Config::win_h_small;
265 [ # # ]: 0 : ResizeWindowPlatform(Config::win_pos_x, Config::win_pos_y, target_w, target_h);
266 [ # # # # ]: 0 : Config::Save(engine);
267 : : }
268 [ + - - + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::SHOW_GRAPHS);
- - ]
269 : :
270 [ + - ]: 377 : ImGui::Separator();
271 : 377 : bool is_logging = Config::m_auto_start_logging;
272 [ + - ]: 377 : if (is_logging) {
273 [ + - - + ]: 377 : if (ImGui::Button("STOP LOG", ImVec2(80, 0))) {
274 : 0 : Config::m_auto_start_logging = false;
275 [ # # ]: 0 : AsyncLogger::Get().Stop();
276 [ # # # # ]: 0 : Config::Save(engine);
277 : : }
278 [ + - - + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::LOG_STOP);
- - ]
279 [ + - ]: 377 : ImGui::SameLine();
280 [ + - + + ]: 377 : if (AsyncLogger::Get().IsLogging()) {
281 [ + - ]: 3 : float time = (float)ImGui::GetTime();
282 : 3 : bool blink = (fmod(time, 1.0f) < 0.5f);
283 [ + + + - ]: 3 : ImGui::TextColored(blink ? ImVec4(1, 0, 0, 1) : ImVec4(0.6f, 0, 0, 1), "REC");
284 [ + - - + : 3 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::LOG_REC);
- - ]
285 : :
286 [ + - ]: 3 : ImGui::SameLine();
287 [ + - ]: 3 : size_t bytes = AsyncLogger::Get().GetFileSizeBytes();
288 [ + - ]: 3 : if (bytes < 1024ULL * 1024ULL)
289 [ + - + - ]: 3 : ImGui::Text("%zu f (%.0f KB)", AsyncLogger::Get().GetFrameCount(), (float)bytes / 1024.0f);
290 : : else
291 [ # # # # ]: 0 : ImGui::Text("%zu f (%.1f MB)", AsyncLogger::Get().GetFrameCount(), (float)bytes / (1024.0f * 1024.0f));
292 : :
293 [ + - ]: 3 : ImGui::SameLine();
294 [ + - - + ]: 3 : if (ImGui::Button("MARKER")) {
295 [ # # ]: 0 : AsyncLogger::Get().SetMarker();
296 : : }
297 [ + - - + : 3 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::LOG_MARKER);
- - ]
298 : : } else {
299 [ + - ]: 374 : ImGui::TextColored(ImVec4(1.0f, 0.8f, 0.0f, 1.0f), "ARMED");
300 [ + - + + : 374 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("Waiting for driving to start...");
+ - ]
301 : : }
302 : : } else {
303 [ # # # # ]: 0 : if (ImGui::Button("START LOGGING", ImVec2(120, 0))) {
304 : 0 : Config::m_auto_start_logging = true;
305 [ # # # # ]: 0 : Config::Save(engine);
306 : : }
307 [ # # # # : 0 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::LOG_START);
# # ]
308 [ # # ]: 0 : ImGui::SameLine();
309 [ # # ]: 0 : ImGui::TextDisabled("(Diagnostics)");
310 : : }
311 : :
312 : :
313 [ + - ]: 377 : ImGui::Separator();
314 : :
315 : : static int selected_preset = 0;
316 : :
317 : 4494 : auto FormatDecoupled = [&](float val, float base_nm) {
318 : 4494 : float estimated_nm = val * base_nm;
319 : : static char buf[64];
320 : 4494 : StringUtils::SafeFormat(buf, sizeof(buf), "%.1f%%%% (~%.1f Nm)", val * 100.0f, estimated_nm);
321 : 4494 : return (const char*)buf;
322 : : };
323 : :
324 : 3393 : auto FormatPct = [&](float val) {
325 : : static char buf[32];
326 : 3393 : StringUtils::SafeFormat(buf, sizeof(buf), "%.1f%%%%", val * 100.0f);
327 : 3393 : return (const char*)buf;
328 : : };
329 : :
330 : 25827 : auto FloatSetting = [&](const char* label, float* v, float min, float max, const char* fmt = "%.2f", const char* tooltip = nullptr, std::function<void()> decorator = nullptr) {
331 [ + - + - ]: 25827 : GuiWidgets::Result res = GuiWidgets::Float(label, v, min, max, fmt, tooltip, decorator);
332 [ - + ]: 25827 : if (res.deactivated) {
333 [ # # # # ]: 0 : Config::Save(engine);
334 : : }
335 : 25827 : };
336 : :
337 : 4524 : auto BoolSetting = [&](const char* label, bool* v, const char* tooltip = nullptr) {
338 [ + - ]: 4524 : GuiWidgets::Result res = GuiWidgets::Checkbox(label, v, tooltip);
339 [ - + ]: 4524 : if (res.deactivated) {
340 [ # # # # ]: 0 : Config::Save(engine);
341 : : }
342 : 4524 : };
343 : :
344 : 754 : auto IntSetting = [&](const char* label, int* v, const char* const items[], int items_count, const char* tooltip = nullptr) {
345 [ + - ]: 754 : GuiWidgets::Result res = GuiWidgets::Combo(label, v, items, items_count, tooltip);
346 [ - + ]: 754 : if (res.changed) {
347 [ # # ]: 0 : std::lock_guard<std::recursive_mutex> lock(g_engine_mutex);
348 : : // v is already updated by ImGui, but we lock to ensure visibility and consistency
349 [ # # # # ]: 0 : Config::Save(engine);
350 : 0 : }
351 : 754 : };
352 : :
353 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("Presets and Configuration", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) {
354 [ - + - - : 377 : if (Config::presets.empty()) Config::LoadPresets();
- - ]
355 : :
356 : : static bool first_run = true;
357 [ + + + - : 377 : if (first_run && !Config::presets.empty()) {
+ + ]
358 [ + - ]: 1 : for (int i = 0; i < (int)Config::presets.size(); i++) {
359 [ + - ]: 1 : if (Config::presets[i].name == Config::m_last_preset_name) {
360 : 1 : selected_preset = i;
361 : 1 : break;
362 : : }
363 : : }
364 : 1 : first_run = false;
365 : : }
366 : :
367 [ + + + - ]: 377 : static std::string preview_buf;
368 : 377 : const char* preview_value = "Custom";
369 [ + - + - : 377 : if (selected_preset >= 0 && selected_preset < (int)Config::presets.size()) {
+ - ]
370 [ + - ]: 377 : preview_buf = Config::presets[selected_preset].name;
371 [ + - + + ]: 377 : if (Config::IsEngineDirtyRelativeToPreset(selected_preset, engine)) {
372 [ + - ]: 370 : preview_buf += "*";
373 : : }
374 : 377 : preview_value = preview_buf.c_str();
375 : : }
376 : :
377 [ + - + - ]: 377 : ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.6f);
378 [ + - - + ]: 377 : if (ImGui::BeginCombo("Load Preset", preview_value)) {
379 [ # # ]: 0 : for (int i = 0; i < (int)Config::presets.size(); i++) {
380 : 0 : bool is_selected = (selected_preset == i);
381 [ # # ]: 0 : ImGui::PushID(i);
382 [ # # # # ]: 0 : if (ImGui::Selectable(Config::presets[i].name.c_str(), is_selected)) {
383 : 0 : selected_preset = i;
384 [ # # ]: 0 : Config::ApplyPreset(i, engine);
385 : : }
386 [ # # # # ]: 0 : if (is_selected) ImGui::SetItemDefaultFocus();
387 [ # # ]: 0 : ImGui::PopID();
388 : : }
389 [ # # ]: 0 : ImGui::EndCombo();
390 : : }
391 : :
392 : : static char new_preset_name[64] = "";
393 [ + - + - ]: 377 : ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.4f);
394 [ + - ]: 377 : ImGui::InputText("##NewPresetName", new_preset_name, 64);
395 [ + - + + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::PRESET_NAME);
+ - ]
396 [ + - ]: 377 : ImGui::SameLine();
397 [ + - - + ]: 377 : if (ImGui::Button("Save New")) {
398 [ # # ]: 0 : if (strlen(new_preset_name) > 0) {
399 [ # # # # ]: 0 : Config::AddUserPreset(std::string(new_preset_name), engine);
400 [ # # ]: 0 : for (int i = 0; i < (int)Config::presets.size(); i++) {
401 [ # # # # ]: 0 : if (Config::presets[i].name == std::string(new_preset_name)) {
402 : 0 : selected_preset = i;
403 : 0 : break;
404 : : }
405 : : }
406 : 0 : new_preset_name[0] = '\0';
407 : : }
408 : : }
409 [ + - - + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::PRESET_SAVE_NEW);
- - ]
410 : :
411 [ + - - + ]: 377 : if (ImGui::Button("Save Current Config")) {
412 [ # # # # : 0 : if (selected_preset >= 0 && selected_preset < (int)Config::presets.size() && !Config::presets[selected_preset].is_builtin) {
# # # # ]
413 [ # # ]: 0 : Config::AddUserPreset(Config::presets[selected_preset].name, engine);
414 : : } else {
415 [ # # # # ]: 0 : Config::Save(engine);
416 : : }
417 : : }
418 [ + - + + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::PRESET_SAVE_CURRENT);
+ - ]
419 [ + - ]: 377 : ImGui::SameLine();
420 [ + - - + ]: 377 : if (ImGui::Button("Reset Defaults")) {
421 [ # # ]: 0 : Config::ApplyPreset(0, engine);
422 : 0 : selected_preset = 0;
423 : : }
424 [ + - - + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::PRESET_RESET);
- - ]
425 [ + - ]: 377 : ImGui::SameLine();
426 [ + - - + ]: 377 : if (ImGui::Button("Duplicate")) {
427 [ # # ]: 0 : if (selected_preset >= 0) {
428 [ # # ]: 0 : Config::DuplicatePreset(selected_preset, engine);
429 [ # # ]: 0 : for (int i = 0; i < (int)Config::presets.size(); i++) {
430 [ # # ]: 0 : if (Config::presets[i].name == Config::m_last_preset_name) {
431 : 0 : selected_preset = i;
432 : 0 : break;
433 : : }
434 : : }
435 : : }
436 : : }
437 [ + - + + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::PRESET_DUPLICATE);
+ - ]
438 [ + - ]: 377 : ImGui::SameLine();
439 [ + - + - : 377 : bool can_delete = (selected_preset >= 0 && selected_preset < (int)Config::presets.size() && !Config::presets[selected_preset].is_builtin);
+ - ]
440 [ - + - - ]: 377 : if (!can_delete) ImGui::BeginDisabled();
441 [ + - - + ]: 377 : if (ImGui::Button("Delete")) {
442 [ # # ]: 0 : Config::DeletePreset(selected_preset, engine);
443 : 0 : selected_preset = 0;
444 [ # # ]: 0 : Config::ApplyPreset(0, engine);
445 : : }
446 [ + - - + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::PRESET_DELETE);
- - ]
447 [ - + - - ]: 377 : if (!can_delete) ImGui::EndDisabled();
448 : :
449 [ + - ]: 377 : ImGui::Separator();
450 [ + - - + ]: 377 : if (ImGui::Button("Import Preset...")) {
451 : 0 : std::string path;
452 [ # # # # ]: 0 : if (OpenPresetFileDialogPlatform(path)) {
453 [ # # # # ]: 0 : if (Config::ImportPreset(path, engine)) {
454 : 0 : selected_preset = (int)Config::presets.size() - 1;
455 : : }
456 : : }
457 : 0 : }
458 [ + - + + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::PRESET_IMPORT);
+ - ]
459 [ + - ]: 377 : ImGui::SameLine();
460 [ + - - + ]: 377 : if (ImGui::Button("Export Selected...")) {
461 [ # # # # : 0 : if (selected_preset >= 0 && selected_preset < (int)Config::presets.size()) {
# # ]
462 : 0 : std::string path;
463 [ # # ]: 0 : std::string defaultName = Config::presets[selected_preset].name + ".ini";
464 [ # # # # ]: 0 : if (SavePresetFileDialogPlatform(path, defaultName)) {
465 [ # # ]: 0 : Config::ExportPreset(selected_preset, path);
466 : : }
467 : 0 : }
468 : : }
469 [ + - - + : 377 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::PRESET_EXPORT);
- - ]
470 : :
471 [ + - ]: 377 : ImGui::TreePop();
472 : : }
473 : :
474 [ + - ]: 377 : ImGui::Spacing();
475 : :
476 [ + - ]: 377 : ImGui::Columns(2, "SettingsGrid", false);
477 [ + - + - ]: 377 : ImGui::SetColumnWidth(0, ImGui::GetWindowWidth() * 0.45f);
478 : :
479 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("General FFB", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) {
480 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
481 : :
482 [ + - ]: 377 : ImGui::TextDisabled("Steering: %.1f° (%.0f)", m_latest_steering_angle, m_latest_steering_range);
483 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
484 : :
485 [ + - ]: 377 : BoolSetting("Steerlock from REST API", &engine.m_rest_api_enabled, Tooltips::REST_API_ENABLE);
486 : :
487 [ + - ]: 377 : ImGui::Spacing();
488 : 377 : bool use_in_game_ffb = (engine.m_torque_source == 1);
489 [ + - - + ]: 377 : if (GuiWidgets::Checkbox("Use In-Game FFB (400Hz Native)", &use_in_game_ffb, Tooltips::USE_INGAME_FFB).changed) {
490 [ # # ]: 0 : std::lock_guard<std::recursive_mutex> lock(g_engine_mutex);
491 [ # # ]: 0 : engine.m_torque_source = use_in_game_ffb ? 1 : 0;
492 [ # # # # ]: 0 : Config::Save(engine);
493 : 0 : }
494 : :
495 [ + - ]: 377 : BoolSetting("Invert FFB Signal", &engine.m_invert_force, Tooltips::INVERT_FFB);
496 : :
497 : 377 : bool prev_structural = engine.m_dynamic_normalization_enabled;
498 [ + - - + ]: 377 : if (GuiWidgets::Checkbox("Enable Dynamic Normalization (Session Peak)", &engine.m_dynamic_normalization_enabled, Tooltips::DYNAMIC_NORMALIZATION_ENABLE).changed) {
499 [ # # # # ]: 0 : if (prev_structural && !engine.m_dynamic_normalization_enabled) {
500 [ # # ]: 0 : engine.ResetNormalization();
501 : : }
502 [ # # # # ]: 0 : Config::Save(engine);
503 : : }
504 [ + - ]: 377 : FloatSetting("Master Gain", &engine.m_gain, 0.0f, 2.0f, FormatPct(engine.m_gain), Tooltips::MASTER_GAIN);
505 [ + - ]: 377 : FloatSetting("Wheelbase Max Torque", &engine.m_wheelbase_max_nm, 1.0f, 50.0f, "%.1f Nm", Tooltips::WHEELBASE_MAX_TORQUE);
506 [ + - ]: 377 : FloatSetting("Target Rim Torque", &engine.m_target_rim_nm, 1.0f, 50.0f, "%.1f Nm", Tooltips::TARGET_RIM_TORQUE);
507 [ + - ]: 377 : FloatSetting("Min Force", &engine.m_min_force, 0.0f, 0.20f, "%.3f", Tooltips::MIN_FORCE);
508 : :
509 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("Soft Lock", ImGuiTreeNodeFlags_DefaultOpen)) {
510 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
511 [ + - ]: 377 : BoolSetting("Enable Soft Lock", &engine.m_soft_lock_enabled, Tooltips::SOFT_LOCK_ENABLE);
512 [ + - ]: 377 : if (engine.m_soft_lock_enabled) {
513 [ + - ]: 377 : FloatSetting(" Stiffness", &engine.m_soft_lock_stiffness, 0.0f, 100.0f, "%.1f", Tooltips::SOFT_LOCK_STIFFNESS);
514 [ + - ]: 377 : FloatSetting(" Damping", &engine.m_soft_lock_damping, 0.0f, 5.0f, "%.2f", Tooltips::SOFT_LOCK_DAMPING);
515 : : }
516 [ + - ]: 377 : ImGui::TreePop();
517 [ + - ]: 377 : ImGui::Separator();
518 : : }
519 : :
520 [ + - ]: 377 : ImGui::TreePop();
521 : : } else {
522 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
523 : : }
524 : :
525 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("Front Axle (Understeer)", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) {
526 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
527 : :
528 [ + + ]: 377 : if (engine.m_torque_source == 1) {
529 [ + - ]: 166 : FloatSetting("In-Game FFB Gain", &engine.m_ingame_ffb_gain, 0.0f, 2.0f, FormatPct(engine.m_ingame_ffb_gain), Tooltips::INGAME_FFB_GAIN);
530 : : } else {
531 [ + - ]: 211 : FloatSetting("Steering Shaft Gain", &engine.m_steering_shaft_gain, 0.0f, 2.0f, FormatPct(engine.m_steering_shaft_gain), Tooltips::STEERING_SHAFT_GAIN);
532 : : }
533 : :
534 [ + - ]: 377 : FloatSetting("Steering Shaft Smoothing", &engine.m_steering_shaft_smoothing, 0.000f, 0.100f, "%.3f s",
535 : : Tooltips::STEERING_SHAFT_SMOOTHING,
536 : 377 : [&]() {
537 : 377 : int ms = (int)std::lround(engine.m_steering_shaft_smoothing * 1000.0f);
538 [ + - ]: 377 : ImVec4 color = (ms < LATENCY_WARNING_THRESHOLD_MS) ? ImVec4(0,1,0,1) : ImVec4(1,0,0,1);
539 [ + - + - ]: 377 : ImGui::TextColored(color, "Latency: %d ms - %s", ms, (ms < LATENCY_WARNING_THRESHOLD_MS) ? "OK" : "High");
540 : 377 : });
541 : :
542 [ + - ]: 377 : FloatSetting("Understeer Effect", &engine.m_understeer_effect, 0.0f, 2.0f, FormatPct(engine.m_understeer_effect),
543 : : Tooltips::UNDERSTEER_EFFECT);
544 : :
545 [ + - ]: 377 : FloatSetting("Response Curve (Gamma)", &engine.m_understeer_gamma, 0.1f, 4.0f, "%.1f",
546 : : Tooltips::UNDERSTEER_GAMMA);
547 : :
548 : 377 : const char* torque_sources[] = { "Shaft Torque (100Hz Legacy)", "In-Game FFB (400Hz LMU 1.2+)" };
549 [ + - ]: 377 : IntSetting("Torque Source", &engine.m_torque_source, torque_sources, sizeof(torque_sources)/sizeof(torque_sources[0]),
550 : : Tooltips::TORQUE_SOURCE);
551 : :
552 [ + - ]: 377 : BoolSetting("Pure Passthrough", &engine.m_torque_passthrough, Tooltips::PURE_PASSTHROUGH);
553 : :
554 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("Signal Filtering", ImGuiTreeNodeFlags_DefaultOpen)) {
555 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
556 : :
557 [ + - ]: 377 : BoolSetting(" Flatspot Suppression", &engine.m_flatspot_suppression, Tooltips::FLATSPOT_SUPPRESSION);
558 [ + + ]: 377 : if (engine.m_flatspot_suppression) {
559 [ + - ]: 364 : FloatSetting(" Filter Width (Q)", &engine.m_notch_q, 0.5f, 10.0f, "Q: %.2f", Tooltips::NOTCH_Q);
560 [ + - ]: 364 : FloatSetting(" Suppression Strength", &engine.m_flatspot_strength, 0.0f, 1.0f, "%.2f", Tooltips::SUPPRESSION_STRENGTH);
561 [ + - ]: 364 : ImGui::Text(" Est. / Theory Freq");
562 [ + - ]: 364 : ImGui::NextColumn();
563 [ + - ]: 364 : ImGui::TextDisabled("%.1f Hz / %.1f Hz", engine.m_debug_freq, engine.m_theoretical_freq);
564 [ + - ]: 364 : ImGui::NextColumn();
565 : : }
566 : :
567 [ + - ]: 377 : BoolSetting(" Static Noise Filter", &engine.m_static_notch_enabled, Tooltips::STATIC_NOISE_FILTER);
568 [ + + ]: 377 : if (engine.m_static_notch_enabled) {
569 [ + - ]: 363 : FloatSetting(" Target Frequency", &engine.m_static_notch_freq, 10.0f, 100.0f, "%.1f Hz", Tooltips::STATIC_NOTCH_FREQ);
570 [ + - ]: 363 : FloatSetting(" Filter Width", &engine.m_static_notch_width, 0.1f, 10.0f, "%.1f Hz", Tooltips::STATIC_NOTCH_WIDTH);
571 : : }
572 : :
573 [ + - ]: 377 : ImGui::TreePop();
574 : : } else {
575 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
576 : : }
577 : :
578 [ + - ]: 377 : ImGui::TreePop();
579 : : } else {
580 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
581 : : }
582 : :
583 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("FFB Safety Features", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) {
584 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
585 : :
586 [ + - + - ]: 754 : FloatSetting("Safety Duration", &engine.m_safety.m_safety_window_duration, 0.0f, 10.0f, "%.1f s", Tooltips::SAFETY_WINDOW_DURATION, [&]() { std::lock_guard<std::recursive_mutex> lock(g_engine_mutex); });
587 [ + - + - ]: 754 : FloatSetting("Gain Reduction", &engine.m_safety.m_safety_gain_reduction, 0.0f, 1.0f, FormatPct(engine.m_safety.m_safety_gain_reduction), Tooltips::SAFETY_GAIN_REDUCTION, [&]() { std::lock_guard<std::recursive_mutex> lock(g_engine_mutex); });
588 [ + - + - ]: 754 : FloatSetting("Safety Smoothing", &engine.m_safety.m_safety_smoothing_tau, 0.001f, 1.0f, "%.3f s", Tooltips::SAFETY_SMOOTHING_TAU, [&]() { std::lock_guard<std::recursive_mutex> lock(g_engine_mutex); });
589 [ + - + - ]: 754 : FloatSetting("Slew Restriction", &engine.m_safety.m_safety_slew_full_scale_time_s, 0.1f, 5.0f, "%.2f s", Tooltips::SAFETY_SLEW_FULL_SCALE_TIME_S, [&]() { std::lock_guard<std::recursive_mutex> lock(g_engine_mutex); });
590 : :
591 [ + - ]: 377 : ImGui::Separator();
592 [ + - ]: 377 : ImGui::TextColored(ImVec4(1.0f, 0.8f, 0.0f, 1.0f), "Stuttering (Lost Frames)");
593 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
594 : :
595 [ + - ]: 377 : BoolSetting("Safety on Stuttering", &engine.m_safety.m_stutter_safety_enabled, Tooltips::STUTTER_SAFETY_ENABLE);
596 [ - + ]: 377 : if (engine.m_safety.m_stutter_safety_enabled) {
597 [ # # # # ]: 0 : FloatSetting("Stutter Threshold", &engine.m_safety.m_stutter_threshold, 1.1f, 5.0f, "%.2fx", Tooltips::STUTTER_THRESHOLD, [&]() { std::lock_guard<std::recursive_mutex> lock(g_engine_mutex); });
598 : : }
599 : :
600 [ + - ]: 377 : ImGui::Separator();
601 [ + - ]: 377 : ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "Spike Detection");
602 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
603 : :
604 [ + - + - ]: 754 : FloatSetting("Spike Threshold", &engine.m_safety.m_spike_detection_threshold, 10.0f, 2000.0f, "%.0f u/s", Tooltips::SPIKE_DETECTION_THRESHOLD, [&]() { std::lock_guard<std::recursive_mutex> lock(g_engine_mutex); });
605 [ + - + - ]: 754 : FloatSetting("Immediate Spike", &engine.m_safety.m_immediate_spike_threshold, 100.0f, 5000.0f, "%.0f u/s", Tooltips::IMMEDIATE_SPIKE_THRESHOLD, [&]() { std::lock_guard<std::recursive_mutex> lock(g_engine_mutex); });
606 : :
607 [ + - ]: 377 : ImGui::TreePop();
608 : : } else {
609 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
610 : : }
611 : :
612 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("Load Forces", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) {
613 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
614 : :
615 [ + - ]: 377 : FloatSetting("Lateral Load", &engine.m_lat_load_effect, 0.0f, 10.0f, FormatDecoupled(engine.m_lat_load_effect, FFBEngine::BASE_NM_SOP_LATERAL), Tooltips::LATERAL_LOAD);
616 : :
617 : 377 : const char* load_transforms[] = { "Linear (Raw)", "Cubic (Smooth)", "Quadratic (Broad)", "Hermite (Locked Center)" };
618 : 377 : int lat_transform = static_cast<int>(engine.m_lat_load_transform);
619 [ + - - + ]: 377 : if (GuiWidgets::Combo(" Lateral Transform", &lat_transform, load_transforms, 4, "Mathematical transformation to soften the lateral load limits and remove 'notchiness'.").changed) {
620 [ # # ]: 0 : std::lock_guard<std::recursive_mutex> lock(g_engine_mutex);
621 : 0 : engine.m_lat_load_transform = static_cast<LoadTransform>(lat_transform);
622 [ # # # # ]: 0 : Config::Save(engine);
623 : 0 : }
624 : :
625 [ + - ]: 377 : ImGui::Spacing();
626 : :
627 [ + - ]: 377 : FloatSetting("Longitudinal G-Force", &engine.m_long_load_effect, 0.0f, 10.0f, FormatPct(engine.m_long_load_effect), Tooltips::DYNAMIC_WEIGHT);
628 [ + - ]: 377 : FloatSetting(" G-Force Smoothing", &engine.m_long_load_smoothing, 0.000f, 0.500f, "%.3f s", Tooltips::WEIGHT_SMOOTHING);
629 : :
630 : 377 : int long_transform = static_cast<int>(engine.m_long_load_transform);
631 [ + - - + ]: 377 : if (GuiWidgets::Combo(" G-Force Transform", &long_transform, load_transforms, 4, "Mathematical transformation to soften the longitudinal load limits and remove 'notchiness'.").changed) {
632 [ # # ]: 0 : std::lock_guard<std::recursive_mutex> lock(g_engine_mutex);
633 : 0 : engine.m_long_load_transform = static_cast<LoadTransform>(long_transform);
634 [ # # # # ]: 0 : Config::Save(engine);
635 : 0 : }
636 : :
637 [ + - ]: 377 : ImGui::TreePop();
638 : : } else {
639 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
640 : : }
641 : :
642 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("Rear Axle (Oversteer)", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) {
643 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
644 : :
645 [ + - ]: 377 : FloatSetting("Lateral G Boost (Slide)", &engine.m_oversteer_boost, 0.0f, 4.0f, FormatPct(engine.m_oversteer_boost),
646 : : Tooltips::OVERSTEER_BOOST);
647 [ + - ]: 377 : FloatSetting("Lateral G", &engine.m_sop_effect, 0.0f, 2.0f, FormatDecoupled(engine.m_sop_effect, FFBEngine::BASE_NM_SOP_LATERAL), Tooltips::LATERAL_G);
648 : :
649 [ + - ]: 377 : FloatSetting("SoP Self-Aligning Torque", &engine.m_rear_align_effect, 0.0f, 2.0f, FormatDecoupled(engine.m_rear_align_effect, FFBEngine::BASE_NM_REAR_ALIGN),
650 : : Tooltips::REAR_ALIGN_TORQUE);
651 [ + - ]: 377 : FloatSetting(" Kerb Strike Rejection", &engine.m_kerb_strike_rejection, 0.0f, 1.0f, FormatPct(engine.m_kerb_strike_rejection),
652 : : Tooltips::KERB_STRIKE_REJECTION);
653 [ + - ]: 377 : FloatSetting("Yaw Kick", &engine.m_sop_yaw_gain, 0.0f, 1.0f, FormatDecoupled(engine.m_sop_yaw_gain, FFBEngine::BASE_NM_YAW_KICK),
654 : : Tooltips::YAW_KICK);
655 [ + - ]: 377 : FloatSetting(" Activation Threshold", &engine.m_yaw_kick_threshold, 0.0f, 10.0f, "%.2f rad/s²", Tooltips::YAW_KICK_THRESHOLD);
656 : :
657 [ + - ]: 377 : FloatSetting(" Kick Response", &engine.m_yaw_accel_smoothing, 0.000f, 0.050f, "%.3f s",
658 : : Tooltips::YAW_KICK_RESPONSE,
659 : 377 : [&]() {
660 : 377 : int ms = (int)std::lround(engine.m_yaw_accel_smoothing * 1000.0f);
661 [ + - ]: 377 : ImVec4 color = (ms <= 15) ? ImVec4(0,1,0,1) : ImVec4(1,0,0,1);
662 [ + - ]: 377 : ImGui::TextColored(color, "Latency: %d ms", ms);
663 : 377 : });
664 : :
665 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("Unloaded Yaw Kick (Braking)", ImGuiTreeNodeFlags_DefaultOpen)) {
666 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
667 [ + - ]: 377 : FloatSetting(" Gain", &engine.m_unloaded_yaw_gain, 0.0f, 1.0f, FormatDecoupled(engine.m_unloaded_yaw_gain, FFBEngine::BASE_NM_YAW_KICK), Tooltips::UNLOADED_YAW_GAIN);
668 [ + - ]: 377 : FloatSetting(" Threshold", &engine.m_unloaded_yaw_threshold, 0.0f, 2.0f, "%.2f rad/s²", Tooltips::UNLOADED_YAW_THRESHOLD);
669 [ + - ]: 377 : FloatSetting(" Unload Sens.", &engine.m_unloaded_yaw_sens, 0.1f, 5.0f, "%.1fx", Tooltips::UNLOADED_YAW_SENS);
670 [ + - ]: 377 : FloatSetting(" Gamma", &engine.m_unloaded_yaw_gamma, 0.1f, 2.0f, "%.1f", Tooltips::UNLOADED_YAW_GAMMA);
671 [ + - ]: 377 : FloatSetting(" Punch (Jerk)", &engine.m_unloaded_yaw_punch, 0.0f, 0.2f, "%.2fx", Tooltips::UNLOADED_YAW_PUNCH);
672 [ + - ]: 377 : ImGui::TreePop();
673 : : } else {
674 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
675 : : }
676 : :
677 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("Power Yaw Kick (Acceleration)", ImGuiTreeNodeFlags_DefaultOpen)) {
678 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
679 [ + - ]: 377 : FloatSetting(" Gain", &engine.m_power_yaw_gain, 0.0f, 1.0f, FormatDecoupled(engine.m_power_yaw_gain, FFBEngine::BASE_NM_YAW_KICK), Tooltips::POWER_YAW_GAIN);
680 [ + - ]: 377 : FloatSetting(" Threshold", &engine.m_power_yaw_threshold, 0.0f, 2.0f, "%.2f rad/s²", Tooltips::POWER_YAW_THRESHOLD);
681 [ + - ]: 377 : FloatSetting(" TC Slip Target", &engine.m_power_slip_threshold, 0.01f, 0.5f, FormatPct(engine.m_power_slip_threshold), Tooltips::POWER_SLIP_THRESHOLD);
682 [ + - ]: 377 : FloatSetting(" Gamma", &engine.m_power_yaw_gamma, 0.1f, 2.0f, "%.1f", Tooltips::POWER_YAW_GAMMA);
683 [ + - ]: 377 : FloatSetting(" Punch (Jerk)", &engine.m_power_yaw_punch, 0.0f, 0.2f, "%.2fx", Tooltips::POWER_YAW_PUNCH);
684 [ + - ]: 377 : ImGui::TreePop();
685 : : } else {
686 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
687 : : }
688 : :
689 [ + - ]: 377 : FloatSetting("Gyro Damping", &engine.m_gyro_gain, 0.0f, 1.0f, FormatDecoupled(engine.m_gyro_gain, FFBEngine::BASE_NM_GYRO_DAMPING), Tooltips::GYRO_DAMPING);
690 : :
691 [ + - ]: 377 : FloatSetting(" Gyro Smooth", &engine.m_gyro_smoothing, 0.000f, 0.050f, "%.3f s",
692 : : Tooltips::GYRO_SMOOTH,
693 : 377 : [&]() {
694 : 377 : int ms = (int)std::lround(engine.m_gyro_smoothing * 1000.0f);
695 [ + - ]: 377 : ImVec4 color = (ms <= 20) ? ImVec4(0,1,0,1) : ImVec4(1,0,0,1);
696 [ + - ]: 377 : ImGui::TextColored(color, "Latency: %d ms", ms);
697 : 377 : });
698 : :
699 [ + - ]: 377 : ImGui::TextColored(ImVec4(0.0f, 0.6f, 0.85f, 1.0f), "Advanced SoP");
700 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
701 : :
702 [ + - ]: 377 : FloatSetting("SoP Smoothing", &engine.m_sop_smoothing_factor, 0.0f, 1.0f, "%.2f",
703 : : Tooltips::SOP_SMOOTHING,
704 : 377 : [&]() {
705 : 377 : int ms = (int)std::lround(engine.m_sop_smoothing_factor * 100.0f);
706 [ + - ]: 377 : ImVec4 color = (ms < LATENCY_WARNING_THRESHOLD_MS) ? ImVec4(0,1,0,1) : ImVec4(1,0,0,1);
707 [ + - + - ]: 377 : ImGui::TextColored(color, "Latency: %d ms - %s", ms, (ms < LATENCY_WARNING_THRESHOLD_MS) ? "OK" : "High");
708 : 377 : });
709 : :
710 [ + - ]: 377 : FloatSetting("Grip Smoothing", &engine.m_grip_smoothing_steady, 0.000f, 0.100f, "%.3f s",
711 : : Tooltips::GRIP_SMOOTHING);
712 : :
713 [ + - ]: 377 : FloatSetting(" SoP Scale", &engine.m_sop_scale, 0.0f, 20.0f, "%.2f", Tooltips::SOP_SCALE);
714 : :
715 [ + - ]: 377 : ImGui::TreePop();
716 : : } else {
717 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
718 : : }
719 : :
720 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("Grip & Slip Angle Estimation", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) {
721 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
722 : :
723 [ + - ]: 377 : FloatSetting("Slip Angle Smoothing", &engine.m_slip_angle_smoothing, 0.000f, 0.100f, "%.3f s",
724 : : Tooltips::SLIP_ANGLE_SMOOTHING,
725 : 377 : [&]() {
726 : 377 : int ms = (int)std::lround(engine.m_slip_angle_smoothing * 1000.0f);
727 [ + - ]: 377 : ImVec4 color = (ms < LATENCY_WARNING_THRESHOLD_MS) ? ImVec4(0,1,0,1) : ImVec4(1,0,0,1);
728 [ + - + - ]: 377 : ImGui::TextColored(color, "Latency: %d ms - %s", ms, (ms < LATENCY_WARNING_THRESHOLD_MS) ? "OK" : "High");
729 : 377 : });
730 : :
731 [ + - ]: 377 : FloatSetting("Chassis Inertia (Load)", &engine.m_chassis_inertia_smoothing, 0.000f, 0.100f, "%.3f s",
732 : : Tooltips::CHASSIS_INERTIA,
733 : 377 : [&]() {
734 : 377 : int ms = (int)std::lround(engine.m_chassis_inertia_smoothing * 1000.0f);
735 [ + - ]: 377 : ImGui::TextColored(ImVec4(0.5f, 0.5f, 1.0f, 1.0f), "Simulation: %d ms", ms);
736 : 377 : });
737 : :
738 [ + - ]: 377 : FloatSetting("Optimal Slip Angle", &engine.m_optimal_slip_angle, 0.040f, 0.200f, "%.3f rad",
739 : : Tooltips::OPTIMAL_SLIP_ANGLE);
740 [ + - ]: 377 : FloatSetting("Optimal Slip Ratio", &engine.m_optimal_slip_ratio, 0.04f, 0.20f, "%.3f",
741 : : Tooltips::OPTIMAL_SLIP_RATIO);
742 : :
743 [ + - ]: 377 : ImGui::Separator();
744 [ + - ]: 377 : ImGui::TextColored(ImVec4(1.0f, 0.8f, 0.0f, 1.0f), "Slope Detection (Experimental)");
745 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
746 : :
747 : 377 : bool prev_slope_enabled = engine.m_slope_detection_enabled;
748 [ + - ]: 377 : GuiWidgets::Result slope_res = GuiWidgets::Checkbox("Enable Slope Detection", &engine.m_slope_detection_enabled,
749 : : Tooltips::SLOPE_DETECTION_ENABLE);
750 : :
751 [ - + ]: 377 : if (slope_res.changed) {
752 [ # # # # ]: 0 : if (!prev_slope_enabled && engine.m_slope_detection_enabled) {
753 : 0 : engine.m_slope_buffer_count = 0;
754 : 0 : engine.m_slope_buffer_index = 0;
755 : 0 : engine.m_slope_smoothed_output = 1.0;
756 : : }
757 : : }
758 [ - + ]: 377 : if (slope_res.deactivated) {
759 [ # # # # ]: 0 : Config::Save(engine);
760 : : }
761 : :
762 [ + + + + ]: 377 : if (engine.m_slope_detection_enabled && engine.m_oversteer_boost > 0.01f) {
763 [ + - ]: 362 : ImGui::TextColored(ImVec4(1.0f, 0.5f, 0.0f, 1.0f),
764 : : "Note: Lateral G Boost (Slide) is auto-disabled when Slope Detection is ON.");
765 [ + - + - ]: 362 : ImGui::NextColumn(); ImGui::NextColumn();
766 : : }
767 : :
768 [ + + ]: 377 : if (engine.m_slope_detection_enabled) {
769 : 363 : int window = engine.m_slope_sg_window;
770 [ + - - + ]: 363 : if (ImGui::SliderInt(" Filter Window", &window, 5, 41)) {
771 [ # # ]: 0 : if (window % 2 == 0) window++;
772 : 0 : engine.m_slope_sg_window = window;
773 : : }
774 [ + - - + ]: 363 : if (ImGui::IsItemHovered()) {
775 [ # # ]: 0 : ImGui::SetTooltip("%s", Tooltips::SLOPE_FILTER_WINDOW);
776 : : }
777 [ + - - + : 363 : if (ImGui::IsItemDeactivatedAfterEdit()) Config::Save(engine);
- - - - ]
778 : :
779 [ + - ]: 363 : ImGui::SameLine();
780 : 363 : float latency_ms = (static_cast<float>(engine.m_slope_sg_window) / 2.0f) * 2.5f;
781 [ + - ]: 363 : ImVec4 color = (latency_ms < 25.0f) ? ImVec4(0,1,0,1) : ImVec4(1,0.5f,0,1);
782 [ + - ]: 363 : ImGui::TextColored(color, "~%.0f ms latency", latency_ms);
783 [ + - + - ]: 363 : ImGui::NextColumn(); ImGui::NextColumn();
784 : :
785 [ + - ]: 363 : FloatSetting(" Sensitivity", &engine.m_slope_sensitivity, 0.1f, 5.0f, "%.1fx",
786 : : Tooltips::SLOPE_SENSITIVITY);
787 : :
788 [ + - - + ]: 363 : if (ImGui::TreeNode("Advanced Slope Settings")) {
789 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
790 [ # # ]: 0 : FloatSetting(" Slope Threshold", &engine.m_slope_min_threshold, -1.0f, 0.0f, "%.2f", Tooltips::SLOPE_THRESHOLD);
791 [ # # ]: 0 : FloatSetting(" Output Smoothing", &engine.m_slope_smoothing_tau, 0.005f, 0.100f, "%.3f s", Tooltips::SLOPE_OUTPUT_SMOOTHING);
792 : :
793 [ # # ]: 0 : ImGui::Separator();
794 [ # # ]: 0 : ImGui::Text("Stability Fixes (v0.7.3)");
795 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
796 [ # # ]: 0 : FloatSetting(" Alpha Threshold", &engine.m_slope_alpha_threshold, 0.001f, 0.100f, "%.3f", Tooltips::SLOPE_ALPHA_THRESHOLD);
797 [ # # ]: 0 : FloatSetting(" Decay Rate", &engine.m_slope_decay_rate, 0.5f, 20.0f, "%.1f", Tooltips::SLOPE_DECAY_RATE);
798 [ # # ]: 0 : BoolSetting(" Confidence Gate", &engine.m_slope_confidence_enabled, Tooltips::SLOPE_CONFIDENCE_GATE);
799 : :
800 [ # # ]: 0 : ImGui::TreePop();
801 : : } else {
802 [ + - + - ]: 363 : ImGui::NextColumn(); ImGui::NextColumn();
803 : : }
804 : :
805 : 363 : ImGui::Text(" Live Slope: %.3f | Grip: %.0f%%",
806 : : engine.m_slope_current,
807 [ + - ]: 363 : engine.m_slope_smoothed_output * 100.0f);
808 [ + - + - ]: 363 : ImGui::NextColumn(); ImGui::NextColumn();
809 : : }
810 : :
811 [ + - ]: 377 : ImGui::TreePop();
812 : : } else {
813 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
814 : : }
815 : :
816 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("Braking & Lockup", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) {
817 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
818 : :
819 [ + - ]: 377 : BoolSetting("Lockup Vibration", &engine.m_lockup_enabled, Tooltips::LOCKUP_VIBRATION);
820 [ + + ]: 377 : if (engine.m_lockup_enabled) {
821 [ + - ]: 373 : FloatSetting(" Lockup Strength", &engine.m_lockup_gain, 0.0f, 3.0f, FormatDecoupled(engine.m_lockup_gain, FFBEngine::BASE_NM_LOCKUP_VIBRATION), Tooltips::LOCKUP_STRENGTH);
822 [ + - ]: 373 : FloatSetting(" Brake Load Cap", &engine.m_brake_load_cap, 1.0f, 10.0f, "%.2fx", Tooltips::BRAKE_LOAD_CAP);
823 [ + - ]: 373 : FloatSetting(" Vibration Pitch", &engine.m_lockup_freq_scale, 0.5f, 2.0f, "%.2fx", Tooltips::VIBRATION_PITCH);
824 : :
825 [ + - ]: 373 : ImGui::Separator();
826 [ + - ]: 373 : ImGui::Text("Response Curve");
827 [ + - + - ]: 373 : ImGui::NextColumn(); ImGui::NextColumn();
828 : :
829 [ + - ]: 373 : FloatSetting(" Gamma", &engine.m_lockup_gamma, 0.1f, 3.0f, "%.1f", Tooltips::LOCKUP_GAMMA);
830 [ + - ]: 373 : FloatSetting(" Start Slip %", &engine.m_lockup_start_pct, 1.0f, 10.0f, "%.1f%%", Tooltips::LOCKUP_START_PCT);
831 [ + - ]: 373 : FloatSetting(" Full Slip %", &engine.m_lockup_full_pct, 5.0f, 25.0f, "%.1f%%", Tooltips::LOCKUP_FULL_PCT);
832 : :
833 [ + - ]: 373 : ImGui::Separator();
834 [ + - ]: 373 : ImGui::Text("Prediction (Advanced)");
835 [ + - + - ]: 373 : ImGui::NextColumn(); ImGui::NextColumn();
836 : :
837 [ + - ]: 373 : FloatSetting(" Sensitivity", &engine.m_lockup_prediction_sens, 10.0f, 100.0f, "%.0f", Tooltips::LOCKUP_PREDICTION_SENS);
838 [ + - ]: 373 : FloatSetting(" Bump Rejection", &engine.m_lockup_bump_reject, 0.1f, 5.0f, "%.1f m/s", Tooltips::LOCKUP_BUMP_REJECT);
839 [ + - ]: 373 : FloatSetting(" Rear Boost", &engine.m_lockup_rear_boost, 1.0f, 10.0f, "%.2fx", Tooltips::LOCKUP_REAR_BOOST);
840 : : }
841 : :
842 [ + - ]: 377 : ImGui::Separator();
843 [ + - ]: 377 : ImGui::Text("ABS & Hardware");
844 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
845 : :
846 [ + - ]: 377 : BoolSetting("ABS Pulse", &engine.m_abs_pulse_enabled, Tooltips::ABS_PULSE);
847 [ + + ]: 377 : if (engine.m_abs_pulse_enabled) {
848 [ + - ]: 360 : FloatSetting(" Pulse Gain", &engine.m_abs_gain, 0.0f, 10.0f, "%.2f", Tooltips::ABS_PULSE_GAIN);
849 [ + - ]: 360 : FloatSetting(" Pulse Frequency", &engine.m_abs_freq_hz, 10.0f, 50.0f, "%.1f Hz", Tooltips::ABS_PULSE_FREQ);
850 : : }
851 : :
852 [ + - ]: 377 : ImGui::TreePop();
853 : : } else {
854 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
855 : : }
856 : :
857 [ + - + - ]: 377 : if (ImGui::TreeNodeEx("Vibration Effects", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) {
858 [ + - + - ]: 377 : ImGui::NextColumn(); ImGui::NextColumn();
859 : :
860 : 377 : bool prev_vibration_norm = engine.m_auto_load_normalization_enabled;
861 [ + - - + ]: 377 : if (GuiWidgets::Checkbox("Enable Dynamic Load Normalization", &engine.m_auto_load_normalization_enabled, Tooltips::DYNAMIC_LOAD_NORMALIZATION_ENABLE).changed) {
862 [ # # # # ]: 0 : if (prev_vibration_norm && !engine.m_auto_load_normalization_enabled) {
863 [ # # ]: 0 : engine.ResetNormalization();
864 : : }
865 [ # # # # ]: 0 : Config::Save(engine);
866 : : }
867 : :
868 [ + - ]: 377 : FloatSetting("Texture Load Cap", &engine.m_texture_load_cap, 1.0f, 3.0f, "%.2fx", Tooltips::TEXTURE_LOAD_CAP);
869 [ + - ]: 377 : FloatSetting("Vibration Strength", &engine.m_vibration_gain, 0.0f, 2.0f, FormatPct(engine.m_vibration_gain), Tooltips::VIBRATION_GAIN);
870 : :
871 [ + - ]: 377 : BoolSetting("Slide Rumble", &engine.m_slide_texture_enabled, Tooltips::SLIDE_RUMBLE);
872 [ + + ]: 377 : if (engine.m_slide_texture_enabled) {
873 [ + - ]: 359 : FloatSetting(" Slide Gain", &engine.m_slide_texture_gain, 0.0f, 2.0f, FormatDecoupled(engine.m_slide_texture_gain, FFBEngine::BASE_NM_SLIDE_TEXTURE), Tooltips::SLIDE_GAIN);
874 [ + - ]: 359 : FloatSetting(" Slide Pitch", &engine.m_slide_freq_scale, 0.5f, 5.0f, "%.2fx", Tooltips::SLIDE_PITCH);
875 : : }
876 : :
877 [ + - ]: 377 : BoolSetting("Road Details", &engine.m_road_texture_enabled, Tooltips::ROAD_DETAILS);
878 [ + + ]: 377 : if (engine.m_road_texture_enabled) {
879 [ + - ]: 373 : FloatSetting(" Road Gain", &engine.m_road_texture_gain, 0.0f, 2.0f, FormatDecoupled(engine.m_road_texture_gain, FFBEngine::BASE_NM_ROAD_TEXTURE), Tooltips::ROAD_GAIN);
880 : : }
881 : :
882 [ + - ]: 377 : BoolSetting("Spin Vibration", &engine.m_spin_enabled, Tooltips::SPIN_VIBRATION);
883 [ + + ]: 377 : if (engine.m_spin_enabled) {
884 [ + - ]: 373 : FloatSetting(" Spin Strength", &engine.m_spin_gain, 0.0f, 2.0f, FormatDecoupled(engine.m_spin_gain, FFBEngine::BASE_NM_SPIN_VIBRATION), Tooltips::SPIN_STRENGTH);
885 [ + - ]: 373 : FloatSetting(" Spin Pitch", &engine.m_spin_freq_scale, 0.5f, 2.0f, "%.2fx", Tooltips::SPIN_PITCH);
886 : : }
887 : :
888 [ + - ]: 377 : FloatSetting("Scrub Drag", &engine.m_scrub_drag_gain, 0.0f, 1.0f, FormatDecoupled(engine.m_scrub_drag_gain, FFBEngine::BASE_NM_SCRUB_DRAG), Tooltips::SCRUB_DRAG);
889 : :
890 : 377 : const char* bottoming_modes[] = { "Method A: Scraping", "Method B: Susp. Spike" };
891 [ + - ]: 377 : IntSetting("Bottoming Logic", &engine.m_bottoming_method, bottoming_modes, sizeof(bottoming_modes)/sizeof(bottoming_modes[0]), Tooltips::BOTTOMING_LOGIC);
892 : :
893 [ + - ]: 377 : ImGui::TreePop();
894 : : } else {
895 [ # # # # ]: 0 : ImGui::NextColumn(); ImGui::NextColumn();
896 : : }
897 : :
898 [ + - - + ]: 377 : if (ImGui::CollapsingHeader("Advanced Settings")) {
899 [ # # ]: 0 : ImGui::Indent();
900 : :
901 [ # # # # ]: 0 : if (ImGui::TreeNode("Stationary Vibration Gate")) {
902 : 0 : float lower_kmh = engine.m_speed_gate_lower * 3.6f;
903 [ # # # # ]: 0 : if (ImGui::SliderFloat("Mute Below", &lower_kmh, 0.0f, 20.0f, "%.1f km/h")) {
904 : 0 : engine.m_speed_gate_lower = lower_kmh / 3.6f;
905 [ # # ]: 0 : if (engine.m_speed_gate_upper <= engine.m_speed_gate_lower + 0.1f)
906 : 0 : engine.m_speed_gate_upper = engine.m_speed_gate_lower + 0.5f;
907 : : }
908 [ # # # # : 0 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::MUTE_BELOW);
# # ]
909 [ # # # # : 0 : if (ImGui::IsItemDeactivatedAfterEdit()) Config::Save(engine);
# # # # ]
910 : :
911 : 0 : float upper_kmh = engine.m_speed_gate_upper * 3.6f;
912 [ # # # # ]: 0 : if (ImGui::SliderFloat("Full Above", &upper_kmh, 1.0f, 50.0f, "%.1f km/h")) {
913 : 0 : engine.m_speed_gate_upper = upper_kmh / 3.6f;
914 [ # # ]: 0 : if (engine.m_speed_gate_upper <= engine.m_speed_gate_lower + 0.1f)
915 : 0 : engine.m_speed_gate_upper = engine.m_speed_gate_lower + 0.5f;
916 : : }
917 [ # # # # : 0 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::FULL_ABOVE);
# # ]
918 [ # # # # : 0 : if (ImGui::IsItemDeactivatedAfterEdit()) Config::Save(engine);
# # # # ]
919 : :
920 [ # # ]: 0 : ImGui::TreePop();
921 : : }
922 : :
923 [ # # # # ]: 0 : if (ImGui::TreeNode("Telemetry Logger")) {
924 [ # # # # ]: 0 : if (ImGui::Checkbox("Enable Logging Logic", &Config::m_auto_start_logging)) {
925 [ # # # # ]: 0 : Config::Save(engine);
926 : : }
927 [ # # # # : 0 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::AUTO_START_LOGGING);
# # ]
928 : :
929 : : char log_path_buf[256];
930 : 0 : StringUtils::SafeCopy(log_path_buf, sizeof(log_path_buf), Config::m_log_path.c_str());
931 [ # # # # ]: 0 : if (ImGui::InputText("Log Path", log_path_buf, 255)) {
932 [ # # ]: 0 : Config::m_log_path = log_path_buf;
933 : : }
934 [ # # # # : 0 : if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", Tooltips::LOG_PATH);
# # ]
935 [ # # # # : 0 : if (ImGui::IsItemDeactivatedAfterEdit()) Config::Save(engine);
# # # # ]
936 : :
937 [ # # # # ]: 0 : if (AsyncLogger::Get().IsLogging()) {
938 [ # # # # : 0 : ImGui::BulletText("Filename: %s", AsyncLogger::Get().GetFilename().c_str());
# # ]
939 : : }
940 : :
941 [ # # ]: 0 : ImGui::TreePop();
942 : : }
943 [ # # ]: 0 : ImGui::Unindent();
944 : : }
945 : :
946 [ + - ]: 377 : ImGui::Columns(1);
947 [ + - ]: 377 : ImGui::End();
948 : 377 : }
949 : :
950 : : const float PLOT_HISTORY_SEC = 10.0f;
951 : : const int PHYSICS_RATE_HZ = 400;
952 : : const int PLOT_BUFFER_SIZE = (int)(PLOT_HISTORY_SEC * PHYSICS_RATE_HZ);
953 : :
954 : : struct RollingBuffer {
955 : : std::vector<float> data;
956 : : int offset = 0;
957 : :
958 : 46 : RollingBuffer() {
959 [ + - ]: 46 : data.resize(PLOT_BUFFER_SIZE, 0.0f);
960 : 46 : }
961 : :
962 : 0 : void Add(float val) {
963 : 0 : data[offset] = val;
964 : 0 : offset = (offset + 1) % (int)data.size();
965 : 0 : }
966 : :
967 : 992 : float GetCurrent() const {
968 [ - + ]: 992 : if (data.empty()) return 0.0f;
969 : 992 : size_t idx = (offset - 1 + (int)data.size()) % (int)data.size();
970 : 992 : return data[idx];
971 : : }
972 : :
973 : 992 : float GetMin() const {
974 [ - + ]: 992 : if (data.empty()) return 0.0f;
975 [ + - ]: 992 : return *std::min_element(data.begin(), data.end());
976 : : }
977 : :
978 : 992 : float GetMax() const {
979 [ - + ]: 992 : if (data.empty()) return 0.0f;
980 [ + - ]: 992 : return *std::max_element(data.begin(), data.end());
981 : : }
982 : : };
983 : :
984 : 992 : inline void PlotWithStats(const char* label, const RollingBuffer& buffer,
985 : : float scale_min, float scale_max,
986 : : const ImVec2& size = ImVec2(0, 40),
987 : : const char* tooltip = nullptr) {
988 [ + - ]: 992 : ImGui::Text("%s", label);
989 : : char hidden_label[256];
990 : 992 : StringUtils::SafeFormat(hidden_label, sizeof(hidden_label), "##%s", label);
991 [ + - ]: 992 : ImGui::PlotLines(hidden_label, buffer.data.data(), (int)buffer.data.size(),
992 : 992 : buffer.offset, NULL, scale_min, scale_max, size);
993 [ - + - - : 992 : if (tooltip && ImGui::IsItemHovered()) ImGui::SetTooltip("%s", tooltip);
- - - + -
- ]
994 : :
995 : 992 : float current = buffer.GetCurrent();
996 [ + - ]: 992 : float min_val = buffer.GetMin();
997 [ + - ]: 992 : float max_val = buffer.GetMax();
998 : : char stats_overlay[128];
999 : 992 : StringUtils::SafeFormat(stats_overlay, sizeof(stats_overlay), "Cur:%.4f Min:%.3f Max:%.3f", current, min_val, max_val);
1000 : :
1001 [ + - ]: 992 : ImVec2 p_min = ImGui::GetItemRectMin();
1002 [ + - ]: 992 : ImVec2 p_max = ImGui::GetItemRectMax();
1003 : 992 : float plot_width = p_max.x - p_min.x;
1004 : 992 : p_min.x += 2; p_min.y += 2;
1005 : :
1006 [ + - ]: 992 : ImDrawList* draw_list = ImGui::GetWindowDrawList();
1007 [ + - ]: 992 : ImFont* font = ImGui::GetFont();
1008 [ + - ]: 992 : float font_size = ImGui::GetFontSize();
1009 [ + - ]: 992 : ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, stats_overlay);
1010 : :
1011 [ - + ]: 992 : if (text_size.x > plot_width - 4) {
1012 : 0 : StringUtils::SafeFormat(stats_overlay, sizeof(stats_overlay), "%.4f [%.3f, %.3f]", current, min_val, max_val);
1013 [ # # ]: 0 : text_size = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, stats_overlay);
1014 [ # # ]: 0 : if (text_size.x > plot_width - 4) {
1015 : 0 : StringUtils::SafeFormat(stats_overlay, sizeof(stats_overlay), "Val: %.4f", current);
1016 [ # # ]: 0 : text_size = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, stats_overlay);
1017 : : }
1018 : : }
1019 [ + - ]: 992 : draw_list->AddRectFilled(ImVec2(p_min.x - 1, p_min.y), ImVec2(p_min.x + text_size.x + 2, p_min.y + text_size.y), IM_COL32(0, 0, 0, 90));
1020 [ + - ]: 992 : draw_list->AddText(font, font_size, p_min, IM_COL32(255, 255, 255, 255), stats_overlay);
1021 : 992 : }
1022 : :
1023 : : // Global Buffers
1024 : : static RollingBuffer plot_total, plot_base, plot_sop, plot_yaw_kick, plot_rear_torque, plot_gyro_damping, plot_scrub_drag, plot_soft_lock, plot_oversteer, plot_understeer, plot_clipping, plot_road, plot_slide, plot_lockup, plot_spin, plot_bottoming;
1025 : : static RollingBuffer plot_calc_front_load, plot_calc_rear_load, plot_calc_front_grip, plot_calc_rear_grip, plot_calc_slip_ratio, plot_calc_slip_angle_smoothed, plot_calc_rear_slip_angle_smoothed, plot_slope_current, plot_calc_rear_lat_force;
1026 : : static RollingBuffer plot_raw_steer, plot_raw_shaft_torque, plot_raw_gen_torque, plot_raw_input_steering, plot_raw_throttle, plot_raw_brake, plot_input_accel, plot_raw_car_speed, plot_raw_load, plot_raw_grip, plot_raw_rear_grip, plot_raw_front_slip_ratio, plot_raw_susp_force, plot_raw_ride_height, plot_raw_front_lat_patch_vel, plot_raw_front_long_patch_vel, plot_raw_rear_lat_patch_vel, plot_raw_rear_long_patch_vel, plot_raw_slip_angle, plot_raw_rear_slip_angle, plot_raw_front_deflection;
1027 : :
1028 : : static bool g_warn_dt = false;
1029 : :
1030 : 0 : void GuiLayer::UpdateTelemetry(FFBEngine& engine) {
1031 [ # # ]: 0 : auto snapshots = engine.GetDebugBatch();
1032 [ # # ]: 0 : for (const auto& snap : snapshots) {
1033 : 0 : m_latest_steering_range = snap.steering_range_deg;
1034 : 0 : m_latest_steering_angle = snap.steering_angle_deg;
1035 : :
1036 : 0 : plot_total.Add(snap.total_output);
1037 : 0 : plot_base.Add(snap.base_force);
1038 : 0 : plot_sop.Add(snap.sop_force);
1039 : 0 : plot_yaw_kick.Add(snap.ffb_yaw_kick);
1040 : 0 : plot_rear_torque.Add(snap.ffb_rear_torque);
1041 : 0 : plot_gyro_damping.Add(snap.ffb_gyro_damping);
1042 : 0 : plot_scrub_drag.Add(snap.ffb_scrub_drag);
1043 : 0 : plot_soft_lock.Add(snap.ffb_soft_lock);
1044 : 0 : plot_oversteer.Add(snap.oversteer_boost);
1045 : 0 : plot_understeer.Add(snap.understeer_drop);
1046 : 0 : plot_clipping.Add(snap.clipping);
1047 : 0 : plot_road.Add(snap.texture_road);
1048 : 0 : plot_slide.Add(snap.texture_slide);
1049 : 0 : plot_lockup.Add(snap.texture_lockup);
1050 : 0 : plot_spin.Add(snap.texture_spin);
1051 : 0 : plot_bottoming.Add(snap.texture_bottoming);
1052 : 0 : plot_calc_front_load.Add(snap.calc_front_load);
1053 : 0 : plot_calc_rear_load.Add(snap.calc_rear_load);
1054 : 0 : plot_calc_front_grip.Add(snap.calc_front_grip);
1055 : 0 : plot_calc_rear_grip.Add(snap.calc_rear_grip);
1056 : 0 : plot_calc_slip_ratio.Add(snap.calc_front_slip_ratio);
1057 : 0 : plot_calc_slip_angle_smoothed.Add(snap.calc_front_slip_angle_smoothed);
1058 : 0 : plot_calc_rear_slip_angle_smoothed.Add(snap.calc_rear_slip_angle_smoothed);
1059 : 0 : plot_calc_rear_lat_force.Add(snap.calc_rear_lat_force);
1060 : 0 : plot_slope_current.Add(snap.slope_current);
1061 : 0 : plot_raw_steer.Add(snap.steer_force);
1062 : 0 : plot_raw_shaft_torque.Add(snap.raw_shaft_torque);
1063 : 0 : plot_raw_gen_torque.Add(snap.raw_gen_torque);
1064 : 0 : plot_raw_input_steering.Add(snap.raw_input_steering);
1065 : 0 : plot_raw_throttle.Add(snap.raw_input_throttle);
1066 : 0 : plot_raw_brake.Add(snap.raw_input_brake);
1067 : 0 : plot_input_accel.Add(snap.accel_x);
1068 : 0 : plot_raw_car_speed.Add(snap.raw_car_speed);
1069 : 0 : plot_raw_load.Add(snap.raw_front_tire_load);
1070 : 0 : plot_raw_grip.Add(snap.raw_front_grip_fract);
1071 : 0 : plot_raw_rear_grip.Add(snap.raw_rear_grip);
1072 : 0 : plot_raw_front_slip_ratio.Add(snap.raw_front_slip_ratio);
1073 : 0 : plot_raw_susp_force.Add(snap.raw_front_susp_force);
1074 : 0 : plot_raw_ride_height.Add(snap.raw_front_ride_height);
1075 : 0 : plot_raw_front_lat_patch_vel.Add(snap.raw_front_lat_patch_vel);
1076 : 0 : plot_raw_front_long_patch_vel.Add(snap.raw_front_long_patch_vel);
1077 : 0 : plot_raw_rear_lat_patch_vel.Add(snap.raw_rear_lat_patch_vel);
1078 : 0 : plot_raw_rear_long_patch_vel.Add(snap.raw_rear_long_patch_vel);
1079 : 0 : plot_raw_slip_angle.Add(snap.raw_front_slip_angle);
1080 : 0 : plot_raw_rear_slip_angle.Add(snap.raw_rear_slip_angle);
1081 : 0 : plot_raw_front_deflection.Add(snap.raw_front_deflection);
1082 : 0 : g_warn_dt = snap.warn_dt;
1083 : : }
1084 : 0 : }
1085 : :
1086 : 63 : void GuiLayer::DrawDebugWindow(FFBEngine& engine) {
1087 [ + + ]: 63 : if (!Config::show_graphs) return;
1088 : :
1089 : 62 : ImGuiViewport* viewport = ImGui::GetMainViewport();
1090 [ + - ]: 62 : ImGui::SetNextWindowPos(ImVec2(viewport->WorkPos.x + CONFIG_PANEL_WIDTH, viewport->WorkPos.y));
1091 [ + - ]: 62 : ImGui::SetNextWindowSize(ImVec2(viewport->WorkSize.x - CONFIG_PANEL_WIDTH, viewport->WorkSize.y));
1092 : :
1093 : 62 : ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
1094 : 62 : ImGui::Begin("FFB Analysis", nullptr, flags);
1095 : :
1096 : : // System Health Diagnostics (Moved from Tuning window - Issue #149)
1097 [ + - ]: 62 : if (ImGui::CollapsingHeader("System Health", ImGuiTreeNodeFlags_DefaultOpen)) {
1098 : 310 : HealthStatus hs = HealthMonitor::Check(engine.m_ffb_rate, engine.m_telemetry_rate, engine.m_gen_torque_rate, engine.m_torque_source, engine.m_physics_rate,
1099 [ + - + - : 62 : GameConnector::Get().IsConnected(), GameConnector::Get().IsSessionActive(), GameConnector::Get().GetSessionType(), GameConnector::Get().IsInRealtime(), GameConnector::Get().GetPlayerControl());
+ - + - +
- + - ]
1100 : :
1101 [ + - ]: 62 : ImGui::Columns(6, "RateCols", false);
1102 [ + - ]: 62 : DisplayRate("USB Loop", engine.m_ffb_rate, 1000.0);
1103 [ + - ]: 62 : ImGui::NextColumn();
1104 [ + - ]: 62 : DisplayRate("Physics", engine.m_physics_rate, 400.0);
1105 [ + - ]: 62 : ImGui::NextColumn();
1106 [ + - ]: 62 : DisplayRate("Telemetry", engine.m_telemetry_rate, 100.0); // Standard LMU is 100Hz
1107 [ + - ]: 62 : ImGui::NextColumn();
1108 [ + - ]: 62 : DisplayRate("Hardware", engine.m_hw_rate, 1000.0);
1109 [ + - ]: 62 : ImGui::NextColumn();
1110 [ + - ]: 62 : DisplayRate("S.Torque", engine.m_torque_rate, 100.0);
1111 [ + - ]: 62 : ImGui::NextColumn();
1112 [ + - ]: 62 : DisplayRate("G.Torque", engine.m_gen_torque_rate, 400.0);
1113 [ + - ]: 62 : ImGui::Columns(1);
1114 : :
1115 [ + - ]: 62 : ImGui::Separator();
1116 : :
1117 : : // Robust State Machine (#269, #274)
1118 [ + + ]: 62 : if (!hs.is_connected) {
1119 [ + - ]: 55 : ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "Sim: Disconnected from LMU");
1120 : : } else {
1121 : 7 : bool active = hs.session_active;
1122 [ - + - + : 7 : ImGui::TextColored(active ? ImVec4(0.4f, 1.0f, 0.4f, 1.0f) : ImVec4(0.7f, 0.7f, 0.7f, 1.0f),
+ - ]
1123 : : "Sim: %s", active ? "Track Loaded" : "Main Menu");
1124 : : }
1125 : :
1126 [ + + - + ]: 62 : if (hs.is_connected && hs.session_active) {
1127 [ # # ]: 0 : ImGui::SameLine();
1128 : 0 : const char* sessionStr = "Unknown";
1129 : 0 : long stype = hs.session_type;
1130 [ # # ]: 0 : if (stype == 0) sessionStr = "Test Day";
1131 [ # # # # ]: 0 : else if (stype >= 1 && stype <= 4) sessionStr = "Practice";
1132 [ # # # # ]: 0 : else if (stype >= 5 && stype <= 8) sessionStr = "Qualifying";
1133 [ # # ]: 0 : else if (stype == 9) sessionStr = "Warmup";
1134 [ # # # # ]: 0 : else if (stype >= 10 && stype <= 13) sessionStr = "Race";
1135 [ # # ]: 0 : ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "| Session: %s", sessionStr);
1136 : :
1137 : 0 : bool driving = hs.is_realtime;
1138 [ # # # # : 0 : ImGui::TextColored(driving ? ImVec4(0.4f, 1.0f, 0.4f, 1.0f) : ImVec4(1.0f, 1.0f, 0.4f, 1.0f),
# # ]
1139 : : "State: %s", driving ? "Driving" : "In Menu");
1140 : :
1141 [ # # ]: 0 : ImGui::SameLine();
1142 : 0 : const char* ctrlStr = "Unknown";
1143 : 0 : signed char ctrl = hs.player_control;
1144 [ # # # # : 0 : switch (ctrl) {
# # ]
1145 : 0 : case -1: ctrlStr = "Nobody"; break;
1146 : 0 : case 0: ctrlStr = "Player"; break;
1147 : 0 : case 1: ctrlStr = "AI"; break;
1148 : 0 : case 2: ctrlStr = "Remote"; break;
1149 : 0 : case 3: ctrlStr = "Replay"; break;
1150 : 0 : default: ctrlStr = "Unknown"; break;
1151 : : }
1152 [ # # ]: 0 : ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "| Control: %s", ctrlStr);
1153 : : }
1154 : :
1155 [ + + + + : 62 : if (!hs.is_healthy && engine.m_telemetry_rate > 1.0 && GameConnector::Get().IsConnected()) {
+ - + - +
- + + ]
1156 [ + - ]: 6 : ImGui::TextColored(ImVec4(1, 1, 0, 1), "Warning: Sub-optimal sample rates detected. Check game settings.");
1157 : : }
1158 [ + - ]: 62 : ImGui::Separator();
1159 : : }
1160 : :
1161 : :
1162 [ - + ]: 62 : if (g_warn_dt) {
1163 [ # # ]: 0 : ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f));
1164 : 0 : ImGui::Text("TELEMETRY WARNINGS: - Invalid DeltaTime");
1165 : 0 : ImGui::PopStyleColor();
1166 : 0 : ImGui::Separator();
1167 : : }
1168 : :
1169 [ + - ]: 62 : if (ImGui::CollapsingHeader("A. FFB Components (Output)", ImGuiTreeNodeFlags_DefaultOpen)) {
1170 [ + - ]: 62 : PlotWithStats("Total Output", plot_total, -1.0f, 1.0f, ImVec2(0, 60));
1171 : 62 : ImGui::Separator();
1172 : 62 : ImGui::Columns(3, "FFBMain", false);
1173 [ + - ]: 62 : ImGui::TextColored(ImVec4(0.7f, 0.7f, 1.0f, 1.0f), "[Main Forces]");
1174 [ + - ]: 62 : PlotWithStats("Base Torque (Nm)", plot_base, -30.0f, 30.0f);
1175 [ + - ]: 62 : PlotWithStats("SoP (Chassis G)", plot_sop, -20.0f, 20.0f);
1176 [ + - ]: 62 : PlotWithStats("Yaw Kick", plot_yaw_kick, -20.0f, 20.0f);
1177 [ + - ]: 62 : PlotWithStats("Rear Align", plot_rear_torque, -20.0f, 20.0f);
1178 [ + - ]: 62 : PlotWithStats("Gyro Damping", plot_gyro_damping, -20.0f, 20.0f);
1179 [ + - ]: 62 : PlotWithStats("Scrub Drag", plot_scrub_drag, -20.0f, 20.0f);
1180 [ + - ]: 62 : PlotWithStats("Soft Lock", plot_soft_lock, -50.0f, 50.0f);
1181 : 62 : ImGui::NextColumn();
1182 [ + - ]: 62 : ImGui::TextColored(ImVec4(1.0f, 0.7f, 0.7f, 1.0f), "[Modifiers]");
1183 [ + - ]: 62 : PlotWithStats("Lateral G Boost", plot_oversteer, -20.0f, 20.0f);
1184 [ + - ]: 62 : PlotWithStats("Understeer Cut", plot_understeer, -20.0f, 20.0f);
1185 [ + - ]: 62 : PlotWithStats("Clipping", plot_clipping, 0.0f, 1.1f);
1186 : 62 : ImGui::NextColumn();
1187 [ + - ]: 62 : ImGui::TextColored(ImVec4(0.7f, 1.0f, 0.7f, 1.0f), "[Textures]");
1188 [ + - ]: 62 : PlotWithStats("Road Texture", plot_road, -10.0f, 10.0f);
1189 [ + - ]: 62 : PlotWithStats("Slide Texture", plot_slide, -10.0f, 10.0f);
1190 [ + - ]: 62 : PlotWithStats("Lockup Vib", plot_lockup, -10.0f, 10.0f);
1191 [ + - ]: 62 : PlotWithStats("Spin Vib", plot_spin, -10.0f, 10.0f);
1192 [ + - ]: 62 : PlotWithStats("Bottoming", plot_bottoming, -10.0f, 10.0f);
1193 : 62 : ImGui::Columns(1);
1194 : : }
1195 : :
1196 [ - + ]: 62 : if (ImGui::CollapsingHeader("B. Internal Physics (Brain)", ImGuiTreeNodeFlags_None)) {
1197 [ # # ]: 0 : ImGui::Columns(3, "PhysCols", false);
1198 [ # # ]: 0 : ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "[Loads]");
1199 [ # # ]: 0 : ImGui::Text("Front: %.0f N | Rear: %.0f N", plot_calc_front_load.GetCurrent(), plot_calc_rear_load.GetCurrent());
1200 [ # # ]: 0 : ImGui::PushStyleColor(ImGuiCol_PlotLines, ImVec4(0.0f, 1.0f, 1.0f, 1.0f));
1201 [ # # ]: 0 : ImGui::PlotLines("##CLoadF", plot_calc_front_load.data.data(), (int)plot_calc_front_load.data.size(), plot_calc_front_load.offset, NULL, 0.0f, 10000.0f, ImVec2(0, 40));
1202 [ # # ]: 0 : ImGui::PopStyleColor();
1203 [ # # ]: 0 : ImVec2 pos_load = ImGui::GetItemRectMin();
1204 [ # # ]: 0 : ImGui::SetCursorScreenPos(pos_load);
1205 [ # # ]: 0 : ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0,0,0,0));
1206 [ # # ]: 0 : ImGui::PushStyleColor(ImGuiCol_PlotLines, ImVec4(1.0f, 0.0f, 1.0f, 1.0f));
1207 [ # # ]: 0 : ImGui::PlotLines("##CLoadR", plot_calc_rear_load.data.data(), (int)plot_calc_rear_load.data.size(), plot_calc_rear_load.offset, NULL, 0.0f, 10000.0f, ImVec2(0, 40));
1208 [ # # ]: 0 : ImGui::PopStyleColor(2);
1209 [ # # ]: 0 : ImGui::NextColumn();
1210 [ # # ]: 0 : ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "[Grip/Slip]");
1211 [ # # ]: 0 : PlotWithStats("Calc Front Grip", plot_calc_front_grip, 0.0f, 1.2f);
1212 [ # # ]: 0 : PlotWithStats("Calc Rear Grip", plot_calc_rear_grip, 0.0f, 1.2f);
1213 [ # # ]: 0 : PlotWithStats("Front Slip Ratio", plot_calc_slip_ratio, -1.0f, 1.0f);
1214 [ # # ]: 0 : PlotWithStats("Front Slip Angle", plot_calc_slip_angle_smoothed, 0.0f, 1.0f);
1215 [ # # ]: 0 : PlotWithStats("Rear Slip Angle", plot_calc_rear_slip_angle_smoothed, 0.0f, 1.0f);
1216 [ # # # # ]: 0 : if (engine.m_slope_detection_enabled) PlotWithStats("Slope", plot_slope_current, -5.0f, 5.0f);
1217 [ # # ]: 0 : ImGui::NextColumn();
1218 [ # # ]: 0 : ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "[Forces]");
1219 [ # # ]: 0 : PlotWithStats("Calc Rear Lat Force", plot_calc_rear_lat_force, -5000.0f, 5000.0f);
1220 [ # # ]: 0 : ImGui::Columns(1);
1221 : : }
1222 : :
1223 [ - + ]: 62 : if (ImGui::CollapsingHeader("C. Raw Game Telemetry (Input)", ImGuiTreeNodeFlags_None)) {
1224 [ # # ]: 0 : ImGui::Columns(4, "TelCols", false);
1225 [ # # ]: 0 : ImGui::TextColored(ImVec4(0.0f, 1.0f, 1.0f, 1.0f), "[Driver Input]");
1226 [ # # ]: 0 : PlotWithStats("Selected Torque", plot_raw_steer, -30.0f, 30.0f, ImVec2(0, 40), Tooltips::PLOT_SELECTED_TORQUE);
1227 [ # # ]: 0 : PlotWithStats("Shaft Torque (100Hz)", plot_raw_shaft_torque, -30.0f, 30.0f, ImVec2(0, 40), Tooltips::PLOT_SHAFT_TORQUE);
1228 [ # # ]: 0 : PlotWithStats("In-Game FFB (400Hz)", plot_raw_gen_torque, -30.0f, 30.0f, ImVec2(0, 40), Tooltips::PLOT_INGAME_FFB);
1229 [ # # ]: 0 : PlotWithStats("Steering Input", plot_raw_input_steering, -1.0f, 1.0f);
1230 [ # # ]: 0 : ImGui::Text("Combined Input");
1231 [ # # ]: 0 : ImVec2 pos = ImGui::GetCursorScreenPos();
1232 [ # # ]: 0 : ImGui::PushStyleColor(ImGuiCol_PlotLines, ImVec4(1.0f, 0.0f, 0.0f, 1.0f));
1233 [ # # ]: 0 : ImGui::PlotLines("##BrkComb", plot_raw_brake.data.data(), (int)plot_raw_brake.data.size(), plot_raw_brake.offset, NULL, 0.0f, 1.0f, ImVec2(0, 40));
1234 [ # # ]: 0 : ImGui::PopStyleColor();
1235 [ # # ]: 0 : ImGui::SetCursorScreenPos(pos);
1236 [ # # ]: 0 : ImGui::PushStyleColor(ImGuiCol_PlotLines, ImVec4(0.0f, 1.0f, 0.0f, 1.0f));
1237 [ # # ]: 0 : ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
1238 [ # # ]: 0 : ImGui::PlotLines("##ThrComb", plot_raw_throttle.data.data(), (int)plot_raw_throttle.data.size(), plot_raw_throttle.offset, NULL, 0.0f, 1.0f, ImVec2(0, 40));
1239 [ # # ]: 0 : ImGui::PopStyleColor(2);
1240 [ # # ]: 0 : ImGui::NextColumn();
1241 [ # # ]: 0 : ImGui::TextColored(ImVec4(0.0f, 1.0f, 1.0f, 1.0f), "[Vehicle State]");
1242 [ # # ]: 0 : PlotWithStats("Lat Accel", plot_input_accel, -20.0f, 20.0f);
1243 [ # # ]: 0 : PlotWithStats("Speed (m/s)", plot_raw_car_speed, 0.0f, 100.0f);
1244 [ # # ]: 0 : ImGui::NextColumn();
1245 [ # # ]: 0 : ImGui::TextColored(ImVec4(0.0f, 1.0f, 1.0f, 1.0f), "[Raw Tire Data]");
1246 [ # # ]: 0 : PlotWithStats("Raw Front Load", plot_raw_load, 0.0f, 10000.0f);
1247 [ # # ]: 0 : PlotWithStats("Raw Front Grip", plot_raw_grip, 0.0f, 1.2f);
1248 [ # # ]: 0 : PlotWithStats("Raw Rear Grip", plot_raw_rear_grip, 0.0f, 1.2f);
1249 [ # # ]: 0 : ImGui::NextColumn();
1250 [ # # ]: 0 : ImGui::TextColored(ImVec4(0.0f, 1.0f, 1.0f, 1.0f), "[Patch Velocities]");
1251 [ # # ]: 0 : PlotWithStats("F-Lat PatchVel", plot_raw_front_lat_patch_vel, 0.0f, 20.0f);
1252 [ # # ]: 0 : PlotWithStats("R-Lat PatchVel", plot_raw_rear_lat_patch_vel, 0.0f, 20.0f);
1253 [ # # ]: 0 : PlotWithStats("F-Long PatchVel", plot_raw_front_long_patch_vel, -20.0f, 20.0f);
1254 [ # # ]: 0 : PlotWithStats("R-Long PatchVel", plot_raw_rear_long_patch_vel, -20.0f, 20.0f);
1255 [ # # ]: 0 : ImGui::Columns(1);
1256 : : }
1257 : :
1258 : 62 : ImGui::End();
1259 : : }
1260 : : #endif
1261 : :
1262 : : #ifndef ENABLE_IMGUI
1263 : : void GuiLayer::DrawMenuBar(FFBEngine& engine) {}
1264 : : #endif
|