From a374d576166399c2e946d76d52740b33e00db695 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Thu, 21 Jan 2021 15:26:24 -0500 Subject: relax requirements when deserializing settings --- wrapper/wrapper.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index 46e7e3a..c7318b8 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -86,10 +86,10 @@ public ref struct DriverSettings [JsonProperty("Negative directional multipliers", Required = Required::Default)] Vec2 directionalMultipliers; - [JsonProperty("Stretches domain for horizontal vs vertical inputs")] + [JsonProperty("Stretches domain for horizontal vs vertical inputs", Required = Required::Default)] DomainArgs domainArgs; - [JsonProperty("Stretches accel range for horizontal vs vertical inputs")] + [JsonProperty("Stretches accel range for horizontal vs vertical inputs", Required = Required::Default)] Vec2 rangeXY; [JsonProperty(Required = Required::Default)] @@ -103,6 +103,12 @@ public ref struct DriverSettings { return minimumTime > 0 && minimumTime != DEFAULT_TIME_MIN; } + + DriverSettings() + { + domainArgs = { { 1, 1 }, 2 }; + rangeXY = { 1, 1 }; + } }; -- cgit v1.2.3 From e74f14f2d4fdd39001f98df9f3e2ec33b13c967f Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Thu, 21 Jan 2021 15:28:51 -0500 Subject: direction/distance calc - small opts --- common/rawaccel.hpp | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp index c617bed..d17a460 100644 --- a/common/rawaccel.hpp +++ b/common/rawaccel.hpp @@ -232,7 +232,7 @@ namespace rawaccel { double sigma_x = 1.0; double sigma_y = 1.0; - weighted_distance(domain_args args) + weighted_distance(const domain_args& args) { sigma_x = args.domain_weights.x; sigma_y = args.domain_weights.y; @@ -250,19 +250,18 @@ namespace rawaccel { } } - double calculate(double x, double y) + inline double calculate(double x, double y) { double abs_x = fabs(x); double abs_y = fabs(y); - if (lp_norm_infinity) - { - return abs_x > abs_y ? abs_x : abs_y; - } + if (lp_norm_infinity) return maxsd(abs_x, abs_y); double x_scaled = abs_x * sigma_x; double y_scaled = abs_y * sigma_y; - return pow(pow(x_scaled, p) + pow(y_scaled, p), p_inverse); + + if (p == 2) return sqrtsd(x_scaled * x_scaled + y_scaled * y_scaled); + else return pow(pow(x_scaled, p) + pow(y_scaled, p), p_inverse); } weighted_distance() = default; @@ -273,19 +272,12 @@ namespace rawaccel { double start = 1.0; bool should_apply = false; - direction_weight(vec2d thetas) + direction_weight(const vec2d& thetas) { diff = thetas.y - thetas.x; start = thetas.x; - if (diff != 0) - { - should_apply = true; - } - else - { - should_apply = false; - } + should_apply = diff != 0; } inline double atan_scale(double x, double y) @@ -293,7 +285,7 @@ namespace rawaccel { return M_2_PI * atan2(fabs(y), fabs(x)); } - double apply(double x, double y) + inline double apply(double x, double y) { return atan_scale(x, y) * diff + start; } -- cgit v1.2.3 From 8dac6b3ff1d3fa434c4cd1db752ba34681cae8b4 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Thu, 21 Jan 2021 22:35:37 -0500 Subject: add angle snapping probably works like interaccel --- common/rawaccel-settings.h | 1 + common/rawaccel.hpp | 32 +++++++++++++++++++++++++++ driver/driver.cpp | 1 + grapher/Models/AccelGUI.cs | 1 + grapher/Models/Serialized/RawAccelSettings.cs | 1 + wrapper/wrapper.cpp | 3 +++ 6 files changed, 39 insertions(+) diff --git a/common/rawaccel-settings.h b/common/rawaccel-settings.h index 6fa2aa9..dedef6d 100644 --- a/common/rawaccel-settings.h +++ b/common/rawaccel-settings.h @@ -19,6 +19,7 @@ namespace rawaccel { struct settings { double degrees_rotation = 0; + double degrees_snap = 0; bool combine_mags = true; vec2 modes = { accel_mode::noaccel, accel_mode::noaccel }; vec2 argsv; diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp index d17a460..4c1e597 100644 --- a/common/rawaccel.hpp +++ b/common/rawaccel.hpp @@ -42,6 +42,26 @@ namespace rawaccel { rotator() = default; }; + struct snapper { + double threshold = 0; + + inline vec2d apply(const vec2d& input) const { + if (input.x != 0 && input.y != 0) { + double angle = fabs(atan(input.y / input.x)); + auto mag = [&] { return sqrtsd(input.x * input.x + input.y * input.y); }; + + if (angle > M_PI_2 - threshold) return { 0, _copysign(mag(), input.y) }; + if (angle < threshold) return { _copysign(mag(), input.x), 0 }; + } + + return input; + } + + snapper(double degrees) : threshold(minsd(fabs(degrees), 45) * M_PI / 180) {} + + snapper() = default; + }; + /// Struct to hold clamp (min and max) details for acceleration application struct accel_scale_clamp { double lo = 0; @@ -296,9 +316,11 @@ namespace rawaccel { /// Struct to hold variables and methods for modifying mouse input struct mouse_modifier { bool apply_rotate = false; + bool apply_snap = false; bool apply_accel = false; bool combine_magnitudes = true; rotator rotate; + snapper snap; weighted_distance distance; direction_weight directional; vec2 accels; @@ -313,6 +335,11 @@ namespace rawaccel { apply_rotate = true; } + if (args.degrees_snap != 0) { + snap = snapper(args.degrees_snap); + apply_snap = true; + } + if (args.sens.x != 0) sensitivity.x = args.sens.x; if (args.sens.y != 0) sensitivity.y = args.sens.y; @@ -336,6 +363,7 @@ namespace rawaccel { void modify(vec2d& movement, milliseconds time) { apply_rotation(movement); + apply_angle_snap(movement); apply_acceleration(movement, [=] { return time; }); apply_sensitivity(movement); } @@ -344,6 +372,10 @@ namespace rawaccel { if (apply_rotate) movement = rotate.apply(movement); } + inline void apply_angle_snap(vec2d& movement) { + if (apply_snap) movement = snap.apply(movement); + } + template inline void apply_acceleration(vec2d& movement, TimeSupplier time_supp) { if (apply_accel) { diff --git a/driver/driver.cpp b/driver/driver.cpp index a92f773..0c21f34 100644 --- a/driver/driver.cpp +++ b/driver/driver.cpp @@ -74,6 +74,7 @@ Arguments: }; global.modifier.apply_rotation(input); + global.modifier.apply_angle_snap(input); if (enable_accel) { auto time_supplier = [=] { diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 5cd7012..4dd7caa 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -144,6 +144,7 @@ namespace grapher var settings = new DriverSettings { rotation = ApplyOptions.Rotation.Field.Data, + snap = driverSettings.snap, sensitivity = new Vec2 { x = ApplyOptions.Sensitivity.Fields.X, diff --git a/grapher/Models/Serialized/RawAccelSettings.cs b/grapher/Models/Serialized/RawAccelSettings.cs index f4fb1e2..17db910 100644 --- a/grapher/Models/Serialized/RawAccelSettings.cs +++ b/grapher/Models/Serialized/RawAccelSettings.cs @@ -131,6 +131,7 @@ namespace grapher.Models.Serialized accelSettings.directionalMultipliers.x <= 0 && accelSettings.directionalMultipliers.y <= 0 && accelSettings.rotation == 0 && + accelSettings.snap == 0 && accelSettings.modes.x == AccelMode.noaccel && wholeOrNoY; } diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index c7318b8..f5672a1 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -70,6 +70,9 @@ public ref struct DriverSettings [JsonProperty("Degrees of rotation")] double rotation; + [JsonProperty("Degrees of angle snapping", Required = Required::Default)] + double snap; + [JsonProperty("Use x as whole/combined accel")] [MarshalAs(UnmanagedType::U1)] bool combineMagnitudes; -- cgit v1.2.3 From c346fa7baba3e14d8a2cc088eaee118ad269ace4 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Thu, 21 Jan 2021 22:40:56 -0500 Subject: update signed --- common/rawaccel-version.h | 2 +- installer/installer.rc | 2 +- signed/driver/rawaccel.sys | Bin 61640 -> 69896 bytes signed/installer.exe | Bin 59784 -> 60296 bytes signed/uninstaller.exe | Bin 55176 -> 55688 bytes 5 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/rawaccel-version.h b/common/rawaccel-version.h index 0e02036..d2c7922 100644 --- a/common/rawaccel-version.h +++ b/common/rawaccel-version.h @@ -4,7 +4,7 @@ #define RA_VER_MINOR 4 #define RA_VER_PATCH 0 -#define RA_MIN_OS "Win7" +#define RA_OS "Win7+" #define M_STR_HELPER(x) #x #define M_STR(x) M_STR_HELPER(x) diff --git a/installer/installer.rc b/installer/installer.rc index 43672d7..6d69e2d 100644 --- a/installer/installer.rc +++ b/installer/installer.rc @@ -70,7 +70,7 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "FileDescription", "Raw Accel installer (" RA_MIN_OS ")" + VALUE "FileDescription", "Raw Accel installer (" RA_OS ")" VALUE "FileVersion", RA_VER_STRING VALUE "OriginalFilename", "installer.exe" VALUE "ProductName", "Raw Accel" diff --git a/signed/driver/rawaccel.sys b/signed/driver/rawaccel.sys index 0fef07f..653d927 100644 Binary files a/signed/driver/rawaccel.sys and b/signed/driver/rawaccel.sys differ diff --git a/signed/installer.exe b/signed/installer.exe index 38f9201..99f1d32 100644 Binary files a/signed/installer.exe and b/signed/installer.exe differ diff --git a/signed/uninstaller.exe b/signed/uninstaller.exe index aa59df9..cfbf0dd 100644 Binary files a/signed/uninstaller.exe and b/signed/uninstaller.exe differ -- cgit v1.2.3 From d5316b36a285287a3e02a1c568c4b66f02c23c7b Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Thu, 21 Jan 2021 22:54:30 -0500 Subject: center gui on initial resize position is no longer based on the Form.Location property, should fix issues with multi-monitor setups --- grapher/Form1.cs | 17 +++++++++++++---- grapher/Models/AccelGUI.cs | 1 - 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/grapher/Form1.cs b/grapher/Form1.cs index 71a5e01..6927211 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -160,6 +160,8 @@ namespace grapher DirectionalityRangeLabel, RangeActiveValueX, RangeActiveValueY); + + ResizeAndCenter(); } #endregion Constructor @@ -191,18 +193,25 @@ namespace grapher chartsPanel.AutoScrollPosition = Constants.Origin; } - public void DoResize() + public void ResizeAndCenter() { ResetAutoScroll(); - var workingArea = Screen.PrimaryScreen.WorkingArea; + var workingArea = Screen.FromControl(this).WorkingArea; var chartsPreferredSize = chartsPanel.GetPreferredSize(Constants.MaxSize); Size = new Size { - Width = Math.Min(workingArea.Width - Location.X, optionsPanel.Size.Width + chartsPreferredSize.Width), - Height = Math.Min(workingArea.Height - Location.Y, chartsPreferredSize.Height + 48) + Width = Math.Min(workingArea.Width, optionsPanel.Size.Width + chartsPreferredSize.Width), + Height = Math.Min(workingArea.Height, chartsPreferredSize.Height + 48) }; + + Location = new Point + { + X = workingArea.X + (workingArea.Width - Size.Width) / 2, + Y = workingArea.Y + (workingArea.Height - Size.Height) / 2 + }; + } #endregion Method diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index 4dd7caa..a0d3aa8 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -71,7 +71,6 @@ namespace grapher } SetupButtons(); - AccelForm.DoResize(); // TODO: The below removes an overlapping form from the anisotropy panel. // Figure out why and remove the overlap and below. -- cgit v1.2.3 From c50b20015d3032b2045ddaf9b6987ddbce855b06 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Thu, 21 Jan 2021 22:56:55 -0500 Subject: change toggle text, "enabled" -> "disable" --- grapher/Models/AccelGUI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index a0d3aa8..3a30a9b 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -229,7 +229,7 @@ namespace grapher ToggleButton.Checked = LastToggleChecked; ToggleButton.Font = DefaultButtonFont; - ToggleButton.Text = ToggleButton.Checked ? "Enabled" : "Disabled"; + ToggleButton.Text = ToggleButton.Checked ? "Disable" : "Enable"; ToggleButton.Update(); WriteButton.Font = DefaultButtonFont; -- cgit v1.2.3