1
0
mirror of https://gitea.tendokyu.moe/Hay1tsme/segatools.git synced 2024-11-25 01:40:11 +01:00

divaio: Add config

This commit is contained in:
Karl 2020-06-06 15:08:46 -04:00 committed by Tau
parent 7949f54b30
commit 164c74f160
3 changed files with 69 additions and 0 deletions

51
divaio/config.c Normal file
View File

@ -0,0 +1,51 @@
#include <windows.h>
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include "divaio/config.h"
static const int diva_io_default_buttons[] = {
VK_RIGHT, VK_DOWN, VK_LEFT, VK_UP, VK_SPACE
};
static const int diva_io_default_slider[] = {
'Q', 'W', 'E', 'R', 'U', 'I', 'O', 'P'
};
void diva_io_config_load(
struct diva_io_config *cfg,
const wchar_t *filename)
{
wchar_t key[5];
wchar_t cell[8];
int i;
int c;
assert(cfg != NULL);
assert(filename != NULL);
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);
for (i = 0 ; i < _countof(cfg->vk_buttons) ; i++) {
swprintf_s(key, _countof(key), L"key%i", i + 1);
cfg->vk_buttons[i] = GetPrivateProfileIntW(
L"buttons",
key,
diva_io_default_buttons[i],
filename);
}
for (c = 0 ; c < _countof(cfg->vk_slider) ; c++) {
swprintf_s(cell, _countof(cell), L"cell%i", c + 1);
cfg->vk_slider[c] = GetPrivateProfileIntW(
L"slider",
cell,
diva_io_default_slider[c],
filename);
}
}

16
divaio/config.h Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
struct diva_io_config {
uint8_t vk_buttons[5];
uint8_t vk_slider[8];
uint8_t vk_test;
uint8_t vk_service;
uint8_t vk_coin;
};
void diva_io_config_load(
struct diva_io_config *cfg,
const wchar_t *filename);

View File

@ -8,5 +8,7 @@ divaio_dll = shared_library(
sources : [
'divaio.c',
'divaio.h',
'config.c',
'config.h',
],
)