mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-28 02:56:36 -04:00
TCP input injection for port 2 (set_input/press/clear_input port=2)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 66cc81fe63)
This commit is contained in:
@@ -6878,6 +6878,18 @@ static PadExtHooks pad_ext_main_hooks(void) {
|
||||
return h;
|
||||
}
|
||||
|
||||
/* TCP port-2 injection (set_input/press "port":2): a digital pad plugged
|
||||
* into port 2 for as long as a test drives it, so headless runs can reach and
|
||||
* play two-player modes. Applied after the normal sampling so it wins. */
|
||||
static void apply_input_override_port2(int override_word) {
|
||||
if (override_word < 0) return;
|
||||
if (!sio_get_pad_connected(1)) {
|
||||
sio_set_pad_connected(1, 1);
|
||||
sio_set_pad_analog(1, 0, 0x80, 0x80, 0x80, 0x80);
|
||||
}
|
||||
sio_set_pad_state_slot(1, (uint16_t)override_word);
|
||||
}
|
||||
|
||||
static void sample_pad_into_sio(int override) {
|
||||
/* Selfcheck fighter mash owns P1 when enabled (headless-safe). */
|
||||
if (override < 0) {
|
||||
@@ -8098,12 +8110,14 @@ static NetplayVblankEpilogue sdl_vblank_present_body(void) {
|
||||
|
||||
/* Check debug server input override. */
|
||||
int override = debug_server_get_input_override();
|
||||
int override_p2 = debug_server_get_input_override_port2();
|
||||
#else
|
||||
/* Production: skip debug server. Still need to advance frame counter
|
||||
* locally so anything else that reads it continues to work. */
|
||||
extern uint64_t s_frame_count;
|
||||
s_frame_count++;
|
||||
int override = -1;
|
||||
int override_p2 = -1;
|
||||
#endif
|
||||
|
||||
psx_local_mouse_begin(sdl_window, local_mouse_live(override));
|
||||
@@ -8299,6 +8313,7 @@ static NetplayVblankEpilogue sdl_vblank_present_body(void) {
|
||||
sample_headless_pad_into_sio(override);
|
||||
else
|
||||
sample_pad_into_sio(override);
|
||||
apply_input_override_port2(override_p2);
|
||||
}
|
||||
/* Offline vblank boundary: record/replay/compare (PSX_RB_SELFCHECK).
|
||||
* Defer opening a window while multitap arming is still pending —
|
||||
@@ -8629,6 +8644,7 @@ static NetplayVblankEpilogue sdl_vblank_present_body(void) {
|
||||
SDL_PumpEvents(); // retain native timing when no policy exists
|
||||
}
|
||||
sample_pad_into_sio(override);
|
||||
apply_input_override_port2(override_p2);
|
||||
latency_ring_restamp_input();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user