Skip to content
Merged
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
7 changes: 7 additions & 0 deletions src/game/client/mp3player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,13 @@ ConCommand neo_mp3("neo_mp3", &neo_mp3_callback, "Toggle the mp3 player", FCVAR_

void CMP3Player::OnKeyCodePressed(vgui::KeyCode code)
{
// This can happen if the user presses a key which has no corresponding mapping,
// for example multimedia keys like "Volume Up" will trigger this.
if (code == BUTTON_CODE_NONE || code == BUTTON_CODE_INVALID)
{
return;
}

const auto toggleMP3Bind = gameuifuncs->GetButtonCodeForBind("neo_mp3");
if (toggleMP3Bind != code || !g_pPlayer)
{
Expand Down
20 changes: 14 additions & 6 deletions src/game/client/neo/ui/neo_root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,15 +483,23 @@ void CNeoRoot::FireGameEvent(IGameEvent *event)

void CNeoRoot::OnRelayedKeyCodeTyped(vgui::KeyCode code)
{
if (m_ns.keys.bcConsole <= KEY_NONE)
// This can happen eg. when the client uses multimedia keys to adjust OS volume.
// If we don't return here, then any un-bound UI element which also has the bind "none"
// would incorrectly trigger for this unrelated input.
if (code <= KEY_NONE)
{
m_ns.keys.bcConsole = gameuifuncs->GetButtonCodeForBind("neo_toggleconsole");
m_ns.keys.bcMP3Player = gameuifuncs->GetButtonCodeForBind("neo_mp3");
m_ns.keys.bcTeamMenu = gameuifuncs->GetButtonCodeForBind("teammenu");
m_ns.keys.bcClassMenu = gameuifuncs->GetButtonCodeForBind("classmenu");
m_ns.keys.bcLoadoutMenu = gameuifuncs->GetButtonCodeForBind("loadoutmenu");
return;
}

// Refresh every time, because else if the user unbinds or rebinds the key, it will still incorrectly be mapped there.
// NEO FIXME (Rain): We do not currently support binding multiple buttons for the same command;
// if the user does: bind a foo; bind b foo; then only the latest bind will work.
m_ns.keys.bcConsole = gameuifuncs->GetButtonCodeForBind("neo_toggleconsole");
m_ns.keys.bcMP3Player = gameuifuncs->GetButtonCodeForBind("neo_mp3");
m_ns.keys.bcTeamMenu = gameuifuncs->GetButtonCodeForBind("teammenu");
m_ns.keys.bcClassMenu = gameuifuncs->GetButtonCodeForBind("classmenu");
m_ns.keys.bcLoadoutMenu = gameuifuncs->GetButtonCodeForBind("loadoutmenu");

if (code == m_ns.keys.bcConsole && code != KEY_BACKQUOTE)
{
// NEO JANK (nullsystem): Prevent toggle being handled twice causing it to not really open.
Expand Down