diff --git a/UFV Controller/imgui.ini b/UFV Controller/imgui.ini index 8dc175a..a5aec6e 100644 --- a/UFV Controller/imgui.ini +++ b/UFV Controller/imgui.ini @@ -102,7 +102,7 @@ Collapsed=0 DockId=0x00000010,0 [Docking][Data] -DockSpace ID=0xF2944C7F Window=0x4647B76E Pos=138,187 Size=1600,874 Split=Y +DockSpace ID=0xF2944C7F Window=0x4647B76E Pos=64,108 Size=1600,874 Split=Y DockNode ID=0x0000000A Parent=0xF2944C7F SizeRef=1920,704 Split=X DockNode ID=0x00000003 Parent=0x0000000A SizeRef=1088,874 Split=X DockNode ID=0x0000000B Parent=0x00000003 SizeRef=505,874 Split=X Selected=0xB10717DB diff --git a/UFV Controller/presets.dat b/UFV Controller/presets.dat index 61cc367..5bf0a4a 100644 Binary files a/UFV Controller/presets.dat and b/UFV Controller/presets.dat differ diff --git a/UFV Controller/src/Layers/PresetsLayer.cpp b/UFV Controller/src/Layers/PresetsLayer.cpp index 23fb750..ea38404 100644 --- a/UFV Controller/src/Layers/PresetsLayer.cpp +++ b/UFV Controller/src/Layers/PresetsLayer.cpp @@ -1,6 +1,18 @@ #include "PresetsLayer.h" #include "../Win32Helpers.h" +static void ClampPresets() +{ + for (int i = 0; i < NUM_PRESETS; ++i) + { + angle_preset* preset = g_anglePresets + i; + if (preset->pan < -80) preset->pan = -80; + if (preset->pan > 80) preset->pan = 80; + if (preset->tilt < -5) preset->tilt = -5; + if (preset->tilt > 80) preset->tilt = 80; + } +} + static void SavePresets() { HANDLE file = CreateFileA("presets.dat", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); @@ -33,6 +45,8 @@ static void LoadPresets() else Win32Log("[LoadPresets] CreateFileA() failed with error %d: %s", GetLastError(), Win32GetErrorCodeDescription(GetLastError()).c_str()); + + ClampPresets(); } void PresetsLayer::OnUIRender() @@ -51,6 +65,8 @@ void PresetsLayer::OnUIRender() ImGui::InputInt2(buf2, g_anglePresets[i].angles); } + ClampPresets(); + if (ImGui::Button("Save these presets")) { SavePresets(); diff --git a/UFV Controller/src/WalnutApp.h b/UFV Controller/src/WalnutApp.h index 5b4ed8b..83c857b 100644 --- a/UFV Controller/src/WalnutApp.h +++ b/UFV Controller/src/WalnutApp.h @@ -14,14 +14,14 @@ extern ufv_state g_ufvState; #define NUM_PRESETS 6 struct angle_preset { - struct - { - int pan; - int tilt; - }; union { int angles[2]; + struct + { + int pan; + int tilt; + }; }; };