ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.57k stars 596 forks source link

Mouse sensitivity #3334

Open Steven20102 opened 1 year ago

Steven20102 commented 1 year ago

Can you guys tell us what you changed with the cs 1.6 mouse input?

I just downloaded the non steam cs 1.6 clean version and use -noforcemparms and -noforcemaccel and the sensitivity feels perfect like in kovaaks (even tho i get random acceleration)

@SamVanheer do you know what is going on? Steam Cs 1.6 version feels now excat like csgo with -useforcedmparms and m_mousespeed 0

SamVanheer commented 1 year ago

Steam HL uses SDL2 just like Source and Source 2, whatever old version you tried is pre-SDL so it uses raw mouse input instead.

You can see which changes were made to the SDK mouse input code here: https://github.com/twhl-community/HalfLifeSDKHistory/commit/5ceb227e702b3c952cdc8c774a4709bcbd794dbd#diff-3e6baa06b1c49058fe0fad67cdf04d879aa1a7ad06836196bee2d8cdd3e27480

You can see which options were added to control mouse input, see if any of them help.

Steven20102 commented 1 year ago

@SamVanheer do you know what they hardcoded for the threshold1 and threshold2?

nvm found it: _static int restorespi; static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1};

So there is the hardcoded mousespeed 1 and the thresholds are coded to 0.

Ok found it! Since you saying they use now source input their fix with noforcemaccel and noforcemspd doesnt work anymore. They changed noforcemaccel to the thresholds1 0 and threshold2 0 + mousespeed 1.

Their old fix set Threshold1 1 and Threshold2 0 and mousespeed 2 as seen here:

if ( gEngfuncs.CheckParm ("-noforcemparms", NULL ) ) { newmouseparms[0] = originalmouseparms[0]; newmouseparms[1] = originalmouseparms[1]; newmouseparms[2] = originalmouseparms[2];

SamVanheer commented 1 year ago

No, both the old and new code uses 0 for both thresholds. That's been the case since Quake 1: https://github.com/id-Software/Quake/blob/bf4ac424ce754894ac8f1dae6a3981954bc9852d/WinQuake/in_win.c#L43

CS 1.6 has the same values.

SDL2 queries Windows the same way to adjust mouse speed: https://github.com/libsdl-org/SDL/blob/c5c94a6be6bfaccec9c41f6326bd4be6b2db8aea/src/video/windows/SDL_windowsmouse.c#L470-L483

It's possible that SDL2 is affecting mouse sensitivity because of this code.

Try disabling mouse acceleration: https://www.makeuseof.com/windows-10-disable-mouse-acceleration/#how-to-disable-mouse-acceleration-feature-in-windows-10-and-11

See if that solves your problem.

Steven20102 commented 1 year ago

yes, exact on default they set: static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; Which means thresholds are set both to 0 and mousespeed 1.

As far as i know their old mouse fix was:

-noforcemspd (set the mousespeed to what is used in windows) -noforcemaccel (set the thresholds to what is used in windows) <-- This i honestly dont know why cause the thresholds arent in use in newer windows. So if enhanced pointer precision is off and noforcemaccel is in use the thresholds are 0 and 0 same as the coded value in the engine 0 and 0. I dont know if the game is still affected by those cause its coded in the engine.

I wonder what they changed that there is acceleration applied right now if you switch to m_rawinput 0 and dont use lauch options. Before you could see that the enhanced pointer precision get ticked on if you tab out and check the windows settings (I also checked the mouse regedit and mousespeed is 0). Now you get acceleration and the checkbox is not ticked on? Where the accel is coming from?

https://github.com/libsdl-org/SDL/blob/c5c94a6be6bfaccec9c41f6326bd4be6b2db8aea/src/video/windows/SDL_windowsmouse.c#L470-L483

Here they talk about the cursor speed. At 10 (1.0f) the mouse dpi you used is unadulterated.

static float mouse_speed_scale[] = { 0.0f, 1 / 32.0f, 1 / 16.0f, 1 / 8.0f, 2 / 8.0f, 3 / 8.0f, 4 / 8.0f, 5 / 8.0f, 6 / 8.0f, 7 / 8.0f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 2.25f, 2.5f, 2.75f, 3.0f, 3.25f, 3.5f

_void WIN_UpdateMouseSystemScale() { int mouse_speed; int params[3] = { 0, 0, 0 }; <-- This is how the code should be!

Can you help me up with this code:

if (SystemParametersInfo(SPI_GETMOUSESPEED, 0, &mouse_speed, 0) &&
    SystemParametersInfo(SPI_GETMOUSE, 0, params, 0)) {
    if (params[2]) {
        WIN_SetEnhancedMouseScale(mouse_speed);
    } else {
        WIN_SetLinearMouseScale(mouse_speed);_

If I understand it right the mousespeed 1 set in cs 1.6 is reffering to the mouse_speed_scale and not the enhanced precision speed?

rikkitikkitavix commented 1 year ago

my english is bad can you try -noforcemaccel -noforcemparms -noforcemspd -noforcemparms -noforcemaccel -noforcemspd -noforcemspd -noforcemaccel -noforcemparms different method works differently

SamVanheer commented 1 year ago

You can't change SDL2's code. Valve ships a custom build and it hasn't been updated since its introduction.

It seems that SDL2 initializes its mouse acceleration settings before the client has a chance to change the mouse settings, so the settings used by the OS are used there.

Raw mouse input is supposed to bypass SDL2 and use the values from the OS directly, so that should avoid the issue.

Passing the command line arguments in a different order won't change anything.

Steven20102 commented 1 year ago

Agree, the different order doesnt change anything. noforcemparms is the same as noforcemspd + noforcemaccel.

It seems that SDL2 initializes its mouse acceleration settings before the client has a chance to change the mouse settings, so the settings used by the OS are used there.

Na it seems like they control the windows settings and set windows accel to on. Even when the checkbox in windows is not ticked. Or do you mean the have an inbuilt accel system which is the same as windows?

Raw mouse input is supposed to bypass SDL2 and use the values from the OS directly, so that should avoid the issue.

As far as i know raw mouse input is supposed to bypass the windows settings. So the hardcoded values in the engine could still have an effect.

Since CSS and Csgo is customer friendly with their ingame commands m_mousespeed and m_mouseaccel1/2 which are changeable i will test there.

rikkitikkitavix commented 1 year ago

in cs1.6 it has different

Steven20102 commented 1 year ago

No see here the mouse code:

_if (mouseparmsvalid) { if ( gEngfuncs.CheckParm ("-noforcemspd", NULL ) ) newmouseparms[2] = originalmouseparms[2];

    if ( gEngfuncs.CheckParm ("-noforcemaccel", NULL ) ) 
    {
        newmouseparms[0] = originalmouseparms[0];
        newmouseparms[1] = originalmouseparms[1];
    }

    if ( gEngfuncs.CheckParm ("-noforcemparms", NULL ) ) 
    {
        newmouseparms[0] = originalmouseparms[0];
        newmouseparms[1] = originalmouseparms[1];
        newmouseparms[2] = originalmouseparms[2];_

You can see noforcemparms is the same as noforcemspd and noforcemaccel

SamVanheer commented 1 year ago

Na it seems like they control the windows settings and set windows accel to on. Even when the checkbox in windows is not ticked. Or do you mean the have an inbuilt accel system which is the same as windows?

SDL2 queries Windows for the mouse settings before the client has changed those settings, so SDL2 is going off of the OS settings, not the ones set by the client. It then uses those settings to apply adjustments to mouse input so when the game queries SDL2 for the mouse position it will be affected by the OS settings.

As far as i know raw mouse input is supposed to bypass the windows settings. So the hardcoded values in the engine could still have an effect.

Yeah i got it backwards. Raw input uses SDL2, so turning raw input off should use the OS mouse position.

Source has completely different input code: https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/game/client/in_mouse.cpp

So i wouldn't count on Source for improvements here.

Steven20102 commented 1 year ago

damn its so annoying dealing with different mouse feeling even if they have (near) the same engine. Iam not sure how to make the mouse the same in cs 1.6 non steam and steam version. Also I cant find a way (for now) to make source games like 1.6 non steam.

But i also think the problem is that windows is still influencing the mouse input.

rikkitikkitavix commented 1 year ago

just try these variations on practice

Steven20102 commented 1 year ago

I found this: http://web.archive.org/web/20090923154337/http://www.gotfrag.com/cs/forums/thread/411262

39 Even though you may have received that from technical support at steampowered.com I believe it is incorrect, because the code from the half-life sdk disagrees with it. The only part they have correct is -noforcemaccel, but they fail to mention that it only applies if you have acceleration turned on. In other words, this setting only makes Half-Life use the acceleration thresholds you have set in Windows, but if you have acceleration turned off, this is ignored.

40's code snippet is the same one that I examined, from the half-life sdk, that my original thread is based upon. It's the code that initializes and activates the mouse.

41 You are seeing the technical proof of my original post in #40's code snippet. Frankly I think you may be wrong here, because from a development standpoint, there's little reason to create a command that slows the y-axis of a mouse. And as the code shows, -noforcemspd just doesn't do what you say it does.

One possible reason I can think of for the difference in feeling that you are experiencing (and this is a long shot) is that the mouse initialization code might be called more frequently than I expect. If it is called frequently, then having more -noforce commands specified makes that sub-routine longer (though marginally).

In other words, if you have just -noforcemparms specified, you only execute through the bottom part of #40's code snippet, whereas if you have all three, you execute through the whole function. It's redundant though, essentially the function you're executing becomes twice as long. Though we're talking milliseconds here, so again, it's probably negligible.

So maybe you are right. I dont know gldscr and source engine is really weird. Actually ppl in 2009 discussed this problems.

Steven20102 commented 1 year ago
void WIN_UpdateMouseSystemScale()
{
    int mouse_speed;
    int params[3] = { 0, 0, 0 };

    if (SystemParametersInfo(SPI_GETMOUSESPEED, 0, &mouse_speed, 0) &&
        SystemParametersInfo(SPI_GETMOUSE, 0, params, 0)) {
        if (params[2]) {
            WIN_SetEnhancedMouseScale(mouse_speed);
        } else {
            WIN_SetLinearMouseScale(mouse_speed);
        }
    }
}

So we know cs (all cs even source) use params[3] = { 0, 0, 1 }

We know the first two 0 reffering to mouse threshold and the last to the mouse speed. The Code turns mouse speed always on by default. Only noforcemspd which is reffering to "params[2]" change that. With noforcemspd you tell the engine that windows set the last parameter. So if you use 0 in windows its now: params[3] = { 0, 0, 0 }

Short: Set in all goldscr or source games noforcemspd in the launch options. Yes even in source it works without the need of useforcedmparms.

Or but this is only for source games: set useforcedmparms in launch options and ingame set m_mousespeed to 0 to get params[3] = { 0, 0, 0 }.

rikkitikkitavix commented 1 year ago

can you check if old cs 1.6 using cl_mousegrab 1 or similar thing

Steven20102 commented 1 year ago

After 1 month testing i have to say you right. They feel different and also the order of the launch options affects it.

I guess right is just -noforcemparms or -noforcemaccel -noforcemspd

both of this will give params[3] = { 0, 0, 0 } and in the right order.

rikkitikkitavix commented 11 months ago

what i should use m_customaccel_exponent 1 or 0 and why?

rikkitikkitavix commented 11 months ago

in cs many values that should not affect mouse sensitivity affect this as well as integer values and dotted values work differently. I don't know how. for example sensitvity 3 and 3.0 or 3.000000 are felt differently zoom_sensitivity_ratio 1 and 1.0 try lookspring 0.000000 and 0 lookstrafe 0.000000 and 0

rikkitikkitavix commented 11 months ago

after changing the value, it is better to restart the game