refact(iidxio-bio2): Use new config api
Summary: Test Plan: Summary: Test Plan:
This commit is contained in:
@@ -495,7 +495,7 @@ $(zipdir)/iidx-hwio-x86.zip: \
|
||||
build/bin/indep-32/iidxio-ezusb2.dll \
|
||||
build/bin/indep-32/vigem-iidxio.exe \
|
||||
dist/iidx/eamio-icca.xml \
|
||||
dist/iidx/iidxio-bio2.conf \
|
||||
dist/iidx/iidxio-bio2.xml \
|
||||
dist/iidx/vigem-iidxio.conf \
|
||||
| $(zipdir)/
|
||||
$(V)echo ... $@
|
||||
@@ -509,7 +509,7 @@ $(zipdir)/iidx-hwio-x64.zip: \
|
||||
build/bin/indep-64/iidxio-ezusb2.dll \
|
||||
build/bin/indep-64/vigem-iidxio.exe \
|
||||
dist/iidx/eamio-icca.xml \
|
||||
dist/iidx/iidxio-bio2.conf \
|
||||
dist/iidx/iidxio-bio2.xml \
|
||||
dist/iidx/vigem-iidxio.conf \
|
||||
| $(zipdir)/
|
||||
$(V)echo ... $@
|
||||
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
# Autodetect BIO2 port (default: on)
|
||||
bio2.autodetect=true
|
||||
|
||||
# BIO2 serial port. Optional, if autodetect property is turned on
|
||||
bio2.port=COM4
|
||||
|
||||
# BIO2 bus baudrate (real devices expect 115200)
|
||||
bio2.baud=115200
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="Shift-JIS"?>
|
||||
<iidxio-bio2>
|
||||
<autodetect __type="bool">1</autodetect>
|
||||
<port __type="str">COM4</port>
|
||||
<baud __type="s32">115200</baud>
|
||||
</iidxio-bio2>
|
||||
@@ -5,7 +5,7 @@ libs_bio2drv := \
|
||||
aciodrv \
|
||||
|
||||
src_bio2drv := \
|
||||
config.c \
|
||||
detect.c \
|
||||
config-bio2.c \
|
||||
bi2a-iidx.c \
|
||||
bi2a-sdvx.c \
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
#include "bio2drv/config-bio2.h"
|
||||
|
||||
#include "cconfig/cconfig-util.h"
|
||||
|
||||
#include "iface-core/log.h"
|
||||
|
||||
#define BIO2DRV_CONFIG_BIO2_AUTO_KEY "bio2.autodetect"
|
||||
#define BIO2DRV_CONFIG_BIO2_PORT_KEY "bio2.port"
|
||||
#define BIO2DRV_CONFIG_BIO2_BAUD_KEY "bio2.baud"
|
||||
|
||||
#define BIO2DRV_CONFIG_BIO2_DEFAULT_AUTO_VALUE true
|
||||
#define BIO2DRV_CONFIG_BIO2_DEFAULT_PORT_VALUE "COM4"
|
||||
#define BIO2DRV_CONFIG_BIO2_DEFAULT_BAUD_VALUE 115200
|
||||
|
||||
void bio2drv_config_bio2_init(struct cconfig *config)
|
||||
{
|
||||
cconfig_util_set_bool(
|
||||
config,
|
||||
BIO2DRV_CONFIG_BIO2_AUTO_KEY,
|
||||
BIO2DRV_CONFIG_BIO2_DEFAULT_AUTO_VALUE,
|
||||
"Autodetect BIO2 port (default: on)");
|
||||
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
BIO2DRV_CONFIG_BIO2_PORT_KEY,
|
||||
BIO2DRV_CONFIG_BIO2_DEFAULT_PORT_VALUE,
|
||||
"BIO2 serial port. Optional, if autodetect property is turned on");
|
||||
|
||||
cconfig_util_set_int(
|
||||
config,
|
||||
BIO2DRV_CONFIG_BIO2_BAUD_KEY,
|
||||
BIO2DRV_CONFIG_BIO2_DEFAULT_BAUD_VALUE,
|
||||
"BIO2 bus baudrate (real devices expect 115200)");
|
||||
}
|
||||
|
||||
void bio2drv_config_bio2_get(
|
||||
struct bio2drv_config_bio2 *config_bio2, struct cconfig *config)
|
||||
{
|
||||
if (!cconfig_util_get_bool(
|
||||
config,
|
||||
BIO2DRV_CONFIG_BIO2_AUTO_KEY,
|
||||
&config_bio2->autodetect,
|
||||
BIO2DRV_CONFIG_BIO2_DEFAULT_AUTO_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
BIO2DRV_CONFIG_BIO2_AUTO_KEY,
|
||||
BIO2DRV_CONFIG_BIO2_DEFAULT_AUTO_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
BIO2DRV_CONFIG_BIO2_PORT_KEY,
|
||||
config_bio2->port,
|
||||
sizeof(config_bio2->port) - 1,
|
||||
BIO2DRV_CONFIG_BIO2_DEFAULT_PORT_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
BIO2DRV_CONFIG_BIO2_PORT_KEY,
|
||||
BIO2DRV_CONFIG_BIO2_DEFAULT_PORT_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_int(
|
||||
config,
|
||||
BIO2DRV_CONFIG_BIO2_BAUD_KEY,
|
||||
&config_bio2->baud,
|
||||
BIO2DRV_CONFIG_BIO2_DEFAULT_BAUD_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
BIO2DRV_CONFIG_BIO2_BAUD_KEY,
|
||||
BIO2DRV_CONFIG_BIO2_DEFAULT_BAUD_VALUE);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef BIO2DRV_CONFIG_BIO2_H
|
||||
#define BIO2DRV_CONFIG_BIO2_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "cconfig/cconfig.h"
|
||||
|
||||
struct bio2drv_config_bio2 {
|
||||
bool autodetect;
|
||||
char port[64];
|
||||
int32_t baud;
|
||||
};
|
||||
|
||||
void bio2drv_config_bio2_init(struct cconfig *config);
|
||||
|
||||
void bio2drv_config_bio2_get(
|
||||
struct bio2drv_config_bio2 *config_bio2, struct cconfig *config);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "bio2drv/config.h"
|
||||
|
||||
#include "core/config-ext.h"
|
||||
|
||||
void bio2drv_config_bio2_get(
|
||||
const bt_core_config_t *config, bio2drv_config_t *config_out)
|
||||
{
|
||||
bt_core_config_ext_bool_get(config, "autodetect", &config_out->autodetect);
|
||||
bt_core_config_ext_str_get(config, "port", config_out->port, sizeof(config_out->port));
|
||||
bt_core_config_ext_s32_get(config, "baud", &config_out->baud);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef BIO2DRV_CONFIG_BIO2_H
|
||||
#define BIO2DRV_CONFIG_BIO2_H
|
||||
|
||||
#include "api/core/config.h"
|
||||
|
||||
typedef struct bio2drv_config {
|
||||
bool autodetect;
|
||||
char port[64];
|
||||
int32_t baud;
|
||||
} bio2drv_config_t;
|
||||
|
||||
void bio2drv_config_bio2_get(
|
||||
const bt_core_config_t *config, bio2drv_config_t *config_out);
|
||||
|
||||
#endif
|
||||
@@ -2,17 +2,18 @@ dlls += iidxio-bio2
|
||||
|
||||
ldflags_iidxio-bio2 := \
|
||||
-lsetupapi \
|
||||
-lws2_32 \
|
||||
|
||||
libs_iidxio-bio2 := \
|
||||
core \
|
||||
aciodrv \
|
||||
bio2drv \
|
||||
cconfig \
|
||||
util \
|
||||
iface \
|
||||
module \
|
||||
iface-io \
|
||||
iface-core \
|
||||
security \
|
||||
|
||||
src_iidxio-bio2 := \
|
||||
iidxio.c \
|
||||
|
||||
@@ -2,8 +2,9 @@ LIBRARY iidxio
|
||||
|
||||
EXPORTS
|
||||
; Bemanitools 6 API
|
||||
bt_module_core_config_api_set
|
||||
bt_module_core_log_api_set
|
||||
bt_module_core_thread_api_set
|
||||
bt_module_configure_do
|
||||
bt_module_io_iidx_api_get
|
||||
|
||||
; Direct API
|
||||
|
||||
@@ -10,22 +10,26 @@
|
||||
|
||||
#include "aciodrv/device.h"
|
||||
|
||||
#include "api/core/config.h"
|
||||
#include "api/core/log.h"
|
||||
#include "api/core/thread.h"
|
||||
|
||||
#include "bio2drv/bi2a-iidx.h"
|
||||
#include "bio2drv/config-bio2.h"
|
||||
#include "bio2drv/config.h"
|
||||
#include "bio2drv/detect.h"
|
||||
|
||||
#include "iface-core/config.h"
|
||||
#include "iface-core/log.h"
|
||||
#include "iface-core/thread.h"
|
||||
|
||||
#include "cconfig/cconfig-main.h"
|
||||
|
||||
#include "sdk/module/core/config.h"
|
||||
#include "sdk/module/configure.h"
|
||||
#include "sdk/module/core/log.h"
|
||||
#include "sdk/module/core/thread.h"
|
||||
#include "sdk/module/io/iidx.h"
|
||||
|
||||
static bio2drv_config_t _iidxio_bio2_config;
|
||||
|
||||
static char autodetect_buffer[512];
|
||||
|
||||
static atomic_bool running;
|
||||
@@ -61,32 +65,9 @@ static bool _bio2_iidx_io_poll(
|
||||
|
||||
bool bt_io_iidx_init()
|
||||
{
|
||||
struct cconfig *config;
|
||||
struct bio2drv_config_bio2 config_bio2;
|
||||
const char *selected_port = _iidxio_bio2_config.port;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
bio2drv_config_bio2_init(config);
|
||||
|
||||
if (!cconfig_main_config_init(
|
||||
config,
|
||||
"--bio2-config",
|
||||
"iidxio-bio2.conf",
|
||||
"--help",
|
||||
"-h",
|
||||
"iidxio-bio2",
|
||||
CCONFIG_CMD_USAGE_OUT_STDOUT)) {
|
||||
cconfig_finit(config);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bio2drv_config_bio2_get(&config_bio2, config);
|
||||
|
||||
cconfig_finit(config);
|
||||
|
||||
const char *selected_port = config_bio2.port;
|
||||
|
||||
if (config_bio2.autodetect) {
|
||||
if (_iidxio_bio2_config.autodetect) {
|
||||
log_info("Attempting autodetect");
|
||||
|
||||
if (bio2drv_detect(
|
||||
@@ -101,7 +82,7 @@ bool bt_io_iidx_init()
|
||||
}
|
||||
|
||||
// BIO2's cannot share a bus with anything else, so use device directly
|
||||
bio2_device_ctx = aciodrv_device_open_path(selected_port, config_bio2.baud);
|
||||
bio2_device_ctx = aciodrv_device_open_path(selected_port, _iidxio_bio2_config.baud);
|
||||
|
||||
if (bio2_device_ctx == NULL) {
|
||||
log_info("Opening BIO2 device on [%s] failed", selected_port);
|
||||
@@ -344,6 +325,11 @@ bool bt_io_iidx_ep3_16seg_send(const char *text)
|
||||
return true;
|
||||
}
|
||||
|
||||
void bt_module_core_config_api_set(const bt_core_config_api_t *api)
|
||||
{
|
||||
bt_core_config_api_set(api);
|
||||
}
|
||||
|
||||
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
|
||||
{
|
||||
bt_core_log_api_set(api);
|
||||
@@ -354,6 +340,13 @@ void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
|
||||
bt_core_thread_api_set(api);
|
||||
}
|
||||
|
||||
bool bt_module_configure_do(const bt_core_config_t *config)
|
||||
{
|
||||
bio2drv_config_bio2_get(config, &_iidxio_bio2_config);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void bt_module_io_iidx_api_get(bt_io_iidx_api_t *api)
|
||||
{
|
||||
api->version = 1;
|
||||
|
||||
Reference in New Issue
Block a user