1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2025-02-21 04:48:42 +01:00

asiohook: add config

This commit is contained in:
Will Xyen 2020-04-05 00:11:36 -07:00
parent d04598a570
commit 937290f93d
3 changed files with 75 additions and 0 deletions

View File

@ -7,3 +7,4 @@ libs_asiohook := \
src_asiohook := \
asio-reghook.c \
config-asio.c \

View File

@ -0,0 +1,56 @@
#include "cconfig/cconfig-util.h"
#include "asiohook/config-asio.h"
#include "util/log.h"
#define ASIOHOOK_CONFIG_IO_FORCE_ASIO_KEY "asio.force_asio"
#define ASIOHOOK_CONFIG_IO_ASIO_DEVICE_NAME_KEY "asio.device_name"
#define ASIOHOOK_CONFIG_IO_DEFAULT_FORCE_ASIO_VALUE false
#define ASIOHOOK_CONFIG_IO_DEFAULT_ASIO_DEVICE_NAME_VALUE \
"XONAR SOUND CARD(64)"
void asiohook_config_init(struct cconfig *config)
{
cconfig_util_set_bool(
config,
ASIOHOOK_CONFIG_IO_FORCE_ASIO_KEY,
ASIOHOOK_CONFIG_IO_DEFAULT_FORCE_ASIO_VALUE,
"Force ASIO audio mode/device");
cconfig_util_set_str(
config,
ASIOHOOK_CONFIG_IO_ASIO_DEVICE_NAME_KEY,
ASIOHOOK_CONFIG_IO_DEFAULT_ASIO_DEVICE_NAME_VALUE,
"The ASIO device name to use");
}
void asiohook_config_asio_get(
struct asiohook_config_asio *config_asio, struct cconfig *config)
{
if (!cconfig_util_get_bool(
config,
ASIOHOOK_CONFIG_IO_FORCE_ASIO_KEY,
&config_asio->force_asio,
ASIOHOOK_CONFIG_IO_DEFAULT_FORCE_ASIO_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
ASIOHOOK_CONFIG_IO_FORCE_ASIO_KEY,
ASIOHOOK_CONFIG_IO_DEFAULT_FORCE_ASIO_VALUE);
}
if (!cconfig_util_get_str(
config,
ASIOHOOK_CONFIG_IO_ASIO_DEVICE_NAME_KEY,
config_asio->replacement_name,
sizeof(config_asio->replacement_name) - 1,
ASIOHOOK_CONFIG_IO_DEFAULT_ASIO_DEVICE_NAME_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
ASIOHOOK_CONFIG_IO_ASIO_DEVICE_NAME_KEY,
ASIOHOOK_CONFIG_IO_DEFAULT_ASIO_DEVICE_NAME_VALUE);
}
}

View File

@ -0,0 +1,18 @@
#ifndef ASIOHOOK_CONFIG_IO_H
#define ASIOHOOK_CONFIG_IO_H
#include <windows.h>
#include "cconfig/cconfig.h"
struct asiohook_config_asio {
bool force_asio;
char replacement_name[128];
};
void asiohook_config_init(struct cconfig *config);
void asiohook_config_asio_get(
struct asiohook_config_asio *config_asio, struct cconfig *config);
#endif