mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2026-08-28 03:14:03 -05:00
refact(vigem-ddrio): Use new config api
Summary: Test Plan:
This commit is contained in:
@@ -834,6 +834,7 @@ $(zipdir)/ddr-hwio-x86.zip: \
|
||||
build/bin/indep-32/extiotest.exe \
|
||||
build/bin/indep-32/p3io-ddr-tool.exe \
|
||||
build/bin/indep-32/vigem-ddrio.exe \
|
||||
dist/ddr/vigem-ddrio.xml \
|
||||
| $(zipdir)/
|
||||
$(V)echo ... $@
|
||||
$(V)zip -j $@ $^
|
||||
@@ -846,6 +847,7 @@ $(zipdir)/ddr-hwio-x64.zip: \
|
||||
build/bin/indep-64/extiotest.exe \
|
||||
build/bin/indep-64/p3io-ddr-tool.exe \
|
||||
build/bin/indep-64/vigem-ddrio.exe \
|
||||
dist/ddr/vigem-ddrio.xml \
|
||||
| $(zipdir)/
|
||||
$(V)echo ... $@
|
||||
$(V)zip -j $@ $^
|
||||
|
||||
4
dist/ddr/vigem-ddrio.xml
vendored
Normal file
4
dist/ddr/vigem-ddrio.xml
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="Shift-JIS"?>
|
||||
<vigem-ddrio>
|
||||
<enable_reactive_light __type="bool">1</enable_reactive_light>
|
||||
</vigem-ddrio>
|
||||
@@ -8,16 +8,17 @@ cppflags_vigem-ddrio := \
|
||||
|
||||
ldflags_vigem-ddrio := \
|
||||
-lsetupapi \
|
||||
-lws2_32 \
|
||||
|
||||
libs_vigem-ddrio := \
|
||||
core \
|
||||
cconfig \
|
||||
util \
|
||||
vigemstub \
|
||||
module \
|
||||
iface-io \
|
||||
iface-core \
|
||||
security \
|
||||
util \
|
||||
|
||||
src_vigem-ddrio := \
|
||||
config.c \
|
||||
main.c \
|
||||
config-vigem-ddrio.c \
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
#include "cconfig/cconfig-main.h"
|
||||
#include "cconfig/cconfig-util.h"
|
||||
|
||||
#include "iface-core/log.h"
|
||||
|
||||
#include "vigem-ddrio/config-vigem-ddrio.h"
|
||||
|
||||
#define VIGEM_DDRIO_CONFIG_ENABLE_REACTIVE_LIGHT_KEY \
|
||||
"ddrio.enable_reactive_light"
|
||||
|
||||
#define VIGEM_DDRIO_CONFIG_DEFAULT_ENABLE_REACTIVE_LIGHT_VALUE true
|
||||
|
||||
static void vigem_ddrio_config_init(struct cconfig *config)
|
||||
{
|
||||
cconfig_util_set_bool(
|
||||
config,
|
||||
VIGEM_DDRIO_CONFIG_ENABLE_REACTIVE_LIGHT_KEY,
|
||||
VIGEM_DDRIO_CONFIG_DEFAULT_ENABLE_REACTIVE_LIGHT_VALUE,
|
||||
"Enable reactive lights based on input.");
|
||||
}
|
||||
|
||||
static void vigem_ddrio_config_get(
|
||||
struct vigem_ddrio_config *vigem_config, struct cconfig *config)
|
||||
{
|
||||
if (!cconfig_util_get_bool(
|
||||
config,
|
||||
VIGEM_DDRIO_CONFIG_ENABLE_REACTIVE_LIGHT_KEY,
|
||||
&vigem_config->enable_reactive_light,
|
||||
VIGEM_DDRIO_CONFIG_DEFAULT_ENABLE_REACTIVE_LIGHT_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
VIGEM_DDRIO_CONFIG_ENABLE_REACTIVE_LIGHT_KEY,
|
||||
VIGEM_DDRIO_CONFIG_DEFAULT_ENABLE_REACTIVE_LIGHT_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
bool get_vigem_ddrio_config(struct vigem_ddrio_config *config_out)
|
||||
{
|
||||
struct cconfig *config;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
vigem_ddrio_config_init(config);
|
||||
|
||||
if (!cconfig_main_config_init(
|
||||
config,
|
||||
"--config",
|
||||
"vigem-ddrio.conf",
|
||||
"--help",
|
||||
"-h",
|
||||
"vigem-ddrio",
|
||||
CCONFIG_CMD_USAGE_OUT_STDOUT)) {
|
||||
cconfig_finit(config);
|
||||
return false;
|
||||
}
|
||||
|
||||
vigem_ddrio_config_get(config_out, config);
|
||||
|
||||
cconfig_finit(config);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef VIGEM_DDRIO_CONFIG_H
|
||||
#define VIGEM_DDRIO_CONFIG_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "cconfig/cconfig.h"
|
||||
|
||||
struct vigem_ddrio_config {
|
||||
bool enable_reactive_light;
|
||||
};
|
||||
|
||||
bool get_vigem_ddrio_config(struct vigem_ddrio_config *config_out);
|
||||
|
||||
#endif
|
||||
8
src/main/vigem-ddrio/config.c
Normal file
8
src/main/vigem-ddrio/config.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "core/config-ext.h"
|
||||
|
||||
#include "vigem-ddrio/config.h"
|
||||
|
||||
void vigem_ddrio_config_get(const bt_core_config_t *config, vigem_ddrio_config_t *config_out)
|
||||
{
|
||||
bt_core_config_ext_bool_get(config, "enable_reactive_light", &config_out->enable_reactive_light);
|
||||
}
|
||||
12
src/main/vigem-ddrio/config.h
Normal file
12
src/main/vigem-ddrio/config.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef VIGEM_DDRIO_CONFIG_H
|
||||
#define VIGEM_DDRIO_CONFIG_H
|
||||
|
||||
#include "api/core/config.h"
|
||||
|
||||
typedef struct vigem_ddrio_config {
|
||||
bool enable_reactive_light;
|
||||
} vigem_ddrio_config_t;
|
||||
|
||||
void vigem_ddrio_config_get(const bt_core_config_t *config, vigem_ddrio_config_t *config_out);
|
||||
|
||||
#endif
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "ViGEm/Client.h"
|
||||
|
||||
#include "core/config-property-node.h"
|
||||
#include "core/log-bt-ext.h"
|
||||
#include "core/log-bt.h"
|
||||
#include "core/log-sink-std.h"
|
||||
@@ -23,7 +24,7 @@
|
||||
|
||||
#include "vigemstub/helper.h"
|
||||
|
||||
#include "vigem-ddrio/config-vigem-ddrio.h"
|
||||
#include "vigem-ddrio/config.h"
|
||||
|
||||
#define NUM_PADS 2
|
||||
|
||||
@@ -146,20 +147,40 @@ static void _module_io_ddr_init(module_io_t **module)
|
||||
bt_io_ddr_api_set(&api);
|
||||
}
|
||||
|
||||
static void _config_load(vigem_ddrio_config_t *config_out)
|
||||
{
|
||||
core_property_t *property;
|
||||
core_property_result_t property_result;
|
||||
core_property_node_t node;
|
||||
core_property_node_result_t node_result;
|
||||
bt_core_config_t *config;
|
||||
|
||||
property_result = core_property_file_load("vigem-ddrio.xml", &property);
|
||||
core_property_fatal_on_error(property_result);
|
||||
|
||||
node_result = core_property_root_node_get(property, &node);
|
||||
core_property_node_fatal_on_error(node_result);
|
||||
|
||||
core_config_property_node_init(&node, &config);
|
||||
|
||||
vigem_ddrio_config_get(config, config_out);
|
||||
|
||||
core_config_property_node_free(&config);
|
||||
core_property_free(&property);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
vigem_ddrio_config_t config;
|
||||
|
||||
core_log_bt_core_api_set();
|
||||
core_thread_crt_core_api_set();
|
||||
core_config_property_node_core_api_set();
|
||||
|
||||
core_log_bt_ext_init_with_stdout();
|
||||
core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_INFO);
|
||||
|
||||
struct vigem_ddrio_config config;
|
||||
|
||||
if (!get_vigem_ddrio_config(&config)) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
_config_load(&config);
|
||||
_module_io_ddr_init(&_module_io_ddr);
|
||||
|
||||
if (!bt_io_ddr_init()) {
|
||||
|
||||
Reference in New Issue
Block a user