chunihook/slider.c: Add config

This commit is contained in:
Tau 2019-10-19 20:37:43 -04:00
parent b270eaf1c6
commit d31d13e0da
5 changed files with 32 additions and 4 deletions

View File

@ -1,6 +1,7 @@
#include <windows.h>
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include "amex/config.h"
@ -11,6 +12,14 @@
#include "platform/config.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 chuni_hook_config_load(
struct chuni_hook_config *cfg,
const wchar_t *filename)
@ -23,4 +32,5 @@ void chuni_hook_config_load(
nu_config_load(&cfg->nu, filename);
amex_config_load(&cfg->amex, filename);
gfx_config_load(&cfg->gfx, filename);
slider_config_load(&cfg->slider, filename);
}

View File

@ -1,5 +1,6 @@
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include "amex/config.h"
@ -8,12 +9,18 @@
#include "platform/config.h"
struct slider_config {
bool enable;
};
struct chuni_hook_config {
struct nu_config nu;
struct amex_config amex;
struct gfx_config gfx;
struct slider_config slider;
};
void slider_config_load(struct slider_config *cfg, const wchar_t *filename);
void chuni_hook_config_load(
struct chuni_hook_config *cfg,
const wchar_t *filename);

View File

@ -59,7 +59,7 @@ static DWORD CALLBACK chuni_pre_startup(void)
chunithm_jvs_init();
}
slider_hook_init();
slider_hook_init(&chuni_hook_cfg.slider);
/* Initialize debug helpers */

View File

@ -9,6 +9,7 @@
#include "board/slider-cmd.h"
#include "board/slider-frame.h"
#include "chunihook/config.h"
#include "chunihook/slider.h"
#include "chuniio/chuniio.h"
@ -38,8 +39,14 @@ static struct uart slider_uart;
static uint8_t slider_written_bytes[520];
static uint8_t slider_readable_bytes[520];
void 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, 1);
@ -48,7 +55,7 @@ void slider_hook_init(void)
slider_uart.readable.bytes = slider_readable_bytes;
slider_uart.readable.nbytes = sizeof(slider_readable_bytes);
iohook_push_handler(slider_handle_irp);
return iohook_push_handler(slider_handle_irp);
}
static HRESULT slider_handle_irp(struct irp *irp)

View File

@ -1,3 +1,7 @@
#pragma once
void slider_hook_init(void);
#include <windows.h>
#include "chunihook/config.h"
HRESULT slider_hook_init(const struct slider_config *cfg);