diff --git a/cmake/src/main/hook/pro2/CMakeLists.txt b/cmake/src/main/hook/pro2/CMakeLists.txt index 45a1c31..2849c95 100644 --- a/cmake/src/main/hook/pro2/CMakeLists.txt +++ b/cmake/src/main/hook/pro2/CMakeLists.txt @@ -12,4 +12,4 @@ add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES}) set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-fPIC") set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") -target_link_libraries(${PROJECT_NAME} hook-core patch ptapi-io-piuio-util util dl pthread) \ No newline at end of file +target_link_libraries(${PROJECT_NAME} hook-core patch propatch ptapi-io-piuio-util util dl pthread) \ No newline at end of file diff --git a/dist/conf/pro2hook.conf b/dist/conf/pro2hook.conf index 7242f84..22c6957 100644 --- a/dist/conf/pro2hook.conf +++ b/dist/conf/pro2hook.conf @@ -25,6 +25,15 @@ patch.piuio.emu_lib= # [bool (0/1)]: Enable game exit on Test + Service patch.piuio_exit.test_serv=0 +# [str]: Bus and port (format: X-X, e.g. 1-2) of the USB slot to assign to Player 1 when a USB thumb drive is plugged in +patch.usb_profile.p1.bus_port= + +# [str]: Bus and port (format: X-X, e.g. 1-2) of the USB slot to assign to Player 2 when a USB thumb drive is plugged in +patch.usb_profile.p2.bus_port= + +# [str]: Device nodes of plugged in USB thumb drives to consider for mounting for usb profiles, format: sdX,sdY e.g. sde,sdf +patch.usb_profile.dev_nodes= + # [str]: Path to a library implementing the x11-input-handler api to capture X11 keyboard inputs patch_x11_event_loop.input_handler_lib= diff --git a/doc/hook/pro2hook.md b/doc/hook/pro2hook.md index 105ebd7..7c355e2 100644 --- a/doc/hook/pro2hook.md +++ b/doc/hook/pro2hook.md @@ -64,6 +64,15 @@ Each folder with the content from the dump. ## USB thumb drive/profile support See instructions on the [prohook readme](prohook.md#usb-thumb-driveprofile-support). +When using `pro2hook.so`, make sure your `hook.conf` contains the same USB +profile keys used by Pro 1: + +```text +patch.usb_profile.p1.bus_port=2-1 +patch.usb_profile.p2.bus_port=2-2 +patch.usb_profile.dev_nodes=sdb,sdc +``` + ## Troubleshooting and FAQ Since the game is based on Pro 1, have a look at the [troubleshooting section there](19-pro.md#troubleshooting-and-faq). Most of the things listed there diff --git a/src/main/hook/pro2/main.c b/src/main/hook/pro2/main.c index b1ff5f8..22db787 100644 --- a/src/main/hook/pro2/main.c +++ b/src/main/hook/pro2/main.c @@ -19,6 +19,8 @@ #include "hook/patch/usb-init-fix.h" #include "hook/patch/x11-event-loop.h" +#include "hook/propatch/usb-fix.h" + #include "hook/patch/piubtn.h" #include "hook/patch/piuio.h" @@ -160,6 +162,14 @@ static void pro2hook_patch_x11_event_loop_init(struct pro2hook_options *options) } } +static void pro2hook_patch_usbprofiles(struct pro2hook_options *options) +{ + propatch_usb_fix_init( + options->patch.usb_profile.device_nodes, + options->patch.usb_profile.p1_bus_port, + options->patch.usb_profile.p2_bus_port); +} + static void pro2hook_patch_piuio_init(struct pro2hook_options *options) { log_assert(options); @@ -236,6 +246,7 @@ void pro2hook_trap_before_main(int argc, char **argv) pro2hook_fs_redirs_init(&options); pro2hook_patch_sigsegv_init(&options); pro2hook_patch_x11_event_loop_init(&options); + pro2hook_patch_usbprofiles(&options); pro2hook_patch_piuio_init(&options); pro2hook_patch_piubtn_init(&options); pro2hook_patch_secure_binary(); @@ -245,6 +256,7 @@ void pro2hook_trap_before_main(int argc, char **argv) void pro2hook_trap_after_main(void) { + propatch_usb_fix_shutdown(); patch_piubtn_shutdown(); patch_piuio_shutdown(); } diff --git a/src/main/hook/pro2/options.c b/src/main/hook/pro2/options.c index 6e355c1..80c0e76 100644 --- a/src/main/hook/pro2/options.c +++ b/src/main/hook/pro2/options.c @@ -12,6 +12,12 @@ #define PRO2HOOK_OPTIONS_STR_PATCH_PIUIO_EMU_LIB "patch.piuio.emu_lib" #define PRO2HOOK_OPTIONS_STR_PATCH_PIUIO_EXIT_TEST_SERV \ "patch.piuio_exit.test_serv" +#define PRO2HOOK_OPTIONS_STR_PATCH_USB_PROFILE_P1_BUS_PORT \ + "patch.usb_profile.p1.bus_port" +#define PRO2HOOK_OPTIONS_STR_PATCH_USB_PROFILE_P2_BUS_PORT \ + "patch.usb_profile.p2.bus_port" +#define PRO2HOOK_OPTIONS_STR_PATCH_USB_PROFILE_DEV_NODES \ + "patch.usb_profile.dev_nodes" #define PRO2HOOK_OPTIONS_STR_PATCH_X11_EVENT_LOOP_INPUT_HANDLER \ "patch_x11_event_loop.input_handler_lib" #define PRO2HOOK_OPTIONS_STR_PATCH_X11_EVENT_LOOP_INPUT_HANDLER2 \ @@ -94,6 +100,36 @@ const struct util_options_def pro2hook_options_def[] = { .is_secret_data = false, .default_value.b = false, }, + { + .name = PRO2HOOK_OPTIONS_STR_PATCH_USB_PROFILE_P1_BUS_PORT, + .description = "Bus and port (format: X-X, e.g. 1-2) of the USB slot " + "to assign to Player 1 when a USB thumb " + "drive is plugged in", + .param = 'a', + .type = UTIL_OPTIONS_TYPE_STR, + .is_secret_data = false, + .default_value.str = NULL, + }, + { + .name = PRO2HOOK_OPTIONS_STR_PATCH_USB_PROFILE_P2_BUS_PORT, + .description = "Bus and port (format: X-X, e.g. 1-2) of the USB slot " + "to assign to Player 2 when a USB thumb " + "drive is plugged in", + .param = 'k', + .type = UTIL_OPTIONS_TYPE_STR, + .is_secret_data = false, + .default_value.str = NULL, + }, + { + .name = PRO2HOOK_OPTIONS_STR_PATCH_USB_PROFILE_DEV_NODES, + .description = "Device nodes of plugged in USB thumb drives to " + "consider for mounting for usb profiles, format: " + "sdX,sdY e.g. sde,sdf", + .param = 't', + .type = UTIL_OPTIONS_TYPE_STR, + .is_secret_data = false, + .default_value.str = NULL, + }, { .name = PRO2HOOK_OPTIONS_STR_PATCH_X11_EVENT_LOOP_INPUT_HANDLER, .description = "Path to a library implementing the x11-input-handler " @@ -172,6 +208,12 @@ bool pro2hook_options_init( options_opt, PRO2HOOK_OPTIONS_STR_PATCH_PIUIO_EMU_LIB); options->patch.piuio.exit_test_serv = util_options_get_bool( options_opt, PRO2HOOK_OPTIONS_STR_PATCH_PIUIO_EXIT_TEST_SERV); + options->patch.usb_profile.device_nodes = util_options_get_str( + options_opt, PRO2HOOK_OPTIONS_STR_PATCH_USB_PROFILE_DEV_NODES); + options->patch.usb_profile.p1_bus_port = util_options_get_str( + options_opt, PRO2HOOK_OPTIONS_STR_PATCH_USB_PROFILE_P1_BUS_PORT); + options->patch.usb_profile.p2_bus_port = util_options_get_str( + options_opt, PRO2HOOK_OPTIONS_STR_PATCH_USB_PROFILE_P2_BUS_PORT); options->patch.x11_event_loop.api_lib = util_options_get_str( options_opt, PRO2HOOK_OPTIONS_STR_PATCH_X11_EVENT_LOOP_INPUT_HANDLER); options->patch.x11_event_loop.api_lib2 = util_options_get_str( diff --git a/src/main/hook/pro2/options.h b/src/main/hook/pro2/options.h index b9a8df6..61c85fc 100644 --- a/src/main/hook/pro2/options.h +++ b/src/main/hook/pro2/options.h @@ -29,6 +29,12 @@ struct pro2hook_options { bool exit_test_serv; } piuio; + struct usb_profile { + const char *device_nodes; + const char *p1_bus_port; + const char *p2_bus_port; + } usb_profile; + struct x11_event_loop { const char *api_lib; const char *api_lib2;