diff --git a/Module.mk b/Module.mk index be97eae..2594f34 100644 --- a/Module.mk +++ b/Module.mk @@ -493,8 +493,9 @@ $(zipdir)/iidx-hwio-x86.zip: \ build/bin/indep-32/iidxio-bio2.dll \ build/bin/indep-32/iidxio-ezusb.dll \ build/bin/indep-32/iidxio-ezusb2.dll \ - dist/iidx/iidxio-bio2.conf \ build/bin/indep-32/vigem-iidxio.exe \ + dist/iidx/eamio-icca.xml \ + dist/iidx/iidxio-bio2.conf \ dist/iidx/vigem-iidxio.conf \ | $(zipdir)/ $(V)echo ... $@ @@ -506,8 +507,9 @@ $(zipdir)/iidx-hwio-x64.zip: \ build/bin/indep-64/iidxio-bio2.dll \ build/bin/indep-64/iidxio-ezusb.dll \ build/bin/indep-64/iidxio-ezusb2.dll \ - dist/iidx/iidxio-bio2.conf \ build/bin/indep-64/vigem-iidxio.exe \ + dist/iidx/eamio-icca.xml \ + dist/iidx/iidxio-bio2.conf \ dist/iidx/vigem-iidxio.conf \ | $(zipdir)/ $(V)echo ... $@ @@ -617,7 +619,7 @@ $(zipdir)/jb-hwio.zip: \ build/bin/indep-32/jbio-magicbox.dll \ build/bin/indep-32/jbio-p4io.dll \ dist/jb/jbio-h44b.conf \ - dist/jb/eamio-icc.conf \ + dist/jb/eamio-icca.xml \ | $(zipdir)/ $(V)echo ... $@ $(V)zip -j $@ $^ @@ -681,6 +683,7 @@ $(zipdir)/sdvx-hwio-x86.zip: \ build/bin/indep-32/sdvxio-kfca.dll \ build/bin/indep-32/sdvxio-bio2.dll \ build/bin/indep-32/vigem-sdvxio.exe \ + dist/sdvx/eamio-icca.xml \ | $(zipdir)/ $(V)echo ... $@ $(V)zip -j $@ $^ @@ -691,6 +694,7 @@ $(zipdir)/sdvx-hwio-x64.zip: \ build/bin/indep-64/sdvxio-kfca.dll \ build/bin/indep-64/sdvxio-bio2.dll \ build/bin/indep-64/vigem-sdvxio.exe \ + dist/sdvx/eamio-icca.xml \ | $(zipdir)/ $(V)echo ... $@ $(V)zip -j $@ $^ diff --git a/dist/ddr/eamio-icca.xml b/dist/ddr/eamio-icca.xml new file mode 100644 index 0000000..d89bf43 --- /dev/null +++ b/dist/ddr/eamio-icca.xml @@ -0,0 +1,5 @@ + + + COM1 + 57600 + \ No newline at end of file diff --git a/dist/iidx/eamio-icca.xml b/dist/iidx/eamio-icca.xml new file mode 100644 index 0000000..d89bf43 --- /dev/null +++ b/dist/iidx/eamio-icca.xml @@ -0,0 +1,5 @@ + + + COM1 + 57600 + \ No newline at end of file diff --git a/dist/jb/eamio-icc.conf b/dist/jb/eamio-icc.conf deleted file mode 100644 index eef3268..0000000 --- a/dist/jb/eamio-icc.conf +++ /dev/null @@ -1,5 +0,0 @@ -# ICCA serial port -icc.port=COM2 - -# ICCA bus baudrate (real devices expect 57600) -icc.baud=57600 diff --git a/dist/jb/eamio-icca.xml b/dist/jb/eamio-icca.xml new file mode 100644 index 0000000..c0a185c --- /dev/null +++ b/dist/jb/eamio-icca.xml @@ -0,0 +1,5 @@ + + + COM2 + 57600 + \ No newline at end of file diff --git a/dist/sdvx/eamio-icca.xml b/dist/sdvx/eamio-icca.xml new file mode 100644 index 0000000..d89bf43 --- /dev/null +++ b/dist/sdvx/eamio-icca.xml @@ -0,0 +1,5 @@ + + + COM1 + 57600 + \ No newline at end of file diff --git a/src/main/eamio-icca/Module.mk b/src/main/eamio-icca/Module.mk index 347ca2c..c53eaf3 100644 --- a/src/main/eamio-icca/Module.mk +++ b/src/main/eamio-icca/Module.mk @@ -4,12 +4,11 @@ dlls += \ libs_eamio-icca := \ core \ aciodrv \ - cconfig \ util \ iface-core \ iface-acio \ module \ src_eamio-icca := \ - config-icc.c \ - eamio-icca.c \ + config.c \ + eamio.c \ diff --git a/src/main/eamio-icca/config-icc.c b/src/main/eamio-icca/config-icc.c deleted file mode 100644 index 963f688..0000000 --- a/src/main/eamio-icca/config-icc.c +++ /dev/null @@ -1,53 +0,0 @@ -#include "cconfig/cconfig-util.h" - -#include "eamio-icca/config-icc.h" - -#define EAMIO_ICCA_CONFIG_ICC_PORT_KEY "icc.port" -#define EAMIO_ICCA_CONFIG_ICC_BAUD_KEY "icc.baud" - -#define EAMIO_ICCA_CONFIG_ICC_DEFAULT_PORT_VALUE "COM1" -#define EAMIO_ICCA_CONFIG_ICC_DEFAULT_BAUD_VALUE 57600 - -void eamio_icca_config_icc_init(struct cconfig *config) -{ - cconfig_util_set_str( - config, - EAMIO_ICCA_CONFIG_ICC_PORT_KEY, - EAMIO_ICCA_CONFIG_ICC_DEFAULT_PORT_VALUE, - "ICCA serial port"); - - cconfig_util_set_int( - config, - EAMIO_ICCA_CONFIG_ICC_BAUD_KEY, - EAMIO_ICCA_CONFIG_ICC_DEFAULT_BAUD_VALUE, - "ICCA bus baudrate (real devices expect 57600)"); -} - -void eamio_icca_config_icc_get( - struct icc_config *config_icc, struct cconfig *config) -{ - if (!cconfig_util_get_str( - config, - EAMIO_ICCA_CONFIG_ICC_PORT_KEY, - config_icc->port, - sizeof(config_icc->port) - 1, - EAMIO_ICCA_CONFIG_ICC_DEFAULT_PORT_VALUE)) { - log_warning( - "Invalid value for key '%s' specified, fallback " - "to default '%s'", - EAMIO_ICCA_CONFIG_ICC_PORT_KEY, - EAMIO_ICCA_CONFIG_ICC_DEFAULT_PORT_VALUE); - } - - if (!cconfig_util_get_int( - config, - EAMIO_ICCA_CONFIG_ICC_BAUD_KEY, - &config_icc->baud, - EAMIO_ICCA_CONFIG_ICC_DEFAULT_BAUD_VALUE)) { - log_warning( - "Invalid value for key '%s' specified, fallback " - "to default '%d'", - EAMIO_ICCA_CONFIG_ICC_BAUD_KEY, - EAMIO_ICCA_CONFIG_ICC_DEFAULT_BAUD_VALUE); - } -} diff --git a/src/main/eamio-icca/config-icc.h b/src/main/eamio-icca/config-icc.h deleted file mode 100644 index c1219a4..0000000 --- a/src/main/eamio-icca/config-icc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef EAMIO_ICCA_CONFIG_ICC_H -#define EAMIO_ICCA_CONFIG_ICC_H - -#include - -#include "cconfig/cconfig.h" - -struct icc_config { - char port[64]; - int32_t baud; -}; - -void eamio_icca_config_icc_init(struct cconfig *config); - -void eamio_icca_config_icc_get( - struct icc_config *config_icc, struct cconfig *config); - -#endif diff --git a/src/main/eamio-icca/config.c b/src/main/eamio-icca/config.c new file mode 100644 index 0000000..f365d77 --- /dev/null +++ b/src/main/eamio-icca/config.c @@ -0,0 +1,10 @@ +#include "core/config-ext.h" + +#include "eamio-icca/config.h" + +void eamio_icca_config_icc_get( + const bt_core_config_t *config, icc_config_t *config_out) +{ + bt_core_config_str_get(config, "port", config_out->port, sizeof(config_out->port)); + bt_core_config_s32_get(config, "baud", &config_out->baud); +} \ No newline at end of file diff --git a/src/main/eamio-icca/config.h b/src/main/eamio-icca/config.h new file mode 100644 index 0000000..a1fff41 --- /dev/null +++ b/src/main/eamio-icca/config.h @@ -0,0 +1,14 @@ +#ifndef EAMIO_ICCA_CONFIG_ICC_H +#define EAMIO_ICCA_CONFIG_ICC_H + +#include "api/core/config.h" + +typedef struct icc_config { + char port[64]; + int32_t baud; +} icc_config_t; + +void eamio_icca_config_icc_get( + const bt_core_config_t *config, icc_config_t *config_out); + +#endif diff --git a/src/main/eamio-icca/eamio-icca.def b/src/main/eamio-icca/eamio-icca.def index c37f90a..208d9d5 100644 --- a/src/main/eamio-icca/eamio-icca.def +++ b/src/main/eamio-icca/eamio-icca.def @@ -2,7 +2,9 @@ LIBRARY eamio-icca EXPORTS ; Bemanitools 6 API + bt_module_core_config_api_set bt_module_core_log_api_set + bt_module_configure_do bt_module_io_eam_api_get ; Direct API diff --git a/src/main/eamio-icca/eamio-icca.c b/src/main/eamio-icca/eamio.c similarity index 92% rename from src/main/eamio-icca/eamio-icca.c rename to src/main/eamio-icca/eamio.c index 50da3bd..423ae3c 100644 --- a/src/main/eamio-icca/eamio-icca.c +++ b/src/main/eamio-icca/eamio.c @@ -11,17 +11,18 @@ #include "aciodrv/device.h" #include "aciodrv/icca.h" +#include "api/core/config.h" #include "api/core/log.h" -#include "cconfig/cconfig-main.h" - -#include "eamio-icca/config-icc.h" +#include "eamio-icca/config.h" #include "iface-acio/mgr.h" +#include "iface-core/config.h" #include "iface-core/log.h" #include "module/acio-mgr.h" +#include "sdk/module/core/config.h" #include "sdk/module/core/log.h" #include "sdk/module/io/eam.h" @@ -47,6 +48,8 @@ static const uint8_t eam_io_keypad_mappings[16] = { BT_IO_EAM_KEYPAD_SCAN_CODE_5, BT_IO_EAM_KEYPAD_SCAN_CODE_8}; +static icc_config_t _eamio_icca_config; + static struct ac_io_icca_state eam_io_icca_state[NUMBER_OF_EMULATED_READERS]; static bt_acio_mgr_port_dispatcher_t *acio_manager_ctx; @@ -90,35 +93,12 @@ static bool check_if_icca(int node_id) bool bt_io_eam_init() { - struct cconfig *config; - struct icc_config config_icc; - - config = cconfig_init(); - - eamio_icca_config_icc_init(config); - - if (!cconfig_main_config_init( - config, - "--icc-config", - "eamio-icc.conf", - "--help", - "-h", - "eamio-icca", - CCONFIG_CMD_USAGE_OUT_STDOUT)) { - cconfig_finit(config); - exit(EXIT_FAILURE); - } - _bt_io_eam_icca_acio_mgr_init(&_icca_module_acio_mgr); - eamio_icca_config_icc_get(&config_icc, config); - - cconfig_finit(config); - - acio_manager_ctx = bt_acio_mgr_port_init(config_icc.port, config_icc.baud); + acio_manager_ctx = bt_acio_mgr_port_init(_eamio_icca_config.port, _eamio_icca_config.baud); if (acio_manager_ctx == NULL) { - log_warning("Opening acio device on %s failed", config_icc.port); + log_warning("Opening acio device on %s failed", _eamio_icca_config.port); return false; } @@ -337,11 +317,23 @@ const bt_io_eam_config_api_t *bt_io_eam_config_api_get(void) return NULL; } +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) +{ + eamio_icca_config_icc_get(config, &_eamio_icca_config); + + return true; +} + void bt_module_io_eam_api_get(bt_io_eam_api_t *api) { api->version = 1; @@ -354,9 +346,4 @@ void bt_module_io_eam_api_get(bt_io_eam_api_t *api) api->v1.card_slot_cmd_send = bt_io_eam_card_slot_cmd_send; api->v1.poll = bt_io_eam_poll; api->v1.config_api_get = bt_io_eam_config_api_get; -} - -BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *ctx) -{ - return TRUE; -} +} \ No newline at end of file