Files
goldeneye-pc-port/port/include/input.h
T
James Dansereau ad74865404 port: click-to-lock mouse capture + absolute menu cursor + aim retune (D180)
WI-1: Input.MouseCaptureMode (0 = legacy always-grab, default; 1 =
Quake/Nightdive-style click-to-lock). In mode 1 the OS cursor is free
until a click lands in the game window; ESC, focus loss, or entering
any front-end menu frees it again, and re-entering a stage while armed
re-locks so unpausing needs no click. Mouse buttons are withheld from
the game while the cursor is free in-stage (no phantom fire). Controller
input paths are untouched. reconcileGrab() runs once per controller-0
poll off the game's current_menu global (UI context only).

WI-2: when capture mode is on and the cursor is free in a menu, the
D165/D169 pointer P-controller takes its target from the real cursor's
absolute window position mapped onto the live virtual front-end rect
(getPlayer_c_screen*), for true 1:1 tracking. The relative-delta path
(legacy / grabbed) is unchanged.

B3: Input.MouseAimSpeed default 25 -> 16 (aim mode still overshot at 25).

Build 241/241; -level_09 framediff 3/3 within threshold (unregressed);
GE_STARTMENU menu boot crash-free. Feel-checks owed (headless can't
drive the mouse).

Claude-Session: https://claude.ai/code/session_01GULf6knbsqfsnW39tMr9WT
2026-09-02 01:26:33 -04:00

69 lines
2.5 KiB
C

#ifndef PORT_INPUT_H
#define PORT_INPUT_H
/*
* Input: SDL2 keyboard/mouse/gamepad -> N64 controller structs.
* Modelled on the PD port's port/include/input.h.
*
* The game reads controllers via osContInit / osContStartReadData (src/joy.c).
* This layer populates the N64 controller state (buttons, stick) from SDL
* events. Default bindings follow the 1964GEPD / Xbox schemes; see the PD
* port README for the reference table.
*/
#include <PR/ultratypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Initialize SDL input. Returns 0 on success. */
int inputInit(void);
void inputDestroy(void);
/* Poll once per frame; updates the connected-controller state that
* osContStartReadData / osContRead will return. */
void inputUpdate(void);
/* Number of controllers currently "connected" (1..4). */
int inputGetNumControllers(void);
/* Bitmask of connected controllers (bit N = controller N). Bit 0 is always
* set (keyboard/mouse). Consumed by libultra.c's osContInit. */
int inputConnectedMask(void);
/* Compute the N64 button mask + analog stick for controller `idx`.
* Returns the 16-bit CONT_* button mask; writes the stick (-80..80) through
* the out params. Reads current SDL keyboard/mouse/gamepad state plus the
* mouse-aim accumulator maintained by inputUpdate(). */
unsigned inputComputePad(int idx, signed char *stick_x, signed char *stick_y);
/* Grab/release the mouse (relative-mouse mode). The host event pump calls
* this on window focus loss/gain so alt-tabbing frees the cursor. A release
* also suspends mouse-aim reads until re-grabbed. No-op if the mouse is
* disabled in config. */
void inputSetMouseGrab(int on);
/* WI-1 click-to-lock cursor capture (Input.MouseCaptureMode = 1). The host
* event pump calls inputNotifyClick() when a mouse button goes down inside the
* game window (arms + locks the cursor), and inputReleaseCapture() when ESC is
* pressed (frees it; returns 1 if it consumed the key). inputMouseCaptureActive()
* is true when capture mode is on and the cursor is currently free -- the pump
* uses it to decide whether a click should be swallowed rather than passed on. */
void inputNotifyClick(void);
int inputReleaseCapture(void);
int inputMouseCaptureActive(void);
/* Queue a mouse-wheel weapon-cycle input (one short A-button press). Sign is
* ignored -- GE only cycles forward on a bare A edge. */
void inputPostWheel(int notches);
/* Re-enumerate gamepads after a hotplug (SDL_CONTROLLERDEVICEADDED/REMOVED). */
void inputRescanPads(void);
#ifdef __cplusplus
}
#endif
#endif /* PORT_INPUT_H */