Skip to content

Added more options to control the Custom Curve#103

Merged
AndyFilter merged 2 commits into
AndyFilter:masterfrom
anengineer1:feature/custom_curve
Jul 19, 2026
Merged

Added more options to control the Custom Curve#103
AndyFilter merged 2 commits into
AndyFilter:masterfrom
anengineer1:feature/custom_curve

Conversation

@anengineer1

@anengineer1 anengineer1 commented May 18, 2026

Copy link
Copy Markdown

Greetings, I've been studying what people do with a mouse accel software called Custom Curve and I wanted YeetMouse to have more of that functionality.

I considered building on top of you approach and use the quadratic function present in the ImGui stack.

Better to show with a video:

Screencast.From.2026-05-18.20-35-50.mp4

Now you can more easily have curves like "precision" with this new functionality (yes, that profile is quite popular among 1 frame flickers).

image

I'm sorry for saying this but it seems that something in master broke the action of refreshing curve when one drags control points (I tested master without my changes and it doesn't work). The demo I made was made before I rebased the commit with the latest changes from master. (see issue #102)

Btw, why this limit? #define CURVE_POINTS_MARGIN 0.2f why 0.2?

Thank you a lot for your work. I love this driver.

@anengineer1
anengineer1 force-pushed the feature/custom_curve branch from 02e4d34 to 1394ec3 Compare May 19, 2026 21:55
@anengineer1
anengineer1 marked this pull request as draft May 19, 2026 22:10
@anengineer1

Copy link
Copy Markdown
Author

I'm sorry, I'm converting this into a draft, I did review the code and did more testing and it still needs work.

@anengineer1
anengineer1 force-pushed the feature/custom_curve branch 6 times, most recently from 95427e0 to cce14dd Compare May 26, 2026 22:06
@anengineer1
anengineer1 force-pushed the feature/custom_curve branch from cce14dd to ccd51f9 Compare May 31, 2026 12:02
@anengineer1
anengineer1 marked this pull request as ready for review May 31, 2026 12:03
@anengineer1

anengineer1 commented May 31, 2026

Copy link
Copy Markdown
Author

I did quite a bit of testing, I hope I haven't forget a thing.

I think it is now ready for review.

@anengineer1
anengineer1 force-pushed the feature/custom_curve branch from ccd51f9 to 1e8ef3b Compare May 31, 2026 16:40
@AndyFilter

Copy link
Copy Markdown
Owner

Hey, I did not forget. I'll take a look at the changes next month. Thanks for your work!

Comment thread gui/main.cpp Outdated

ImPlot::GetPlotDrawList()->AddLine(p1, pc1, ImColor(0.7, 0.1f, 0.8, 0.8));
ImPlot::GetPlotDrawList()->AddLine(p2, pc2, ImColor(0.7, 0.1f, 0.8, 0.8));
// we will only

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I was about to comment about something and I forgot, I should remove that or take a third look, yes 😅

@anengineer1 anengineer1 Jul 14, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did push with I think is a better comment 😅 , sorry for that

Comment thread gui/CustomCurve.cpp
Comment on lines +271 to +284
if ((idx % 8 == 0) || (idx % 8 == 2) || (idx % 8 == 5))
p_x = p;
else {
else if ((idx % 8 == 1) || (idx % 8 == 3) || (idx % 8 == 6)) {
p_y = p;
if (idx % 6 == 1) {
if (idx % 8 == 1) {
points.emplace_back(p_x, p_y);
}
else {
if (idx % 6 == 3)
control_points.emplace_back();
auto j = idx % 6 - 2;
control_points.back()[j / 2] = {p_x, p_y};
}
else if ((idx % 8 == 4) || (idx % 8 == 7)) {
if (idx % 8 == 4) {
control_points.emplace_back();
}
auto j = (idx % 8) % 2;
control_points.back()[j] = {p_x, p_y, (bool)p};

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some sort of safety mechanism for scenarios where the user loads a config with the old formatting? We could have some kind of fallback that parses the old format as well. Or at least exits cleanly without loading any data that might otherwise be invalid. Technically backwards compatibility doesn't have to be maintained, as there are no releases yet.

@anengineer1 anengineer1 Jul 14, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the data is invalid, it just cleans the points and you end up with the default curve, take a look at:

    catch (std::exception& exception) {
        points.clear();
        control_points.clear();
        return false;
    }

    // 1 element is not enough for a linear interpolation, and n = 3(i - 2) + 4 (where i is the number of nodes), idx 2x because of x/y coordinate
    if (idx <= 2 || idx % 8 - 2 != 0) {
        points.clear();
        control_points.clear();
        return false;
    }

I also thought about that and because and after thinking, any solution felt like a way to make the code less elegant so I ended up preferring for the curve to go default if the collection doesn't make sense

@AndyFilter

Copy link
Copy Markdown
Owner

Hey, I didn't have time to run the code yet, but I just looked through it and left some comments.

About this:

Btw, why this limit? #define CURVE_POINTS_MARGIN 0.2f why 0.2?

It's a safety guard, meant to ensure the Bezier splines create a function in a mathematical sense $(x\mapsto f(x))$. So, simply there are no two values for a given x. Why 0.2? I just checked a bunch of values, and this one seemed the most reasonable. But if you think it should be decreased or increased, feel free to state your agrument.

@anengineer1

Copy link
Copy Markdown
Author

I just checked a bunch of values, and this one seemed the most reasonable. But if you think it should be decreased or increased, feel free to state your argument.

I did some testing and control points seem to behave as it should with limits such a 0.001, I did some digging regarding the windows software known as "Custom Curve" and you seem to be able to set 0 there. In my opinion, 0.001 is good enough and a more appropriate value than 0.2 as 0.2 is not precise enough for a preset like "Precision".

- Update `BezierCalc` and derivative helpers to switch between cubic,
  quadratic, and linear modes based on active control points.
- Add UI checkboxes in the curve editor to enable/disable control points.
- Update serialization (Export/Import) as now new.
  information is needed to keep track of the enabled/disabled control points
- Corrected p_min and p_max.
- Add the ability to align control points with points when using
  linear segments.
@anengineer1
anengineer1 force-pushed the feature/custom_curve branch from 1e8ef3b to 1ef7ee0 Compare July 14, 2026 18:35
@AndyFilter

Copy link
Copy Markdown
Owner

I did some testing and control points seem to behave as it should with limits such a 0.001 (...)

Alright, sounds good!
Yea, 0 should work, but you know... IEEE 754, discrete number representation, and all that stuff... And we're potentially dealing with something that can end up being used in the kernel space, so I'd rather not take that risk.

I'll try to run the code this week, and if everything goes well, I'll merge the change!

@AndyFilter

Copy link
Copy Markdown
Owner

I've tested the code, and it all works as expected. Although the Custom Curve GUI is getting more and more complex, right now, even I can barely tell what's where. So I'm gonna have to come up with some way to tidy it up. But that's beyond the scope of this PR, and I'm probably going to take care of the absolute mess in the code and the UI all at once, some time in the future.

Thanks for the input!

@AndyFilter
AndyFilter merged commit 0c8ff89 into AndyFilter:master Jul 19, 2026
1 check passed
@anengineer1

Copy link
Copy Markdown
Author

Thanks for the input!

I should be the one thanking you, I'm very grateful that this project exists and that I'm able to contribute to it!

It is being a pleasure to work with you and I hope to keep contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants