MCPcopy Create free account
hub / github.com/GameTechDev/PresentMon / ParseKeyName

Function ParseKeyName

PresentMon/CommandLine.cpp:145–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145bool ParseKeyName(KeyNameCode const* valid, size_t validCount, wchar_t* name, wchar_t const* errorMessage, UINT* outKeyCode)
146{
147 for (size_t i = 0; i < validCount; ++i) {
148 if (_wcsicmp(name, valid[i].mName) == 0) {
149 *outKeyCode = valid[i].mCode;
150 return true;
151 }
152 }
153
154 PrintError(L"error: %s: %s\n", errorMessage, name);
155
156 int width = (int) (0.8 * GetConsoleWidth());
157 int col = PrintError(L" valid options:");
158 for (size_t i = 0; i < validCount; ++i) {
159 col += PrintError(L" %s", valid[i].mName);
160 if (col > width) {
161 col = PrintError(L"\n ") - 1;
162 }
163 }
164 PrintError(L"\n");
165
166 return false;
167}
168
169bool AssignHotkey(wchar_t* key, CommandLineArgs* args)
170{

Callers 1

AssignHotkeyFunction · 0.85

Calls 2

PrintErrorFunction · 0.85
GetConsoleWidthFunction · 0.85

Tested by

no test coverage detected