Skip to content

Commit

Permalink
Merge pull request #243 from tmp64/feature/input-fixes
Browse files Browse the repository at this point in the history
Input updates
  • Loading branch information
tmp64 authored Aug 24, 2024
2 parents ba8dc22 + 29506c1 commit 903535f
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 83 deletions.
Binary file modified gamedir/ui/resource/language/bugfixedhl_english.txt
Binary file not shown.
Binary file modified gamedir/ui/resource/language/bugfixedhl_russian.txt
Binary file not shown.
11 changes: 5 additions & 6 deletions src/game/client/gameui/options/options_general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "hud.h"
#include "cl_util.h"
#include "engine_patches.h"
#include "sdl_rt.h"

extern ConVar m_input;

Expand All @@ -27,7 +28,7 @@ CGeneralSubOptions::CGeneralSubOptions(vgui2::Panel *parent)

m_pRawInputLabel = new vgui2::Label(this, "RawInputLabel", "#BHL_AdvOptions_General_Input");
m_pInputMethodBox = new vgui2::ComboBox(this, "InputMethodBox", 3, false);
m_InputMethodItems[0] = m_pInputMethodBox->AddItem("#BHL_AdvOptions_General_InputEng", new KeyValues("Item", "value", 0));
m_InputMethodItems[0] = m_pInputMethodBox->AddItem("#BHL_AdvOptions_General_InputWin", new KeyValues("Item", "value", 0));
m_InputMethodItems[1] = m_pInputMethodBox->AddItem(GetItemText("BHL_AdvOptions_General_InputDX", IsWindows()), new KeyValues("Item", "value", 1));
m_InputMethodItems[2] = m_pInputMethodBox->AddItem(GetItemText("BHL_AdvOptions_General_InputSDL", !IsWindows()), new KeyValues("Item", "value", 2));

Expand All @@ -51,11 +52,9 @@ CGeneralSubOptions::CGeneralSubOptions(vgui2::Panel *parent)
LoadControlSettings(VGUI2_ROOT_DIR "resource/options/GeneralSubOptions.res");

// Disable unsupported input methods
if (!IsWindows())
m_pInputMethodBox->SetItemEnabled(m_InputMethodItems[1], false);

if (!CEnginePatches::Get().IsSDLEngine())
m_pInputMethodBox->SetItemEnabled(m_InputMethodItems[2], false);
m_pInputMethodBox->SetItemEnabled(m_InputMethodItems[0], IsWindows()); // WindowsCursor
m_pInputMethodBox->SetItemEnabled(m_InputMethodItems[1], IsWindows()); // DirectInput
m_pInputMethodBox->SetItemEnabled(m_InputMethodItems[2], GetSDL()->IsGood()); // RawInput

// Disable HTML MOTD if SteamAPI not available
if (!SteamAPI_IsAvailable())
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/hud_msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ void ClearEventList(void);
#endif

extern ConVar zoom_sensitivity_ratio;
extern cvar_t *sensitivity;
extern float g_lastFOV;

cvar_t *cl_lw = nullptr;

void CAM_ToFirstPerson(void);
float IN_GetMouseSensitivity();

/// USER-DEFINED SERVER MESSAGE HANDLERS

Expand Down Expand Up @@ -177,7 +177,7 @@ int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf)
else
{
// set a new sensitivity that is proportional to the change from the FOV default
m_flMouseSensitivity = sensitivity->value * ((float)newfov / (float)def_fov) * zoom_sensitivity_ratio.GetFloat();
m_flMouseSensitivity = IN_GetMouseSensitivity() * ((float)newfov / (float)def_fov) * zoom_sensitivity_ratio.GetFloat();
}

// Update crosshair after zoom change
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/hud_redraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ int grgLogoFrame[MAX_LOGO_FRAMES] = {
};

float HUD_GetFOV(void);
float IN_GetMouseSensitivity();

extern cvar_t *sensitivity;
extern ConVar zoom_sensitivity_ratio;

ConVar hud_colortext("hud_colortext", "1", FCVAR_BHL_ARCHIVE);
Expand Down Expand Up @@ -82,7 +82,7 @@ void CHud::Think(void)
else
{
// set a new sensitivity that is proportional to the change from the FOV default
m_flMouseSensitivity = sensitivity->value * ((float)newfov / (float)default_fov.GetInt()) * zoom_sensitivity_ratio.GetFloat();
m_flMouseSensitivity = IN_GetMouseSensitivity() * ((float)newfov / (float)default_fov.GetInt()) * zoom_sensitivity_ratio.GetFloat();
}

// think about default fov
Expand Down
Loading

0 comments on commit 903535f

Please sign in to comment.