segatools/cxbhook/led.c

99 lines
1.9 KiB
C
Raw Permalink Normal View History

#include <windows.h>
#include <stdbool.h>
#include <stdint.h>
#include "cxbhook/led.h"
#include "cxbhook/cxb-dll.h"
#include "hook/procaddr.h"
#include "hook/table.h"
#include "util/dprintf.h"
static int my_cCommLamp_Open(char *port);
static void my_cCommLamp_Close();
static int my_cCommLamp_Setup(int led_id);
static int my_cCommLamp_SetColor(int led_id, int color);
static int my_cCommLamp_Update();
static int my_cCommLamp_UpdateDelta(float delta);
static struct hook_symbol lamp_syms[] = {
{
.name = "cCommLamp_Open",
.patch = my_cCommLamp_Open
},
{
.name = "cCommLamp_Close",
.patch = my_cCommLamp_Close
},
{
.name = "cCommLamp_Setup",
.patch = my_cCommLamp_Setup,
},
{
.name = "cCommLamp_SetColor",
.patch = my_cCommLamp_SetColor
},
{
.name = "cCommLamp_Update",
.patch = my_cCommLamp_Update
},
{
.name = "cCommLamp_UpdateDelta",
.patch = my_cCommLamp_UpdateDelta
},
};
HRESULT led_hook_init(struct led_config *cfg)
{
assert(cfg != NULL);
if (!cfg->enable) {
return S_FALSE;
}
dprintf("LED: Hook enabled.\n");
return proc_addr_table_push(NULL, "CommLamp.dll", lamp_syms, _countof(lamp_syms));
}
static int my_cCommLamp_Open(char *port)
{
HRESULT hr = cxb_dll.led_init();
dprintf("LED: Open %s (DLL init result %lx)\n", port, hr);
if (FAILED(hr)) {
return 0;
}
return 1;
}
static void my_cCommLamp_Close()
{
dprintf("LED: Close\n");
}
static int my_cCommLamp_Setup(int led_id)
{
dprintf("LED: Setup %d\n", led_id);
return 0;
}
static int my_cCommLamp_SetColor(int led_id, int color)
{
cxb_dll.led_update(led_id, color);
return 1;
}
static int my_cCommLamp_Update()
{
return 0;
}
static int my_cCommLamp_UpdateDelta(float delta)
{
return 0;
2022-12-11 22:01:51 +00:00
}