From 28633ded37af4e3905312757d29cd01a939f528e Mon Sep 17 00:00:00 2001 From: 95c6cd771e00602e3ec82fccba1b3741fdb7f7ca <95c6cd771e00602e3ec82fccba1b3741fdb7f7ca@redacted> Date: Fri, 13 May 2022 19:26:00 +0000 Subject: [PATCH] jbhook2 and jbhook3 gfx updates - Fix jbhook3 window mode - Remove -f option for framed window, no value - Add -s option to show mouse cursor on window --- src/main/jbhook2/dllmain.c | 4 +++ src/main/jbhook2/options.c | 15 ++++---- src/main/jbhook2/options.h | 2 +- src/main/jbhook3/Module.mk | 1 + src/main/jbhook3/dllmain.c | 16 +++++++-- src/main/jbhook3/gfx.c | 73 ++++++++++++++++++++++++++++++++++++++ src/main/jbhook3/gfx.h | 3 ++ src/main/jbhook3/options.c | 16 ++++----- src/main/jbhook3/options.h | 2 +- 9 files changed, 113 insertions(+), 19 deletions(-) create mode 100644 src/main/jbhook3/gfx.c create mode 100644 src/main/jbhook3/gfx.h diff --git a/src/main/jbhook2/dllmain.c b/src/main/jbhook2/dllmain.c index e25f15b..898d2ce 100644 --- a/src/main/jbhook2/dllmain.c +++ b/src/main/jbhook2/dllmain.c @@ -199,6 +199,10 @@ static HWND CDECL my_mwindow_create( window_height = tmp; } + if(options.show_cursor) { + ShowCursor(TRUE); + } + fullscreen = !options.windowed; return real_mwindow_create( diff --git a/src/main/jbhook2/options.c b/src/main/jbhook2/options.c index 7b6959f..9e1987e 100644 --- a/src/main/jbhook2/options.c +++ b/src/main/jbhook2/options.c @@ -34,10 +34,10 @@ void options_init_from_cmdline(struct options *options) void options_init(struct options *options) { options->windowed = false; - options->window_framed = false; options->disable_p3ioemu = false; options->disable_cardemu = false; options->disable_adapteremu = false; + options->show_cursor = false; } bool options_read_cmdline(struct options *options, int argc, const char **argv) @@ -60,11 +60,6 @@ bool options_read_cmdline(struct options *options, int argc, const char **argv) break; } - case 'f': { - options->window_framed = true; - break; - } - case 'v': { options->vertical = true; break; @@ -84,6 +79,11 @@ bool options_read_cmdline(struct options *options, int argc, const char **argv) options->disable_p3ioemu = true; break; } + + case 's': { + options->show_cursor = true; + break; + } } } @@ -106,7 +106,8 @@ void options_print_usage(void) " -c Disable card emulation (e.g. when running on a " "real cab)\n" " -p Disable p3io emulation (e.g. when running on a " - "real cab)\n"); + "real cab)\n" + " -s Show mouse cursor on game window\n"); } void options_fini(struct options *options) diff --git a/src/main/jbhook2/options.h b/src/main/jbhook2/options.h index 01965c4..ecc92b4 100644 --- a/src/main/jbhook2/options.h +++ b/src/main/jbhook2/options.h @@ -6,11 +6,11 @@ struct options { bool windowed; - bool window_framed; bool vertical; bool disable_p3ioemu; bool disable_cardemu; bool disable_adapteremu; + bool show_cursor; }; void options_init_from_cmdline(struct options *options); diff --git a/src/main/jbhook3/Module.mk b/src/main/jbhook3/Module.mk index 1f504e8..a82c4cc 100644 --- a/src/main/jbhook3/Module.mk +++ b/src/main/jbhook3/Module.mk @@ -22,4 +22,5 @@ libs_jbhook3 := \ src_jbhook3 := \ dllmain.c \ + gfx.c \ options.c diff --git a/src/main/jbhook3/dllmain.c b/src/main/jbhook3/dllmain.c index 60ad183..9666412 100644 --- a/src/main/jbhook3/dllmain.c +++ b/src/main/jbhook3/dllmain.c @@ -9,6 +9,7 @@ #include "bemanitools/jbio.h" #include "hook/iohook.h" +#include "hook/table.h" #include "hooklib/adapter.h" #include "hooklib/app.h" @@ -17,6 +18,7 @@ #include "imports/avs.h" +#include "jbhook3/gfx.h" #include "jbhook3/options.h" #include "jbhook-util/acio.h" @@ -47,6 +49,16 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param) iohook_push_handler(p4ioemu_dispatch_irp); iohook_push_handler(jbhook_util_ac_io_port_dispatch_irp); + jbhook3_gfx_init(); + + if(options.windowed) { + jbhook3_gfx_set_windowed(); + } + + if(options.show_cursor) { + jbhook3_gfx_set_show_cursor(); + } + if (!options.disable_p4ioemu) { log_info("Starting up jubeat IO backend"); @@ -119,7 +131,7 @@ static bool my_dll_entry_main(void) if (!options.disable_p4ioemu) { p4ioemu_fini(); } - + options_fini(&options); return result; @@ -141,7 +153,7 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx) if (!options.disable_adapteremu) { adapter_hook_init(); } - + jbhook_util_eamuse_hook_init(); return TRUE; diff --git a/src/main/jbhook3/gfx.c b/src/main/jbhook3/gfx.c new file mode 100644 index 0000000..d0850ab --- /dev/null +++ b/src/main/jbhook3/gfx.c @@ -0,0 +1,73 @@ +#define LOG_MODULE "jbhook-gfx" + +#include +#include +#include +#include + +#include "hook/table.h" + +#include "jbhook3/options.h" + +#include "util/log.h" + +static bool jbhook3_gfx_windowed; +static bool jbhook3_gfx_show_cursor; + +void jbhook3_gfx_set_windowed(void) +{ + jbhook3_gfx_windowed = true; +} + +void jbhook3_gfx_set_show_cursor(void) +{ + jbhook3_gfx_show_cursor = true; +} + +static HWND CDECL my_GFWin32MainWindowRun( + HINSTANCE, + const char *, + long, + long, + DWORD); + +static HWND(CDECL *real_GFWin32MainWindowRun)( + HINSTANCE, + const char *, + long, + long, + DWORD); + +static const struct hook_symbol init_hook_syms[] = { + {.name = "GFWin32MainWindowRun", + .patch = my_GFWin32MainWindowRun, + .link = (void **) &real_GFWin32MainWindowRun,}, +}; + +static HWND CDECL my_GFWin32MainWindowRun( + HINSTANCE hInstance, + const char *lpWindowName, + long X, + long Y, + DWORD dwStyle + ) +{ + if(jbhook3_gfx_windowed) { + log_info("--- Begin jbhook GFWin32MainWindowRun ---"); + dwStyle |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE; + } + + if(jbhook3_gfx_show_cursor) { + ShowCursor(TRUE); + } + + return real_GFWin32MainWindowRun(hInstance, lpWindowName, X, Y, dwStyle); +} + +void jbhook3_gfx_init(void) +{ + hook_table_apply( + NULL, "gftools.dll", init_hook_syms, lengthof(init_hook_syms)); + + log_info("Inserted gfx hooks"); +} \ No newline at end of file diff --git a/src/main/jbhook3/gfx.h b/src/main/jbhook3/gfx.h new file mode 100644 index 0000000..34e3ba0 --- /dev/null +++ b/src/main/jbhook3/gfx.h @@ -0,0 +1,3 @@ +void jbhook3_gfx_init(void); +void jbhook3_gfx_set_windowed(void); +void jbhook3_gfx_set_show_cursor(void); \ No newline at end of file diff --git a/src/main/jbhook3/options.c b/src/main/jbhook3/options.c index ff11021..8204328 100644 --- a/src/main/jbhook3/options.c +++ b/src/main/jbhook3/options.c @@ -34,10 +34,10 @@ void options_init_from_cmdline(struct options *options) void options_init(struct options *options) { options->windowed = false; - options->window_framed = false; options->disable_p4ioemu = false; options->disable_cardemu = false; options->disable_adapteremu = false; + options->show_cursor = false; } bool options_read_cmdline(struct options *options, int argc, const char **argv) @@ -60,11 +60,6 @@ bool options_read_cmdline(struct options *options, int argc, const char **argv) break; } - case 'f': { - options->window_framed = true; - break; - } - case 'a': { options->disable_adapteremu = true; break; @@ -79,6 +74,11 @@ bool options_read_cmdline(struct options *options, int argc, const char **argv) options->disable_p4ioemu = true; break; } + + case 's': { + options->show_cursor = true; + break; + } } } @@ -95,13 +95,13 @@ void options_print_usage(void) "\n" " -h Print this usage message\n" " -w Run the game windowed\n" - " -f Run the game in a framed window (needs -w option)\n" " -a Disable adapter hook\n" " -c Disable card emulation (e.g. when running on a " "real cab)\n" " -p Disable p4io emulation (e.g. when running on a " "real cab or on a bare " - "p4io)\n"); + "p4io)\n" + " -s Show mouse cursor on game window\n"); } void options_fini(struct options *options) diff --git a/src/main/jbhook3/options.h b/src/main/jbhook3/options.h index 840318d..a9a5e0d 100644 --- a/src/main/jbhook3/options.h +++ b/src/main/jbhook3/options.h @@ -6,10 +6,10 @@ struct options { bool windowed; - bool window_framed; bool disable_p4ioemu; bool disable_cardemu; bool disable_adapteremu; + bool show_cursor; }; void options_init_from_cmdline(struct options *options);