Skip to content

Add numeric framerate limit input - #3632

Open
Riqqqque wants to merge 8 commits into
CaffeineMC:devfrom
Riqqqque:rique/custom-fps-cap
Open

Add numeric framerate limit input#3632
Riqqqque wants to merge 8 commits into
CaffeineMC:devfrom
Riqqqque:rique/custom-fps-cap

Conversation

@Riqqqque

@Riqqqque Riqqqque commented May 6, 2026

Copy link
Copy Markdown

Closes #3556.

Adds a numeric input for the framerate limit so exact caps can be entered instead of being limited to 10 FPS slider steps.

Changes:

  • uses a text box for Sodium's framerate limit option
  • replaces Minecraft's framerate limit option with an exact integer range before options are loaded
  • keeps the existing Sodium apply/save flow

The standalone addon this was ported from is Unlicense.

Validation:

  • ./gradlew.bat build
  • ./gradlew.bat :common:compileJava :fabric:compileJava :neoforge:compileJava --rerun-tasks

@douira douira left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you don't have a suggestion for changes to the API to accomodate a second type of integer option, I can also do that myself during merge.

@douira douira left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've pushed some changes to this branch to clean up some things, faster than going back and forth here.

  • However, I've noticed that once I enter a number into the text field, it doesn't let me change it.
  • Focusing it by keyboard navigation works, but it doesn't let me enter text
  • In the video the reset button shows up sometimes, but that's just because pressing shift + tab activates it because of the shift key
  • Clicking on the text field doesn't activate the cursor once it's been used
  • When the text field is activated and there's an outline around the option, the outlines touch which is not nice
  • The text in the textbox seems to be around 1-2 pixels too high and not vertically centered
output.mp4

@Riqqqque

Riqqqque commented May 8, 2026

Copy link
Copy Markdown
Author

Pushed a fix for the textbox focus/click handling and tightened the textbox height/vertical positioning.

Checked with:

  • ./gradlew.bat :common:compileJava :fabric:compileJava :neoforge:compileJava --rerun-tasks
  • ./gradlew.bat build

@Riqqqque

Riqqqque commented May 8, 2026

Copy link
Copy Markdown
Author

Added one more follow-up for the textbox behavior.

Tab focus now routes input to the actual text field, so typing/backspace should work instead of only showing the cursor. The click focus, focus-out commit, and spacing tweaks are still in place.

Checked with:

  • ./gradlew.bat :common:compileJava :fabric:compileJava :neoforge:compileJava --rerun-tasks
  • ./gradlew.bat build

@douira douira left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems to work now but I'm somewhat confused why we need dragging. This flag doesn't seem to be doing anything. Maybe it would be appropriate to instead implement AbstractParentWidget rather than reimplementing a bunch of its code?
Thanks for improving this patch thus far!

@Riqqqque

Riqqqque commented May 9, 2026

Copy link
Copy Markdown
Author

Cleaned up the textbox focus handling.

ControlElement now has the parent-widget focus support, and the textbox registers its EditBox as a child instead of carrying its own focused-child/dragging state. The textbox control only keeps the focus-out commit hook now.

Checked with:

  • ./gradlew.bat :common:compileJava :fabric:compileJava :neoforge:compileJava --rerun-tasks
  • ./gradlew.bat build

@CoolAtlantis

CoolAtlantis commented Jul 6, 2026

Copy link
Copy Markdown

Yea, we need this! I play with VRR and i would like to have my framerate capped exactly at 177fps. I currently use a mod which makes the slider go by steps of 1 instead of 10. But having an input box built in to sodium itself, sounds awesome.

@jellysquid3 jellysquid3 added the T-enhancement Type: Enhancement label Jul 12, 2026
@douira
douira force-pushed the rique/custom-fps-cap branch from 9af86f1 to c0a05a4 Compare July 27, 2026 13:41

@douira douira left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It appears that tab navigation between options is broken on this branch.

@Riqqqque

Copy link
Copy Markdown
Author

Fixed the tab navigation issue. Normal option controls were returning their own focus path even while already focused, so Tab kept selecting the same option. The fallback now only returns the control when it is not already focused; controls with children still use parent traversal.

Checked with:

  • ./gradlew.bat :common:compileJava :fabric:compileJava :neoforge:compileJava --rerun-tasks --console=plain
  • ./gradlew.bat build --console=plain

Commit: 1db98b99

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

Labels

T-enhancement Type: Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace the framerate slider with a numeric input for custom FPS caps

4 participants