From 599d5e321162b0f68916ac1b6ac2d0b0493ef2e5 Mon Sep 17 00:00:00 2001 From: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:25:19 +0200 Subject: [PATCH] kemono: fix LED hooking, add button LEDs --- kemonohook/hooks.c | 6 ++++++ kemonohook/jvs.c | 6 ++++++ kemonohook/kemono-dll.c | 4 ++++ kemonohook/kemono-dll.h | 2 ++ kemonohook/kemonohook.def | 1 + kemonoio/kemonoio.c | 5 +++++ kemonoio/kemonoio.h | 21 ++++++++++++++++++--- 7 files changed, 42 insertions(+), 3 deletions(-) diff --git a/kemonohook/hooks.c b/kemonohook/hooks.c index 51fc0d0..bdce643 100644 --- a/kemonohook/hooks.c +++ b/kemonohook/hooks.c @@ -21,6 +21,12 @@ static const struct hook_symbol kemono_kernel32_syms[] = { }; void kemono_extra_hooks_init(){ + HMODULE serialportapi = LoadLibraryA("Parade_Data/Plugins/SerialPortAPI.dll"); // HACK?? + if (serialportapi != NULL){ + iohook_apply_hooks(serialportapi); + serial_hook_apply_hooks(serialportapi); + dprintf("Kemono: Successfully pre-loaded SerialPortAPI\n"); + } } void kemono_extra_hooks_load(HMODULE mod, const wchar_t* target_module) { diff --git a/kemonohook/jvs.c b/kemonohook/jvs.c index ae9f0f8..0b10d3c 100644 --- a/kemonohook/jvs.c +++ b/kemonohook/jvs.c @@ -25,10 +25,12 @@ static void kemono_jvs_read_coin_counter( void *ctx, uint8_t slot_no, uint16_t *out); +static void kemono_jvs_write_gpio(void *ctx, uint32_t state); static const struct io3_ops kemono_jvs_io3_ops = { .read_switches = kemono_jvs_read_switches, .read_coin_counter = kemono_jvs_read_coin_counter, + .write_gpio = kemono_jvs_write_gpio }; static struct io3 kemono_jvs_io3; @@ -131,3 +133,7 @@ static void kemono_jvs_read_coin_counter( kemono_dll.jvs_read_coin_counter(out); } + +static void kemono_jvs_write_gpio(void *ctx, uint32_t state){ + kemono_dll.jvs_write_gpio(state); +} \ No newline at end of file diff --git a/kemonohook/kemono-dll.c b/kemonohook/kemono-dll.c index 8fbb447..004cf50 100644 --- a/kemonohook/kemono-dll.c +++ b/kemonohook/kemono-dll.c @@ -28,6 +28,10 @@ const struct dll_bind_sym kemono_dll_syms[] = { { .sym = "kemono_io_led_set_colors", .off = offsetof(struct kemono_dll, led_set_leds), + }, + { + .sym = "kemono_io_jvs_write_gpio", + .off = offsetof(struct kemono_dll, jvs_write_gpio), } }; diff --git a/kemonohook/kemono-dll.h b/kemonohook/kemono-dll.h index 3ab7506..df676f0 100644 --- a/kemonohook/kemono-dll.h +++ b/kemonohook/kemono-dll.h @@ -16,6 +16,8 @@ struct kemono_dll { HRESULT (*led_init)(void); void (*led_set_leds)(uint8_t board, uint8_t *rgb); + + void (*jvs_write_gpio)(uint32_t state); }; struct kemono_dll_config { diff --git a/kemonohook/kemonohook.def b/kemonohook/kemonohook.def index c28d512..601a00b 100644 --- a/kemonohook/kemonohook.def +++ b/kemonohook/kemonohook.def @@ -17,6 +17,7 @@ EXPORTS kemono_io_poll kemono_io_led_init kemono_io_led_set_colors + kemono_io_jvs_write_gpio fwdlusb_open fwdlusb_close fwdlusb_listupPrinter diff --git a/kemonoio/kemonoio.c b/kemonoio/kemonoio.c index 8d4033c..5b24c28 100644 --- a/kemonoio/kemonoio.c +++ b/kemonoio/kemonoio.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "kemonoio/kemonoio.h" #include "kemonoio/config.h" @@ -101,4 +102,8 @@ HRESULT kemono_io_led_init(void) { void kemono_io_led_set_colors(uint8_t board, uint8_t *rgb) { +} + +void kemono_io_jvs_write_gpio(uint32_t state){ + } \ No newline at end of file diff --git a/kemonoio/kemonoio.h b/kemonoio/kemonoio.h index 5969158..3b180e2 100644 --- a/kemonoio/kemonoio.h +++ b/kemonoio/kemonoio.h @@ -57,10 +57,25 @@ void kemono_io_jvs_read_coin_counter(uint16_t *out); All subsequent calls may originate from arbitrary threads and some may overlap with each other. Ensuring synchronization inside your IO DLL is - your responsibility. */ + your responsibility. + + Minimum API version: 0x0100 */ HRESULT kemono_io_led_init(void); /* Update the RGB LEDs. - Exact layout is TBD. */ -void kemono_io_led_set_colors(uint8_t board, uint8_t *rgb); \ No newline at end of file + The left side LED bar are indices 0 to 32. + The right side LED bar are indices 33 to 65. + + Minimum API version: 0x0100 */ +void kemono_io_led_set_colors(uint8_t board, uint8_t *rgb); + +/* Update the button LEDs. + + Button R: Bit 15 + Button G: Bit 1 + Button B: Bit 13 + Start Button: Bit 11 + + Minimum API version: 0x0100 */ +void kemono_io_jvs_write_gpio(uint32_t state); \ No newline at end of file