Add led support for mercuryio.dll

This commit is contained in:
2022-07-31 18:11:24 +00:00
committed by Hay1tsme
parent 799f6f889d
commit 729a7ec280
11 changed files with 61 additions and 0 deletions

View File

@ -23,6 +23,7 @@ static void dll_hook_insert_hooks(HMODULE target);
static FARPROC WINAPI my_GetProcAddress(HMODULE hModule, const char *name);
static FARPROC (WINAPI *next_GetProcAddress)(HMODULE hModule, const char *name);
static int my_USBIntLED_Init();
static int my_USBIntLED_set();
static const struct hook_symbol win32_hooks[] = {
{
@ -59,6 +60,10 @@ FARPROC WINAPI my_GetProcAddress(HMODULE hModule, const char *name)
if (strcmp(name, "USBIntLED_Init") == 0) {
result = (FARPROC) my_USBIntLED_Init;
}
if (strcmp(name, "USBIntLED_set") == 0) {
result = (FARPROC) my_USBIntLED_set;
}
}
return result;
@ -70,3 +75,10 @@ static int my_USBIntLED_Init()
dprintf("Elisabeth: my_USBIntLED_Init hit!\n");
return 1;
}
static int my_USBIntLED_set(int data1, struct led_data data2)
{
assert(mercury_dll.set_leds != NULL);
mercury_dll.set_leds(data2);
return 1;
}

View File

@ -1,3 +1,8 @@
#pragma once
struct led_data {
DWORD unitCount;
uint8_t rgba[480 * 4];
};
HRESULT elisabeth_hook_init();

View File

@ -27,6 +27,9 @@ const struct dll_bind_sym mercury_dll_syms[] = {
}, {
.sym = "mercury_io_touch_start",
.off = offsetof(struct mercury_dll, touch_start),
}, {
.sym = "mercury_io_touch_set_leds",
.off = offsetof(struct mercury_dll, set_leds),
}
};

View File

@ -3,6 +3,7 @@
#include <windows.h>
#include "mercuryio/mercuryio.h"
#include "mercuryhook/elisabeth.h"
struct mercury_dll {
uint16_t api_version;
@ -12,6 +13,7 @@ struct mercury_dll {
void (*get_gamebtns)(uint8_t *gamebtn);
HRESULT (*touch_init)(void);
void (*touch_start)(mercury_io_touch_callback_t callback);
void (*set_leds)(struct led_data data);
};
struct mercury_dll_config {

View File

@ -16,5 +16,6 @@ EXPORTS
mercury_io_get_opbtns
mercury_io_touch_init
mercury_io_touch_start
mercury_io_touch_set_leds
mercury_io_init
mercury_io_poll