mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2026-08-08 19:34:00 -05:00
refact(eamio-icca): Use new config api
Summary: Test Plan:
This commit is contained in:
parent
507f161c13
commit
6c0820ae42
10
Module.mk
10
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 $@ $^
|
||||
|
|
|
|||
5
dist/ddr/eamio-icca.xml
vendored
Normal file
5
dist/ddr/eamio-icca.xml
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="Shift-JIS"?>
|
||||
<eamio-icca>
|
||||
<port __type="str">COM1</port>
|
||||
<baud __type="s32">57600</baud>
|
||||
</eamio-icca>
|
||||
5
dist/iidx/eamio-icca.xml
vendored
Normal file
5
dist/iidx/eamio-icca.xml
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="Shift-JIS"?>
|
||||
<eamio-icca>
|
||||
<port __type="str">COM1</port>
|
||||
<baud __type="s32">57600</baud>
|
||||
</eamio-icca>
|
||||
5
dist/jb/eamio-icc.conf
vendored
5
dist/jb/eamio-icc.conf
vendored
|
|
@ -1,5 +0,0 @@
|
|||
# ICCA serial port
|
||||
icc.port=COM2
|
||||
|
||||
# ICCA bus baudrate (real devices expect 57600)
|
||||
icc.baud=57600
|
||||
5
dist/jb/eamio-icca.xml
vendored
Normal file
5
dist/jb/eamio-icca.xml
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="Shift-JIS"?>
|
||||
<eamio-icca>
|
||||
<port __type="str">COM2</port>
|
||||
<baud __type="s32">57600</baud>
|
||||
</eamio-icca>
|
||||
5
dist/sdvx/eamio-icca.xml
vendored
Normal file
5
dist/sdvx/eamio-icca.xml
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="Shift-JIS"?>
|
||||
<eamio-icca>
|
||||
<port __type="str">COM1</port>
|
||||
<baud __type="s32">57600</baud>
|
||||
</eamio-icca>
|
||||
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#ifndef EAMIO_ICCA_CONFIG_ICC_H
|
||||
#define EAMIO_ICCA_CONFIG_ICC_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#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
|
||||
10
src/main/eamio-icca/config.c
Normal file
10
src/main/eamio-icca/config.c
Normal file
|
|
@ -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);
|
||||
}
|
||||
14
src/main/eamio-icca/config.h
Normal file
14
src/main/eamio-icca/config.h
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user