2019-11-17 18:11:49 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
2023-07-13 22:58:02 +00:00
|
|
|
#include <string.h>
|
2019-11-17 18:11:49 +00:00
|
|
|
|
|
|
|
#include "chuniio/config.h"
|
|
|
|
|
|
|
|
static const int chuni_io_default_cells[] = {
|
|
|
|
'L', 'L', 'L', 'L',
|
|
|
|
'K', 'K', 'K', 'K',
|
|
|
|
'J', 'J', 'J', 'J',
|
|
|
|
'H', 'H', 'H', 'H',
|
|
|
|
'G', 'G', 'G', 'G',
|
|
|
|
'F', 'F', 'F', 'F',
|
|
|
|
'D', 'D', 'D', 'D',
|
|
|
|
'S', 'S', 'S', 'S',
|
|
|
|
};
|
|
|
|
|
2023-07-13 22:58:02 +00:00
|
|
|
static const int chuni_io_default_ir[] = {
|
|
|
|
'4', '5', '6', '7', '8', '9'
|
|
|
|
};
|
|
|
|
|
2019-11-17 18:11:49 +00:00
|
|
|
void chuni_io_config_load(
|
|
|
|
struct chuni_io_config *cfg,
|
|
|
|
const wchar_t *filename)
|
|
|
|
{
|
|
|
|
wchar_t key[16];
|
|
|
|
int i;
|
2023-07-13 22:58:02 +00:00
|
|
|
wchar_t port_input[6];
|
2019-11-17 18:11:49 +00:00
|
|
|
|
|
|
|
assert(cfg != NULL);
|
|
|
|
assert(filename != NULL);
|
|
|
|
|
2023-07-13 22:58:02 +00:00
|
|
|
// Technically it's io4 but leave this for compatibility with old configs.
|
2019-11-17 18:11:49 +00:00
|
|
|
cfg->vk_test = GetPrivateProfileIntW(L"io3", L"test", '1', filename);
|
|
|
|
cfg->vk_service = GetPrivateProfileIntW(L"io3", L"service", '2', filename);
|
|
|
|
cfg->vk_coin = GetPrivateProfileIntW(L"io3", L"coin", '3', filename);
|
2023-07-13 22:58:02 +00:00
|
|
|
cfg->vk_ir_emu = GetPrivateProfileIntW(L"io3", L"ir", VK_SPACE, filename);
|
|
|
|
|
|
|
|
for (i = 0 ; i < 6 ; i++) {
|
|
|
|
swprintf_s(key, _countof(key), L"ir%i", i + 1);
|
|
|
|
cfg->vk_ir[i] = GetPrivateProfileIntW(
|
|
|
|
L"ir",
|
|
|
|
key,
|
|
|
|
chuni_io_default_ir[i],
|
|
|
|
filename);
|
|
|
|
}
|
2019-11-17 18:11:49 +00:00
|
|
|
|
|
|
|
for (i = 0 ; i < 32 ; i++) {
|
|
|
|
swprintf_s(key, _countof(key), L"cell%i", i + 1);
|
|
|
|
cfg->vk_cell[i] = GetPrivateProfileIntW(
|
|
|
|
L"slider",
|
|
|
|
key,
|
|
|
|
chuni_io_default_cells[i],
|
|
|
|
filename);
|
|
|
|
}
|
2023-07-13 22:58:02 +00:00
|
|
|
|
|
|
|
GetPrivateProfileStringW(L"slider", L"ledport", L"COM2", port_input, 6, filename);
|
|
|
|
wcsncpy(cfg->led_com, L"\\\\.\\", 4);
|
|
|
|
wcsncat_s(cfg->led_com, 11, port_input, 6);
|
2019-11-17 18:11:49 +00:00
|
|
|
}
|