Added workaround to enforce max fps limit. #14

Open
anomaly wants to merge 12 commits from anomaly/iw6-mod:enforce_fps_limit_workaround into master
2 changed files with 44 additions and 0 deletions
Showing only changes of commit 1db89c64c6 - Show all commits

View File

@ -0,0 +1,35 @@
#include "command_line.hpp"
#include "nt.hpp"
#include <shellapi.h>
#include <winrt/Windows.Foundation.h>
namespace utils::command_line
{
template <typename type, typename deleter>
constexpr std::unique_ptr<type, deleter> make_unique_ptr(type* ptr, deleter&& del)
{
return std::unique_ptr<type, deleter&&>(ptr, std::forward<deleter>(del));
}
const std::vector<std::filesystem::path>& get_args()
{
static const auto args = []()
{
auto argc = 0;
const auto cmd_line = winrt::check_pointer(::GetCommandLineW());
const auto up = make_unique_ptr(winrt::check_pointer(::CommandLineToArgvW(cmd_line, &argc)), ::LocalFree);
const auto argv = up.get();
std::vector<std::filesystem::path> vec(argc);
std::transform(argv, argv + argc, vec.begin(), [](const auto* path)
{
return std::filesystem::path(path);
});
return vec;
}();
return args;
}
}

View File

@ -0,0 +1,9 @@
#pragma once
#include <filesystem>
#include <vector>
namespace utils::command_line
{
[[nodiscard]] const std::vector<std::filesystem::path>& get_args();
}