diff --git a/src/main/iidxhook-util/config-io.c b/src/main/iidxhook-util/config-io.c new file mode 100644 index 0000000..a2095bf --- /dev/null +++ b/src/main/iidxhook-util/config-io.c @@ -0,0 +1,56 @@ +#include "cconfig/cconfig-util.h" + +#include "iidxhook-util/config-io.h" + +#include "util/log.h" + +#define IIDXHOOK_UTIL_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY \ + "io.disable_card_reader_emu" +#define IIDXHOOK_UTIL_CONFIG_IO_DISABLE_IO_EMU_KEY "io.disable_io_emu" + +#define IIDXHOOK_UTIL_CONFIG_IO_DEFAULT_DISABLE_CARD_READER_EMU_VALUE false +#define IIDXHOOK_UTIL_CONFIG_IO_DEFAULT_DISABLE_IO_EMU_VALUE false + +void iidxhook_config_io_init(struct cconfig *config) +{ + cconfig_util_set_bool( + config, + IIDXHOOK_UTIL_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY, + IIDXHOOK_UTIL_CONFIG_IO_DEFAULT_DISABLE_CARD_READER_EMU_VALUE, + "Disable card reader emulation and enable usage of real card reader " + "hardware on COM1 (for games supporting slotted/wavepass readers)"); + + cconfig_util_set_bool( + config, + IIDXHOOK_UTIL_CONFIG_IO_DISABLE_IO_EMU_KEY, + IIDXHOOK_UTIL_CONFIG_IO_DEFAULT_DISABLE_IO_EMU_VALUE, + "Disable ezusb IO emulation and enable usage of real ezusb1/2 IO hardware"); +} + +void iidxhook_config_io_get( + struct iidxhook_config_io *config_io, struct cconfig *config) +{ + if (!cconfig_util_get_bool( + config, + IIDXHOOK_UTIL_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY, + &config_io->disable_card_reader_emu, + IIDXHOOK_UTIL_CONFIG_IO_DEFAULT_DISABLE_CARD_READER_EMU_VALUE)) { + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default '%d'", + IIDXHOOK_UTIL_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY, + IIDXHOOK_UTIL_CONFIG_IO_DEFAULT_DISABLE_CARD_READER_EMU_VALUE); + } + + if (!cconfig_util_get_bool( + config, + IIDXHOOK_UTIL_CONFIG_IO_DISABLE_IO_EMU_KEY, + &config_io->disable_io_emu, + IIDXHOOK_UTIL_CONFIG_IO_DEFAULT_DISABLE_IO_EMU_VALUE)) { + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default '%d'", + IIDXHOOK_UTIL_CONFIG_IO_DISABLE_IO_EMU_KEY, + IIDXHOOK_UTIL_CONFIG_IO_DEFAULT_DISABLE_IO_EMU_VALUE); + } +} diff --git a/src/main/iidxhook-util/config-io.h b/src/main/iidxhook-util/config-io.h new file mode 100644 index 0000000..0f63750 --- /dev/null +++ b/src/main/iidxhook-util/config-io.h @@ -0,0 +1,18 @@ +#ifndef IIDXHOOK_UTIL_CONFIG_IO_H +#define IIDXHOOK_UTIL_CONFIG_IO_H + +#include + +#include "cconfig/cconfig.h" + +struct iidxhook_config_io { + bool disable_card_reader_emu; + bool disable_io_emu; +}; + +void iidxhook_config_io_init(struct cconfig *config); + +void iidxhook_config_io_get( + struct iidxhook_config_io *config_io, struct cconfig *config); + +#endif \ No newline at end of file