1
0
mirror of https://gitea.tendokyu.moe/Hay1tsme/segatools.git synced 2024-11-30 19:54:27 +01:00
segatools-hay1tsme/cxbhook/led.c

93 lines
1.8 KiB
C
Raw Normal View History

2022-12-11 23:01:51 +01:00
#include <windows.h>
#include <stdbool.h>
#include <stdint.h>
#include "cxbhook/led.h"
#include "cxbhook/cxb-dll.h"
2023-12-11 02:47:43 +01:00
#include "hook/procaddr.h"
2022-12-11 23:01:51 +01:00
#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)
{
dprintf("LED: Init\n");
2023-12-11 02:47:43 +01:00
return proc_addr_table_push(NULL, "CommLamp.dll", lamp_syms, _countof(lamp_syms));
2022-12-11 23:01:51 +01:00
}
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;
}