mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2024-11-28 00:10:51 +01:00
sdvxio-kfca: use cconfig instead of envvar
This commit is contained in:
parent
d177f23476
commit
82ac30e49f
@ -3,12 +3,14 @@ Thus, it allows you to use a KFCA device board with *any* version of SDVX that i
|
||||
|
||||
# Setup
|
||||
* Rename sdvxio-kfca.dll to sdvxio.dll.
|
||||
* Ensure that your gamestart.bat actually injects the appropriate sdvxhook dll,
|
||||
* Ensure that your gamestart.bat actually injects the appropriate sdvxhook dll
|
||||
for example:
|
||||
```
|
||||
launcher -K iidxhook2.dll soundvoltex.dll ...*
|
||||
launcher -K sdvxhook2.dll soundvoltex.dll ...*
|
||||
```
|
||||
or that the application otherwise uses sdvxio.dll
|
||||
|
||||
* sdvxio-kfca expects a KFCA device on COM3 by default
|
||||
* You can change the port by settings the SDVXIO_KFCA_PORT envvar
|
||||
* You can change the port and baudrate by editing the sdvxio-kfca.conf that should be created by default
|
||||
* If there is also an ICCA device on the same ACIO bus, it cannot be used with eamio-icca at this time
|
||||
* Please connect any additional acio devices to their own port (ex: SDVX5 expects an ICCA by itself on COM2)
|
||||
|
@ -3,8 +3,10 @@ dlls += sdvxio-kfca
|
||||
libs_sdvxio-kfca := \
|
||||
geninput \
|
||||
aciodrv \
|
||||
cconfig \
|
||||
util \
|
||||
|
||||
src_sdvxio-kfca := \
|
||||
sdvxio.c \
|
||||
config-kfca.c \
|
||||
|
||||
|
56
src/main/sdvxio-kfca/config-kfca.c
Normal file
56
src/main/sdvxio-kfca/config-kfca.c
Normal file
@ -0,0 +1,56 @@
|
||||
#include "cconfig/cconfig-util.h"
|
||||
|
||||
#include "sdvxio-kfca/config-kfca.h"
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
SDVXIO_KFCA_CONFIG_KFCA_H
|
||||
#define SDVXIO_KFCA_CONFIG_KFCA_PORT_KEY "kfca.port"
|
||||
#define SDVXIO_KFCA_CONFIG_KFCA_BAUD_KEY "kfca.baud"
|
||||
|
||||
#define SDVXIO_KFCA_CONFIG_KFCA_DEFAULT_PORT_VALUE "COM3"
|
||||
#define SDVXIO_KFCA_CONFIG_KFCA_DEFAULT_BAUD_VALUE 57600
|
||||
|
||||
void sdvxio_kfca_config_kfca_init(struct cconfig *config)
|
||||
{
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
SDVXIO_KFCA_CONFIG_KFCA_PORT_KEY,
|
||||
SDVXIO_KFCA_CONFIG_KFCA_DEFAULT_PORT_VALUE,
|
||||
"KFCA ACIO serial port");
|
||||
|
||||
cconfig_util_set_int(
|
||||
config,
|
||||
SDVXIO_KFCA_CONFIG_KFCA_BAUD_KEY,
|
||||
SDVXIO_KFCA_CONFIG_KFCA_DEFAULT_BAUD_VALUE,
|
||||
"KFCA ACIO bus baudrate (real devices expect 57600)");
|
||||
}
|
||||
|
||||
void sdvxio_kfca_config_kfca_get(
|
||||
struct sdvxio_kfca_config_kfca *config_kfca, struct cconfig *config)
|
||||
{
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
SDVXIO_KFCA_CONFIG_KFCA_PORT_KEY,
|
||||
config_kfca->port,
|
||||
sizeof(config_kfca->port) - 1,
|
||||
SDVXIO_KFCA_CONFIG_KFCA_DEFAULT_PORT_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
SDVXIO_KFCA_CONFIG_KFCA_PORT_KEY,
|
||||
SDVXIO_KFCA_CONFIG_KFCA_DEFAULT_PORT_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_int(
|
||||
config,
|
||||
SDVXIO_KFCA_CONFIG_KFCA_BAUD_KEY,
|
||||
&config_kfca->baud,
|
||||
SDVXIO_KFCA_CONFIG_KFCA_DEFAULT_BAUD_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
SDVXIO_KFCA_CONFIG_KFCA_BAUD_KEY,
|
||||
SDVXIO_KFCA_CONFIG_KFCA_DEFAULT_BAUD_VALUE);
|
||||
}
|
||||
}
|
18
src/main/sdvxio-kfca/config-kfca.h
Normal file
18
src/main/sdvxio-kfca/config-kfca.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef SDVXIO_KFCA_CONFIG_KFCA_H
|
||||
#define SDVXIO_KFCA_CONFIG_KFCA_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "cconfig/cconfig.h"
|
||||
|
||||
struct sdvxio_kfca_config_kfca {
|
||||
char port[64];
|
||||
int32_t baud;
|
||||
};
|
||||
|
||||
void sdvxio_kfca_config_kfca_init(struct cconfig *config);
|
||||
|
||||
void sdvxio_kfca_config_kfca_get(
|
||||
struct sdvxio_kfca_config_kfca *config_kfca, struct cconfig *config);
|
||||
|
||||
#endif
|
@ -6,9 +6,13 @@
|
||||
#include "bemanitools/glue.h"
|
||||
#include "bemanitools/sdvxio.h"
|
||||
|
||||
#include "cconfig/cconfig-main.h"
|
||||
|
||||
#include "aciodrv/device.h"
|
||||
#include "aciodrv/kfca.h"
|
||||
|
||||
#include "sdvxio-kfca/config-kfca.h"
|
||||
|
||||
#define LOG_MODULE "sdvxio-kfca"
|
||||
|
||||
#define log_misc(...) sdvx_io_log_misc(LOG_MODULE, __VA_ARGS__)
|
||||
@ -48,16 +52,33 @@ bool sdvx_io_init(
|
||||
thread_join_t thread_join,
|
||||
thread_destroy_t thread_destroy)
|
||||
{
|
||||
const char* default_port = "COM3";
|
||||
const char* selected_port = getenv("SDVXIO_KFCA_PORT");
|
||||
|
||||
if (!selected_port) {
|
||||
selected_port = default_port;
|
||||
struct cconfig *config;
|
||||
struct sdvxio_kfca_config_kfca config_kfca;
|
||||
|
||||
config = cconfig_init();
|
||||
|
||||
sdvxio_kfca_config_kfca_init(config);
|
||||
|
||||
if (!cconfig_main_config_init(
|
||||
config,
|
||||
"--kfca-config",
|
||||
"sdvxio-kfca.conf",
|
||||
"--help",
|
||||
"-h",
|
||||
"sdvxio-kfca",
|
||||
CCONFIG_CMD_USAGE_OUT_STDOUT)) {
|
||||
cconfig_finit(config);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!aciodrv_device_open(selected_port, 57600)) {
|
||||
log_info("Opening acio device on [%s] failed", selected_port);
|
||||
return -1;
|
||||
sdvxio_kfca_config_kfca_get(&config_kfca, config);
|
||||
|
||||
cconfig_finit(config);
|
||||
|
||||
if (!aciodrv_device_open(config_kfca.port, config_kfca.baud)) {
|
||||
log_info("Opening acio device on [%s] failed", config_kfca.port);
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_info("Opening acio device successful");
|
||||
|
Loading…
Reference in New Issue
Block a user