Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
k5md committed Nov 8, 2024
2 parents 00ac8f0 + 752e567 commit 5620a17
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 175 deletions.
24 changes: 14 additions & 10 deletions src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,48 @@
#include <string.h>
#include <map>
struct Config {
std::string configPath = "config.ini";
std::string keymapPath = "keymap.cfg";
std::string configPath;
std::string keymapPath;
int altcmkp = 0;
char keymap[256];
bool hwsc = false;
char keymap[256]; // idx is midi key code (0-127, typically), value is vk code (1-254)

Config() {
for (size_t i = 0; i < 255; i++) {
keymap[i] = 0; // idx is midi key code (0-127, typically), value is vk code (1-254)
}
void use(std::string configPath, std::string keymapPath) {
this->configPath = configPath;
this->keymapPath = keymapPath;
}

void save() {
ini::IniFile storage;
storage["Compatibility"]["altcmkp"] = altcmkp;
storage["Compatibility"]["hwsc"] = hwsc;
storage.save(configPath);

std::ofstream out;
out.open(keymapPath);
if (out) out.write(keymap, 256);
out.close();
return;
}

void load() {
ini::IniFile storage;
storage.load(configPath);
if (storage["Compatibility"]["altcmkp"].as<std::string>() != "") altcmkp = storage["Compatibility"]["altcmkp"].as<int>();
if (storage["Compatibility"]["hwsc"].as<std::string>() != "") hwsc = storage["Compatibility"]["hwsc"].as<bool>();

for (size_t i = 0; i < 255; i++) {
keymap[i] = 0;
}
std::ifstream in;
in.open(keymapPath);
if (in) in.getline(keymap, 256);
in.close();
return;
}

auto getEntries() {
auto repr() {
std::map<std::string, std::string> entries = {
{ "altcmkp", std::to_string(altcmkp) },
{ "hwsc", std::to_string(hwsc) },
};
return entries;
}
Expand Down
Loading

0 comments on commit 5620a17

Please sign in to comment.