tidy-fix automàtic (sense naming)

This commit is contained in:
2026-05-14 18:28:23 +02:00
parent 358e91ea30
commit b7a551c158
81 changed files with 1549 additions and 831 deletions
+33 -11
View File
@@ -16,7 +16,9 @@ namespace KeyConfig {
auto findIndex(const std::string& id) -> size_t {
auto it = index_.find(id);
if (it == index_.end()) return SIZE_MAX;
if (it == index_.end()) {
return SIZE_MAX;
}
return it->second;
}
@@ -30,7 +32,9 @@ namespace KeyConfig {
std::string content(buf.begin(), buf.end());
try {
auto yaml = fkyaml::node::deserialize(content);
if (!yaml.contains("keys")) return;
if (!yaml.contains("keys")) {
return;
}
for (const auto& node : yaml["keys"]) {
KeyEntry entry;
@@ -59,7 +63,9 @@ namespace KeyConfig {
void applyOverrides(const std::string& disk_path) {
std::ifstream file(disk_path);
if (!file.good()) return;
if (!file.good()) {
return;
}
std::string content((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
@@ -67,7 +73,9 @@ namespace KeyConfig {
try {
auto yaml = fkyaml::node::deserialize(content);
if (!yaml.contains("overrides")) return;
if (!yaml.contains("overrides")) {
return;
}
int applied = 0;
for (const auto& kv : yaml["overrides"].as_map()) {
@@ -118,28 +126,38 @@ namespace KeyConfig {
auto scancode(const std::string& id) -> SDL_Scancode {
auto idx = findIndex(id);
if (idx == SIZE_MAX) return SDL_SCANCODE_UNKNOWN;
if (idx == SIZE_MAX) {
return SDL_SCANCODE_UNKNOWN;
}
return entries_[idx].scancode;
}
auto scancodePtr(const std::string& id) -> SDL_Scancode* {
auto idx = findIndex(id);
if (idx == SIZE_MAX) return nullptr;
if (idx == SIZE_MAX) {
return nullptr;
}
return &entries_[idx].scancode;
}
void setScancode(const std::string& id, SDL_Scancode sc) {
auto idx = findIndex(id);
if (idx == SIZE_MAX) return;
if (idx == SIZE_MAX) {
return;
}
entries_[idx].scancode = sc;
const char* name = SDL_GetScancodeName(sc);
entries_[idx].code = (name != nullptr) ? name : "";
}
auto isGuiKey(SDL_Scancode sc) -> bool {
if (sc == SDL_SCANCODE_UNKNOWN) return false;
if (sc == SDL_SCANCODE_UNKNOWN) {
return false;
}
for (const auto& e : entries_) {
if (e.scancode == sc) return true;
if (e.scancode == sc) {
return true;
}
}
return false;
}
@@ -149,12 +167,16 @@ namespace KeyConfig {
}
auto saveOverrides() -> bool {
if (overrides_path_.empty()) return false;
if (overrides_path_.empty()) {
return false;
}
// Recull només les entrades remapeades.
std::vector<const KeyEntry*> changed;
for (const auto& e : entries_) {
if (e.scancode != e.default_scancode) changed.push_back(&e);
if (e.scancode != e.default_scancode) {
changed.push_back(&e);
}
}
std::ofstream file(overrides_path_);