|
5 | 5 | #include <string.h> |
6 | 6 | #include <map> |
7 | 7 | struct Config { |
8 | | - std::string configPath = "config.ini"; |
9 | | - std::string keymapPath = "keymap.cfg"; |
| 8 | + std::string configPath; |
| 9 | + std::string keymapPath; |
10 | 10 | int altcmkp = 0; |
11 | | - char keymap[256]; |
| 11 | + bool hwsc = false; |
| 12 | + char keymap[256]; // idx is midi key code (0-127, typically), value is vk code (1-254) |
12 | 13 |
|
13 | | - Config() { |
14 | | - for (size_t i = 0; i < 255; i++) { |
15 | | - keymap[i] = 0; // idx is midi key code (0-127, typically), value is vk code (1-254) |
16 | | - } |
| 14 | + void use(std::string configPath, std::string keymapPath) { |
| 15 | + this->configPath = configPath; |
| 16 | + this->keymapPath = keymapPath; |
17 | 17 | } |
18 | 18 |
|
19 | 19 | void save() { |
20 | 20 | ini::IniFile storage; |
21 | 21 | storage["Compatibility"]["altcmkp"] = altcmkp; |
| 22 | + storage["Compatibility"]["hwsc"] = hwsc; |
22 | 23 | storage.save(configPath); |
23 | 24 |
|
24 | 25 | std::ofstream out; |
25 | 26 | out.open(keymapPath); |
26 | 27 | if (out) out.write(keymap, 256); |
27 | 28 | out.close(); |
28 | | - return; |
29 | 29 | } |
30 | 30 |
|
31 | 31 | void load() { |
32 | 32 | ini::IniFile storage; |
33 | 33 | storage.load(configPath); |
34 | 34 | if (storage["Compatibility"]["altcmkp"].as<std::string>() != "") altcmkp = storage["Compatibility"]["altcmkp"].as<int>(); |
| 35 | + if (storage["Compatibility"]["hwsc"].as<std::string>() != "") hwsc = storage["Compatibility"]["hwsc"].as<bool>(); |
35 | 36 |
|
| 37 | + for (size_t i = 0; i < 255; i++) { |
| 38 | + keymap[i] = 0; |
| 39 | + } |
36 | 40 | std::ifstream in; |
37 | 41 | in.open(keymapPath); |
38 | 42 | if (in) in.getline(keymap, 256); |
39 | 43 | in.close(); |
40 | | - return; |
41 | 44 | } |
42 | 45 |
|
43 | | - auto getEntries() { |
| 46 | + auto repr() { |
44 | 47 | std::map<std::string, std::string> entries = { |
45 | 48 | { "altcmkp", std::to_string(altcmkp) }, |
| 49 | + { "hwsc", std::to_string(hwsc) }, |
46 | 50 | }; |
47 | 51 | return entries; |
48 | 52 | } |
|
0 commit comments