1
0
mirror of https://gitea.tendokyu.moe/Dniel97/segatools.git synced 2024-11-27 22:40:48 +01:00

Merge branch 'master' into 'master'

Add led support for mercuryio.dll

See merge request Hay1tsme/segatools!2
This commit is contained in:
Hay1tsme 2022-07-31 18:11:24 +00:00
commit 2fb04ce08f
11 changed files with 61 additions and 0 deletions

View File

@ -34,6 +34,7 @@ $(BUILD_DIR_ZIP)/mercury.zip:
$(V)mkdir -p $(BUILD_DIR_ZIP)/mercury/DEVICE $(V)mkdir -p $(BUILD_DIR_ZIP)/mercury/DEVICE
$(V)cp $(BUILD_DIR_64)/subprojects/capnhook/inject/inject.exe \ $(V)cp $(BUILD_DIR_64)/subprojects/capnhook/inject/inject.exe \
$(BUILD_DIR_64)/mercuryhook/mercuryhook.dll \ $(BUILD_DIR_64)/mercuryhook/mercuryhook.dll \
$(BUILD_DIR_64)/mercuryio/mercuryio.dll \
$(DIST_DIR)/mercury/segatools.ini \ $(DIST_DIR)/mercury/segatools.ini \
$(DIST_DIR)/mercury/start.bat \ $(DIST_DIR)/mercury/start.bat \
$(BUILD_DIR_ZIP)/mercury $(BUILD_DIR_ZIP)/mercury

View File

@ -43,3 +43,10 @@ coin=0x24
volup=0x26 volup=0x26
voldown=0x28 voldown=0x28
[touch]
; Enable or disable touch hook
enable=1
;[mercuryio]
; Use mercuryio.dll
;path=mercuryio.dll

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 my_GetProcAddress(HMODULE hModule, const char *name);
static FARPROC (WINAPI *next_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_Init();
static int my_USBIntLED_set();
static const struct hook_symbol win32_hooks[] = { 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) { if (strcmp(name, "USBIntLED_Init") == 0) {
result = (FARPROC) my_USBIntLED_Init; result = (FARPROC) my_USBIntLED_Init;
} }
if (strcmp(name, "USBIntLED_set") == 0) {
result = (FARPROC) my_USBIntLED_set;
}
} }
return result; return result;
@ -70,3 +75,10 @@ static int my_USBIntLED_Init()
dprintf("Elisabeth: my_USBIntLED_Init hit!\n"); dprintf("Elisabeth: my_USBIntLED_Init hit!\n");
return 1; 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 #pragma once
struct led_data {
DWORD unitCount;
uint8_t rgba[480 * 4];
};
HRESULT elisabeth_hook_init(); HRESULT elisabeth_hook_init();

View File

@ -27,6 +27,9 @@ const struct dll_bind_sym mercury_dll_syms[] = {
}, { }, {
.sym = "mercury_io_touch_start", .sym = "mercury_io_touch_start",
.off = offsetof(struct mercury_dll, 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 <windows.h>
#include "mercuryio/mercuryio.h" #include "mercuryio/mercuryio.h"
#include "mercuryhook/elisabeth.h"
struct mercury_dll { struct mercury_dll {
uint16_t api_version; uint16_t api_version;
@ -12,6 +13,7 @@ struct mercury_dll {
void (*get_gamebtns)(uint8_t *gamebtn); void (*get_gamebtns)(uint8_t *gamebtn);
HRESULT (*touch_init)(void); HRESULT (*touch_init)(void);
void (*touch_start)(mercury_io_touch_callback_t callback); void (*touch_start)(mercury_io_touch_callback_t callback);
void (*set_leds)(struct led_data data);
}; };
struct mercury_dll_config { struct mercury_dll_config {

View File

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

View File

@ -6,6 +6,7 @@
#include "mercuryio/mercuryio.h" #include "mercuryio/mercuryio.h"
#include "mercuryio/config.h" #include "mercuryio/config.h"
#include "mercuryhook/elisabeth.h"
static unsigned int __stdcall mercury_io_touch_thread_proc(void *ctx); static unsigned int __stdcall mercury_io_touch_thread_proc(void *ctx);
@ -90,6 +91,11 @@ void mercury_io_touch_start(mercury_io_touch_callback_t callback)
); );
} }
void mercury_io_touch_set_leds(struct led_data data)
{
}
static unsigned int __stdcall mercury_io_touch_thread_proc(void *ctx) static unsigned int __stdcall mercury_io_touch_thread_proc(void *ctx)
{ {
mercury_io_touch_callback_t callback; mercury_io_touch_callback_t callback;

11
mercuryio/mercuryio.def Normal file
View File

@ -0,0 +1,11 @@
LIBRARY mercuryio
EXPORTS
mercury_io_get_api_version
mercury_io_init
mercury_io_poll
mercury_io_get_opbtns
mercury_io_get_gamebtns
mercury_io_touch_init
mercury_io_touch_start
mercury_io_touch_set_leds

View File

@ -4,6 +4,8 @@
#include <stdint.h> #include <stdint.h>
#include "mercuryhook/elisabeth.h"
enum { enum {
MERCURY_IO_OPBTN_TEST = 0x01, MERCURY_IO_OPBTN_TEST = 0x01,
MERCURY_IO_OPBTN_SERVICE = 0x02, MERCURY_IO_OPBTN_SERVICE = 0x02,
@ -64,3 +66,5 @@ void mercury_io_get_gamebtns(uint8_t *gamebtn);
HRESULT mercury_io_touch_init(void); HRESULT mercury_io_touch_init(void);
void mercury_io_touch_start(mercury_io_touch_callback_t callback); void mercury_io_touch_start(mercury_io_touch_callback_t callback);
void mercury_io_touch_set_leds(struct led_data data);

View File

@ -11,3 +11,12 @@ mercuryio_lib = static_library(
'config.h', 'config.h',
], ],
) )
shared_library(
'mercuryio',
name_prefix : '',
vs_module_defs : 'mercuryio.def',
link_with : [
mercuryio_lib,
],
)