From 87ecd639a2ea6916bea152be8908c0c6ce15bbea Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Sun, 12 Feb 2023 20:40:41 -0500 Subject: [PATCH] Wacca: Add toggle for LED board hooks --- dist/mercury/segatools.ini | 8 ++++++-- mercuryhook/config.c | 16 ++++++++++++++++ mercuryhook/config.h | 2 ++ mercuryhook/dllmain.c | 2 +- mercuryhook/elisabeth.c | 5 ++++- mercuryhook/elisabeth.h | 7 ++++++- 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/dist/mercury/segatools.ini b/dist/mercury/segatools.ini index 9fc5bba..f231c66 100644 --- a/dist/mercury/segatools.ini +++ b/dist/mercury/segatools.ini @@ -43,10 +43,14 @@ coin=0x24 volup=0x26 voldown=0x28 +; Hooks related to the touch boards [touch] -; Enable or disable touch hook +enable=1 + +; Hooks related to the LED board (codenamed Elisabeth) +[elisabeth] enable=1 ;[mercuryio] ; Use mercuryio.dll -;path=mercuryio.dll \ No newline at end of file +;path=mercuryio.dll diff --git a/mercuryhook/config.c b/mercuryhook/config.c index f0dbb08..f087942 100644 --- a/mercuryhook/config.c +++ b/mercuryhook/config.c @@ -41,6 +41,21 @@ void touch_config_load( filename); } +void elisabeth_config_load( + struct elisabeth_config *cfg, + const wchar_t *filename) +{ + assert(cfg != NULL); + assert(filename != NULL); + + cfg->enable = GetPrivateProfileIntW( + L"elisabeth", + L"enable", + 1, + filename); +} + + void mercury_hook_config_load( struct mercury_hook_config *cfg, const wchar_t *filename) @@ -55,4 +70,5 @@ void mercury_hook_config_load( gfx_config_load(&cfg->gfx, filename); mercury_dll_config_load(&cfg->dll, filename); touch_config_load(&cfg->touch, filename); + elisabeth_config_load(&cfg->elisabeth, filename); } diff --git a/mercuryhook/config.h b/mercuryhook/config.h index cfeb490..d5bf463 100644 --- a/mercuryhook/config.h +++ b/mercuryhook/config.h @@ -9,6 +9,7 @@ #include "mercuryhook/mercury-dll.h" #include "mercuryhook/touch.h" +#include "mercuryhook/elisabeth.h" #include "platform/config.h" @@ -20,6 +21,7 @@ struct mercury_hook_config { struct gfx_config gfx; struct mercury_dll_config dll; struct touch_config touch; + struct elisabeth_config elisabeth; }; void mercury_dll_config_load( diff --git a/mercuryhook/dllmain.c b/mercuryhook/dllmain.c index 611122b..f3df2a7 100644 --- a/mercuryhook/dllmain.c +++ b/mercuryhook/dllmain.c @@ -83,7 +83,7 @@ static DWORD CALLBACK mercury_pre_startup(void) } /* Start elisabeth Hooks for the LED and IO Board DLLs */ - elisabeth_hook_init(); + elisabeth_hook_init(&mercury_hook_cfg.elisabeth); touch_hook_init(&mercury_hook_cfg.touch); diff --git a/mercuryhook/elisabeth.c b/mercuryhook/elisabeth.c index baac575..7078a21 100644 --- a/mercuryhook/elisabeth.c +++ b/mercuryhook/elisabeth.c @@ -33,8 +33,11 @@ static const struct hook_symbol win32_hooks[] = { } }; -HRESULT elisabeth_hook_init() +HRESULT elisabeth_hook_init(struct elisabeth_config *cfg) { + if (!cfg->enable) { + return S_OK; + } dll_hook_insert_hooks(NULL); dprintf("Elisabeth: Init\n"); return S_OK; diff --git a/mercuryhook/elisabeth.h b/mercuryhook/elisabeth.h index 41066fc..5806c99 100644 --- a/mercuryhook/elisabeth.h +++ b/mercuryhook/elisabeth.h @@ -1,8 +1,13 @@ #pragma once +#include struct led_data { DWORD unitCount; uint8_t rgba[480 * 4]; }; -HRESULT elisabeth_hook_init(); +struct elisabeth_config { + bool enable; +}; + +HRESULT elisabeth_hook_init(struct elisabeth_config *cfg);