diff --git a/Module.mk b/Module.mk index 6237435..e22b0dc 100644 --- a/Module.mk +++ b/Module.mk @@ -616,7 +616,7 @@ $(zipdir)/jb-hwio.zip: \ build/bin/indep-32/eamio-icca.dll \ build/bin/indep-32/jbio-magicbox.dll \ build/bin/indep-32/jbio-p4io.dll \ - dist/jb/jbio-h44b.conf \ + dist/jb/jbio-h44b.xml \ dist/jb/eamio-icca.xml \ | $(zipdir)/ $(V)echo ... $@ diff --git a/dist/jb/jbio-h44b.conf b/dist/jb/jbio-h44b.conf deleted file mode 100644 index 7c984b5..0000000 --- a/dist/jb/jbio-h44b.conf +++ /dev/null @@ -1,5 +0,0 @@ -# H44B serial port -h44b.port=COM2 - -# H44B bus baudrate (real devices expect 57600) -h44b.baud=57600 diff --git a/dist/jb/jbio-h44b.xml b/dist/jb/jbio-h44b.xml new file mode 100644 index 0000000..aaaf54f --- /dev/null +++ b/dist/jb/jbio-h44b.xml @@ -0,0 +1,7 @@ + + + + COM2 + + 57600 + diff --git a/src/main/jbio-p4io/Module.mk b/src/main/jbio-p4io/Module.mk index 7a85788..2ccda69 100644 --- a/src/main/jbio-p4io/Module.mk +++ b/src/main/jbio-p4io/Module.mk @@ -1,19 +1,21 @@ dlls += jbio-p4io ldflags_jbio-p4io := \ - -lsetupapi - -src_jbio-p4io := \ - config-h44b.c \ - h44b.c \ - jbio.c \ + -lsetupapi \ + -lws2_32 \ libs_jbio-p4io := \ + core \ aciodrv \ - cconfig \ p4iodrv \ util \ iface \ module \ iface-core \ iface-acio \ + security \ + +src_jbio-p4io := \ + config-h44b.c \ + h44b.c \ + jbio.c \ diff --git a/src/main/jbio-p4io/config-h44b.c b/src/main/jbio-p4io/config-h44b.c index 842a0ff..88d2ce0 100644 --- a/src/main/jbio-p4io/config-h44b.c +++ b/src/main/jbio-p4io/config-h44b.c @@ -1,55 +1,11 @@ -#include "cconfig/cconfig-util.h" - -#include "iface-core/log.h" +#include "core/config-ext.h" #include "jbio-p4io/config-h44b.h" -#define JBIO_CONFIG_H44B_PORT_KEY "h44b.port" -#define JBIO_CONFIG_H44B_BAUD_KEY "h44b.baud" - -#define JBIO_CONFIG_H44B_DEFAULT_PORT_VALUE "COM2" -#define JBIO_CONFIG_H44B_DEFAULT_BAUD_VALUE 57600 - -void jbio_config_h44b_init(struct cconfig *config) -{ - cconfig_util_set_str( - config, - JBIO_CONFIG_H44B_PORT_KEY, - JBIO_CONFIG_H44B_DEFAULT_PORT_VALUE, - "H44B serial port"); - - cconfig_util_set_int( - config, - JBIO_CONFIG_H44B_BAUD_KEY, - JBIO_CONFIG_H44B_DEFAULT_BAUD_VALUE, - "H44B bus baudrate (real devices expect 57600)"); -} - void jbio_config_h44b_get( - struct h44b_config *config_h44b, struct cconfig *config) + const bt_core_config_t *config, + h44b_config_t *config_out) { - if (!cconfig_util_get_str( - config, - JBIO_CONFIG_H44B_PORT_KEY, - config_h44b->port, - sizeof(config_h44b->port) - 1, - JBIO_CONFIG_H44B_DEFAULT_PORT_VALUE)) { - log_warning( - "Invalid value for key '%s' specified, fallback " - "to default '%s'", - JBIO_CONFIG_H44B_PORT_KEY, - JBIO_CONFIG_H44B_DEFAULT_PORT_VALUE); - } - - if (!cconfig_util_get_int( - config, - JBIO_CONFIG_H44B_BAUD_KEY, - &config_h44b->baud, - JBIO_CONFIG_H44B_DEFAULT_BAUD_VALUE)) { - log_warning( - "Invalid value for key '%s' specified, fallback " - "to default '%d'", - JBIO_CONFIG_H44B_BAUD_KEY, - JBIO_CONFIG_H44B_DEFAULT_BAUD_VALUE); - } + bt_core_config_str_get(config, "h44b/port", config_out->port, sizeof(config_out->port)); + bt_core_config_s32_get(config, "h44b/baud", &config_out->baud); } diff --git a/src/main/jbio-p4io/config-h44b.h b/src/main/jbio-p4io/config-h44b.h index cdc33f9..6919547 100644 --- a/src/main/jbio-p4io/config-h44b.h +++ b/src/main/jbio-p4io/config-h44b.h @@ -1,18 +1,15 @@ #ifndef JBIO_CONFIG_H44B_H #define JBIO_CONFIG_H44B_H -#include +#include "api/core/config.h" -#include "cconfig/cconfig.h" - -struct h44b_config { +typedef struct h44b_config { char port[64]; int32_t baud; -}; - -void jbio_config_h44b_init(struct cconfig *config); +} h44b_config_t; void jbio_config_h44b_get( - struct h44b_config *config_h44b, struct cconfig *config); + const bt_core_config_t *config, + h44b_config_t *config_out); #endif diff --git a/src/main/jbio-p4io/jbio-p4io.def b/src/main/jbio-p4io/jbio-p4io.def index c665b51..cd7c296 100644 --- a/src/main/jbio-p4io/jbio-p4io.def +++ b/src/main/jbio-p4io/jbio-p4io.def @@ -2,7 +2,9 @@ LIBRARY jbio EXPORTS ; Bemanitools 6 API + bt_module_core_config_api_set bt_module_core_log_api_set + bt_module_configure_do bt_module_io_jb_api_get ; Direct API diff --git a/src/main/jbio-p4io/jbio.c b/src/main/jbio-p4io/jbio.c index 97e4162..a8bf374 100644 --- a/src/main/jbio-p4io/jbio.c +++ b/src/main/jbio-p4io/jbio.c @@ -9,9 +9,8 @@ #include "api/core/log.h" -#include "cconfig/cconfig-main.h" - #include "iface-acio/mgr.h" +#include "iface-core/config.h" #include "iface-core/log.h" #include "jbio-p4io/config-h44b.h" @@ -21,9 +20,13 @@ #include "p4iodrv/device.h" +#include "sdk/module/core/config.h" +#include "sdk/module/configure.h" #include "sdk/module/core/log.h" #include "sdk/module/io/jb.h" +static h44b_config_t _jbio_p4io_config_h44b; + static struct p4iodrv_ctx *p4io_ctx; static uint16_t jb_io_panels; static uint8_t jb_io_sys_buttons; @@ -47,29 +50,6 @@ static void _bt_io_jb_module_acio_mgr_init(module_acio_mgr_t **module) bool bt_io_jb_init() { - struct cconfig *config; - struct h44b_config config_h44b; - - config = cconfig_init(); - - jbio_config_h44b_init(config); - - if (!cconfig_main_config_init( - config, - "--h44b-config", - "jbio-h44b.conf", - "--help", - "-h", - "jbio-h44b", - CCONFIG_CMD_USAGE_OUT_STDOUT)) { - cconfig_finit(config); - exit(EXIT_FAILURE); - } - - jbio_config_h44b_get(&config_h44b, config); - - cconfig_finit(config); - _bt_io_jb_module_acio_mgr_init(&acio_mgr_module); p4io_ctx = p4iodrv_open(); @@ -79,7 +59,7 @@ bool bt_io_jb_init() // some people use p4io just for acio_mgrs and have no lights. Soft fail // when h44b is not able to be connected instead of returning false - lights_present = jb_io_h44b_init(config_h44b.port, config_h44b.baud); + lights_present = jb_io_h44b_init(_jbio_p4io_config_h44b.port, _jbio_p4io_config_h44b.baud); if (!lights_present) { log_warning("Could not connect to H44B, lights disabled"); } @@ -239,11 +219,23 @@ bool bt_io_jb_coin_blocker_set(bool blocked) return p4iodrv_cmd_coinstock(p4io_ctx, coin); } +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); } +bool bt_module_configure_do(const bt_core_config_t *config) +{ + jbio_config_h44b_get(config, &_jbio_p4io_config_h44b); + + return true; +} + void bt_module_io_jb_api_get(bt_io_jb_api_t *api) { api->version = 1;