diff --git a/board/config.c b/board/config.c index e64e28a..191425a 100644 --- a/board/config.c +++ b/board/config.c @@ -31,3 +31,11 @@ void aime_config_load(struct aime_config *cfg, const wchar_t *filename) aime_dll_config_load(&cfg->dll, filename); cfg->enable = GetPrivateProfileIntW(L"aime", L"enable", 1, filename); } + +void io4_config_load(struct io4_config *cfg, const wchar_t *filename) +{ + assert(cfg != NULL); + assert(filename != NULL); + + cfg->enable = GetPrivateProfileIntW(L"io4", L"enable", 1, filename); +} diff --git a/board/config.h b/board/config.h index 840c963..f436a82 100644 --- a/board/config.h +++ b/board/config.h @@ -3,6 +3,8 @@ #include #include +#include "board/io4.h" #include "board/sg-reader.h" void aime_config_load(struct aime_config *cfg, const wchar_t *filename); +void io4_config_load(struct io4_config *cfg, const wchar_t *filename); diff --git a/board/io4.c b/board/io4.c index c956700..efad62f 100644 --- a/board/io4.c +++ b/board/io4.c @@ -8,6 +8,7 @@ #include #include +#include "board/config.h" #include "board/guid.h" #include "board/io4.h" @@ -97,12 +98,20 @@ static uint8_t io4_system_status; static const struct io4_ops *io4_ops; static void *io4_ops_ctx; -HRESULT io4_hook_init(const struct io4_ops *ops, void *ctx) +HRESULT io4_hook_init( + const struct io4_config *cfg, + const struct io4_ops *ops, + void *ctx) { HRESULT hr; + assert(cfg != NULL); assert(ops != NULL); + if (!cfg->enable) { + return S_FALSE; + } + async_init(&io4_async, NULL); hr = iohook_open_nul_fd(&io4_fd); diff --git a/board/io4.h b/board/io4.h index 1ce7bcf..1a6cc05 100644 --- a/board/io4.h +++ b/board/io4.h @@ -11,6 +11,10 @@ enum { IO4_BUTTON_SERVICE = 1 << 6, }; +struct io4_config { + bool enable; +}; + struct io4_state { uint16_t adcs[8]; uint16_t spinners[4]; @@ -22,4 +26,7 @@ struct io4_ops { HRESULT (*poll)(void *ctx, struct io4_state *state); }; -HRESULT io4_hook_init(const struct io4_ops *ops, void *ctx); +HRESULT io4_hook_init( + const struct io4_config *cfg, + const struct io4_ops *ops, + void *ctx); diff --git a/mu3hook/config.c b/mu3hook/config.c index 0205a3f..aba8cf7 100644 --- a/mu3hook/config.c +++ b/mu3hook/config.c @@ -37,6 +37,7 @@ void mu3_hook_config_load( platform_config_load(&cfg->platform, filename); aime_config_load(&cfg->aime, filename); dvd_config_load(&cfg->dvd, filename); + io4_config_load(&cfg->io4, filename); gfx_config_load(&cfg->gfx, filename); mu3_dll_config_load(&cfg->dll, filename); } diff --git a/mu3hook/config.h b/mu3hook/config.h index 1d31ec5..982a688 100644 --- a/mu3hook/config.h +++ b/mu3hook/config.h @@ -15,6 +15,7 @@ struct mu3_hook_config { struct platform_config platform; struct aime_config aime; struct dvd_config dvd; + struct io4_config io4; struct gfx_config gfx; struct mu3_dll_config dll; }; diff --git a/mu3hook/dllmain.c b/mu3hook/dllmain.c index 6d307de..242c579 100644 --- a/mu3hook/dllmain.c +++ b/mu3hook/dllmain.c @@ -71,7 +71,7 @@ static DWORD CALLBACK mu3_pre_startup(void) goto fail; } - hr = mu3_io4_hook_init(); + hr = mu3_io4_hook_init(&mu3_hook_cfg.io4); if (FAILED(hr)) { goto fail; diff --git a/mu3hook/io4.c b/mu3hook/io4.c index 1fd875a..7edcb0c 100644 --- a/mu3hook/io4.c +++ b/mu3hook/io4.c @@ -16,13 +16,13 @@ static const struct io4_ops mu3_io4_ops = { .poll = mu3_io4_poll, }; -HRESULT mu3_io4_hook_init(void) +HRESULT mu3_io4_hook_init(const struct io4_config *cfg) { HRESULT hr; assert(mu3_dll.init != NULL); - hr = io4_hook_init(&mu3_io4_ops, NULL); + hr = io4_hook_init(cfg, &mu3_io4_ops, NULL); if (FAILED(hr)) { return hr; diff --git a/mu3hook/io4.h b/mu3hook/io4.h index e427d20..acb53b3 100644 --- a/mu3hook/io4.h +++ b/mu3hook/io4.h @@ -2,4 +2,6 @@ #include -HRESULT mu3_io4_hook_init(void); +#include "board/io4.h" + +HRESULT mu3_io4_hook_init(const struct io4_config *cfg);