From d32f6ab18b179fffaed7398a4160a23489dcba91 Mon Sep 17 00:00:00 2001 From: 5d3b9130281102eb36519ddd0a2c6868ff061a3b <5d3b9130281102eb36519ddd0a2c6868ff061a3b@redacted> Date: Sun, 29 Dec 2019 13:28:32 -0400 Subject: [PATCH] divahook: Add an option to disable slider emulation --- divahook/config.c | 8 ++++++++ divahook/config.h | 4 ++++ divahook/dllmain.c | 2 +- divahook/slider.c | 7 ++++++- divahook/slider.h | 8 +++++++- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/divahook/config.c b/divahook/config.c index 1b52c3e..e639874 100644 --- a/divahook/config.c +++ b/divahook/config.c @@ -12,6 +12,13 @@ #include "platform/config.h" #include "platform/platform.h" +void slider_config_load(struct slider_config *cfg, const wchar_t *filename) { + assert(cfg != NULL); + assert(filename != NULL); + + cfg->enable = GetPrivateProfileIntW(L"slider", L"enable", 1, filename); +} + void diva_hook_config_load( struct diva_hook_config *cfg, const wchar_t *filename) @@ -22,4 +29,5 @@ void diva_hook_config_load( platform_config_load(&cfg->platform, filename); amex_config_load(&cfg->amex, filename); aime_config_load(&cfg->aime, filename); + slider_config_load(&cfg->slider, filename); } diff --git a/divahook/config.h b/divahook/config.h index c7ca22f..3e484d5 100644 --- a/divahook/config.h +++ b/divahook/config.h @@ -6,14 +6,18 @@ #include "board/sg-reader.h" +#include "divahook/slider.h" + #include "platform/platform.h" struct diva_hook_config { struct platform_config platform; struct amex_config amex; struct aime_config aime; + struct slider_config slider; }; +void slider_config_load(struct slider_config *cfg, const wchar_t *filename); void diva_hook_config_load( struct diva_hook_config *cfg, const wchar_t *filename); diff --git a/divahook/dllmain.c b/divahook/dllmain.c index a194f84..1a6449a 100644 --- a/divahook/dllmain.c +++ b/divahook/dllmain.c @@ -63,7 +63,7 @@ static DWORD CALLBACK diva_pre_startup(void) return EXIT_FAILURE; } - hr = slider_hook_init(); + hr = slider_hook_init(&diva_hook_cfg.slider); if (FAILED(hr)) { return EXIT_FAILURE; diff --git a/divahook/slider.c b/divahook/slider.c index fe114cb..cc1273d 100644 --- a/divahook/slider.c +++ b/divahook/slider.c @@ -37,8 +37,13 @@ static struct uart slider_uart; static uint8_t slider_written_bytes[520]; static uint8_t slider_readable_bytes[520]; -HRESULT slider_hook_init(void) +HRESULT slider_hook_init(const struct slider_config *cfg) { + assert(cfg != NULL); + if (!cfg->enable) { + return S_FALSE; + } + InitializeCriticalSection(&slider_lock); uart_init(&slider_uart, 11); diff --git a/divahook/slider.h b/divahook/slider.h index 08fe430..7053e04 100644 --- a/divahook/slider.h +++ b/divahook/slider.h @@ -2,4 +2,10 @@ #include -HRESULT slider_hook_init(void); +#include + +struct slider_config { + bool enable; +}; + +HRESULT slider_hook_init(const struct slider_config *cfg);