ValveSoftware / gamescope

SteamOS session compositing window manager
Other
3.02k stars 198 forks source link

Add support for passing decimal refresh rates to gamescope thru the command line #1455

Open sharkautarch opened 1 month ago

sharkautarch commented 1 month ago

To avoid any floating-point weirdness, I decided to make the code get the whole part and the decimal part of the string arg, convert it to 64 bit unsigned ints, (and also get the length of the decimal part) and do the mathy stuff to calculate the converted-to-mHz value from those integers.

Little bonus is that the code accepts using either a (,) comma or (.) period as the decimal separator, lol :P

I did a little bit of testing to make sure int32_t ConvertHztomHz( const char* refreshHz ) was handling both decimal number-strings and whole-number-strings correctly, and everything just works!

sharkautarch commented 1 month ago

I recently edited this PR to use Split() from convar.h instead of the c-style strcspn I was using before. I also made sure it was still working correctly after the edits.