mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 02:11:36 -04:00
e21226feb7
psx_host_set_input_sink: an overlay provider sees host SDL events first, in the event drain and the host pause loop, and may consume them. psx_host_set_ui_capture: while on, local game input reads released and centred (netplay included, so peers receive "nothing pressed") and the external-input gate stays closed. Debug builds gain host_key, which pushes a real SDL key event for scripted runs. Inert without a provider. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
3.1 KiB
C
64 lines
3.1 KiB
C
/* host_overlay.h -- hooks for an optional in-game menu ("overlay provider").
|
|
*
|
|
* Every hook is inert until something registers with it: a title with no
|
|
* overlay provider runs exactly as before. Sections are added by the
|
|
* docs/IN_GAME_OVERLAY.md PR stack (P1 pause, P2 draw, P3 input, ...).
|
|
*/
|
|
#ifndef PSX_HOST_OVERLAY_H
|
|
#define PSX_HOST_OVERLAY_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* ---- P1: host pause --------------------------------------------------------
|
|
* A nesting pause owned by the host (not the guest): while depth > 0 the
|
|
* runtime holds the guest at the vblank present, keeps presenting the last
|
|
* frame and pauses audio. Push refuses (returns 0) while the refusal probe
|
|
* says so -- the runtime installs psx_netplay_active() there, because pausing
|
|
* one peer would stall the session. Main thread only. */
|
|
typedef int (*PsxHostPauseRefuseFn)(void);
|
|
int psx_host_pause_push(const char *reason);
|
|
void psx_host_pause_pop(void);
|
|
int psx_host_pause_depth(void);
|
|
const char *psx_host_pause_reason(void);
|
|
void psx_host_pause_set_refuse_probe(PsxHostPauseRefuseFn fn);
|
|
|
|
/* ---- P2: overlay draw callback ---------------------------------------------
|
|
* Called once per presented frame by the OpenGL backend after the game image
|
|
* and the host OSD layers are composed, before present_shot capture and the
|
|
* swap, with the drawable size in pixels. It runs on the thread that owns the
|
|
* GL context (the render thread when it is on, else the main thread), with the
|
|
* window framebuffer bound. The callback must leave GL state as it found it.
|
|
* Vulkan and the SDL renderer never call it. NULL unregisters.
|
|
*
|
|
* Lifetime contract: the registrant owns ctx. psx_host_overlay_set_draw_cb
|
|
* (replace or NULL) returns only after any draw call that may still be using
|
|
* the previous fn/ctx has finished, so the registrant may free ctx and the GL
|
|
* objects it draws with right after it returns, and must keep them alive
|
|
* until then. Unregister before destroying those objects or the GL context
|
|
* (e.g. on renderer shutdown). Called from inside the callback it does not
|
|
* wait; the current call is then the last one with the old ctx. */
|
|
typedef void (*PsxHostOverlayDrawFn)(int width, int height, void *ctx);
|
|
void psx_host_overlay_set_draw_cb(PsxHostOverlayDrawFn fn, void *ctx);
|
|
int psx_host_overlay_has_draw(void);
|
|
void psx_host_overlay_draw(int width, int height); /* renderer side */
|
|
|
|
/* ---- P3: input sink -----------------------------------------------------
|
|
* The sink sees every host SDL event first (main thread), in the normal event
|
|
* drain and in the host pause loop. Returning non-zero consumes the event.
|
|
* While ui_capture is on, local game input reads as released/centred, in
|
|
* netplay too (the peer then simply receives "nothing pressed"), so a menu
|
|
* open over a running session never leaks presses into the game.
|
|
* `event` is an SDL_Event*. NULL unregisters. */
|
|
typedef int (*PsxHostInputSinkFn)(const void *event, void *ctx);
|
|
void psx_host_set_input_sink(PsxHostInputSinkFn fn, void *ctx);
|
|
int psx_host_input_sink_dispatch(const void *event);
|
|
void psx_host_set_ui_capture(int on);
|
|
int psx_host_ui_capture_active(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|