Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/src/main/hook/pro2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
target_link_libraries(${PROJECT_NAME} hook-core patch propatch ptapi-io-piuio-util util dl pthread)
9 changes: 9 additions & 0 deletions dist/conf/pro2hook.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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=

Expand Down
9 changes: 9 additions & 0 deletions doc/hook/pro2hook.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/main/hook/pro2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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();
}
Expand Down
42 changes: 42 additions & 0 deletions src/main/hook/pro2/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions src/main/hook/pro2/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down