Skip to content

Commit

Permalink
feat(gameinput): put txAdmin keys mappings at the top
Browse files Browse the repository at this point in the history
Actually, @tabarra added # in his key mappings to have the txAdmin key mappings at the top of the FiveM key settings. This PR aims to fix this so Tabarra doesn't have to do this workaround
  • Loading branch information
spacevx committed Oct 1, 2024
1 parent e31630e commit d7f4145
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions code/components/gta-core-five/src/GameInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,24 @@ static void GetMappingCategoryInputs(uint32_t* categoryId, atArray<uint32_t>& co
std::vector<std::pair<std::string, std::tuple<std::string, std::string>>> sortedBindings(g_registeredBindings.begin(), g_registeredBindings.end());
std::sort(sortedBindings.begin(), sortedBindings.end(), [](const auto& left, const auto& right)
{

const std::string& leftTag = std::get<0>(std::get<1>(left));
const std::string& rightTag = std::get<0>(std::get<1>(right));

// txAdmin key mappings needs to be at the top of the list.
bool leftIsTxAdmin = (leftTag == "monitor");
bool rightIsTxAdmin = (rightTag == "monitor");

if (leftIsTxAdmin && !rightIsTxAdmin)
{
return true;
}

if (!leftIsTxAdmin && rightIsTxAdmin)
{
return false;
}

// #TODO: Unicode-aware comparison
return std::get<1>(left.second) < std::get<1>(right.second);
});
Expand Down

0 comments on commit d7f4145

Please sign in to comment.