MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / ParseAutoKeys

Function ParseAutoKeys

apps/cwr/Game/GameApplication.cpp:485–516  ·  view source on GitHub ↗

Parse --auto-keys ("trigger:scancode[:modflags],..."). Missing-colon tokens skipped.

Source from the content-addressed store, hash-verified

483
484// Parse --auto-keys ("trigger:scancode[:modflags],..."). Missing-colon tokens skipped.
485static std::vector<AutoKeyEvent> ParseAutoKeys(const std::string& spec)
486{
487 std::vector<AutoKeyEvent> out;
488 if (spec.empty())
489 return out;
490 std::istringstream ss(spec);
491 std::string token;
492 while (std::getline(ss, token, ','))
493 {
494 auto colon1 = token.find(':');
495 if (colon1 == std::string::npos)
496 continue;
497 TimedTrigger trig = ParseTriggerTime(token, colon1);
498 std::string rest = token.substr(colon1 + 1);
499 auto colon2 = rest.find(':');
500 int sc;
501 SDL_Keymod mod = SDL_KMOD_NONE;
502 if (colon2 != std::string::npos)
503 {
504 sc = std::stoi(rest.substr(0, colon2));
505 mod = (SDL_Keymod)std::stoi(rest.substr(colon2 + 1));
506 }
507 else
508 {
509 sc = std::stoi(rest);
510 }
511 out.push_back({trig, (SDL_Scancode)sc, mod});
512 }
513 if (!out.empty())
514 LOG_INFO(Core, "Auto-keys: {} events scheduled", out.size());
515 return out;
516}
517
518// Parse --auto-screenshot ("trigger:path,...").
519static std::vector<AutoScreenshotSpec> ParseAutoScreenshots(const std::string& spec)

Callers 1

RunMainLoopMethod · 0.85

Calls 3

ParseTriggerTimeFunction · 0.85
sizeMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected