Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Shared] Add cl_mouseAspectScaling to correct UI mouse sensitivity for your resolution #1170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion code/client/cl_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,13 @@ CL_MouseEvent
*/
void CL_MouseEvent( int dx, int dy, int time ) {
if ( Key_GetCatcher( ) & KEYCATCH_UI ) {
_UI_MouseEvent( dx, dy );
float dxScaled = dx;
float dyScaled = dy;
if ( cl_mouseAspectScaling->integer ) {
dxScaled *= (SCREEN_WIDTH / (float)cls.glconfig.vidWidth);
dyScaled *= (SCREEN_HEIGHT / (float)cls.glconfig.vidHeight);
}
_UI_MouseEvent( dxScaled, dyScaled );
}
else {
cl.mouseDx[cl.mouseIndex] += dx;
Expand Down
2 changes: 2 additions & 0 deletions code/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ cvar_t *cl_freelook;
cvar_t *cl_sensitivity;

cvar_t *cl_mouseAccel;
cvar_t *cl_mouseAspectScaling;
cvar_t *cl_showMouseRate;
cvar_t *cl_framerate;

Expand Down Expand Up @@ -1258,6 +1259,7 @@ void CL_Init( void ) {
cl_run = Cvar_Get ("cl_run", "1", CVAR_ARCHIVE_ND);
cl_sensitivity = Cvar_Get ("sensitivity", "5", CVAR_ARCHIVE);
cl_mouseAccel = Cvar_Get ("cl_mouseAccel", "0", CVAR_ARCHIVE_ND);
cl_mouseAspectScaling = Cvar_Get ("cl_mouseAspectScaling", "0", CVAR_ARCHIVE_ND);
cl_freelook = Cvar_Get( "cl_freelook", "1", CVAR_ARCHIVE_ND );

cl_showMouseRate = Cvar_Get ("cl_showmouserate", "0", 0);
Expand Down
1 change: 1 addition & 0 deletions code/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ extern cvar_t *cl_sensitivity;
extern cvar_t *cl_freelook;

extern cvar_t *cl_mouseAccel;
extern cvar_t *cl_mouseAspectScaling;
extern cvar_t *cl_showMouseRate;

extern cvar_t *cl_allowAltEnter;
Expand Down
14 changes: 10 additions & 4 deletions codemp/client/cl_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,22 +922,28 @@ CL_MouseEvent
=================
*/
void CL_MouseEvent( int dx, int dy, int time ) {
float dxScaled = dx;
float dyScaled = dy;
if ( cl_mouseAspectScaling->integer ) {
dxScaled *= (SCREEN_WIDTH / (float)cls.glconfig.vidWidth);
dyScaled *= (SCREEN_HEIGHT / (float)cls.glconfig.vidHeight);
}
if (g_clAutoMapMode && cls.cgameStarted)
{ //automap input
autoMapInput_t *data = (autoMapInput_t *)cl.mSharedMemory;

g_clAutoMapInput.yaw = dx;
g_clAutoMapInput.pitch = dy;
g_clAutoMapInput.yaw = dxScaled;
g_clAutoMapInput.pitch = dyScaled;
memcpy(data, &g_clAutoMapInput, sizeof(autoMapInput_t));
CGVM_AutomapInput();

g_clAutoMapInput.yaw = 0.0f;
g_clAutoMapInput.pitch = 0.0f;
}
else if ( Key_GetCatcher( ) & KEYCATCH_UI ) {
UIVM_MouseEvent( dx, dy );
UIVM_MouseEvent( dxScaled, dyScaled );
} else if ( Key_GetCatcher( ) & KEYCATCH_CGAME ) {
CGVM_MouseEvent( dx, dy );
CGVM_MouseEvent( dxScaled, dyScaled );
} else {
cl.mouseDx[cl.mouseIndex] += dx;
cl.mouseDy[cl.mouseIndex] += dy;
Expand Down
3 changes: 3 additions & 0 deletions codemp/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ cvar_t *cl_sensitivity;
cvar_t *cl_mouseAccel;
cvar_t *cl_mouseAccelOffset;
cvar_t *cl_mouseAccelStyle;
cvar_t *cl_mouseAspectScaling;
cvar_t *cl_showMouseRate;

cvar_t *m_pitchVeh;
Expand Down Expand Up @@ -2730,6 +2731,8 @@ void CL_Init( void ) {
// this should be set to the max rate value
cl_mouseAccelOffset = Cvar_Get( "cl_mouseAccelOffset", "5", CVAR_ARCHIVE_ND, "Mouse acceleration offset for style 1" );

cl_mouseAspectScaling = Cvar_Get( "cl_mouseAspectScaling", "0", CVAR_ARCHIVE_ND, "Scale mouse movement correctly in menus based on your desktop aspect ratio" );

cl_showMouseRate = Cvar_Get ("cl_showmouserate", "0", 0);
cl_framerate = Cvar_Get ("cl_framerate", "0", CVAR_TEMP);
cl_allowDownload = Cvar_Get ("cl_allowDownload", "0", CVAR_ARCHIVE_ND, "Allow downloading custom paks from server");
Expand Down
1 change: 1 addition & 0 deletions codemp/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ extern cvar_t *cl_freelook;
extern cvar_t *cl_mouseAccel;
extern cvar_t *cl_mouseAccelOffset;
extern cvar_t *cl_mouseAccelStyle;
extern cvar_t *cl_mouseAspectScaling;
extern cvar_t *cl_showMouseRate;

extern cvar_t *m_pitchVeh;
Expand Down