Files
bigmak94andClaude Opus 5.5 525c73c6e9 Fix the Wii Remote's tilt for Ray surfing and the Star Ball
The emulated accelerometer had its own axes (x right, y along the
pointer, z out of the button face) where KPAD's are x left, y out of the
button face, z along the pointer ((0, -1, 0) held level, KPADReset),
which the game then remaps (WPadAcceleration::update).  A level
controller read as a remote standing on end: the surfing coach's "Point
your Wii Remote at the screen" never passed, and the Star Ball would
roll forward at full speed.

- wpad.cpp adds gravity in KPAD's axes.  While the game steers by tilt
  (port_input_use_tilt), it follows the right controller pitched up by
  the game's neutral angle, so a level controller gives the grip the
  game asks for; a controller whose orientation is unknown counts as
  level.  PortPadState carries which way is down from the controller
  (xr_app.cpp) and, as accelerations, only the motion on top (shakes).
- Star Ball: neutral 80 degrees (90 - sCoreBaseDegreeYZ), not 100.  Its
  tutorial reads the tilt only while it checks that the remote is
  raised, so aiming near the sign never counts as a shake.
- PETARI_INPUT scripts tilt the controller with PITCH= and ROLL=.
- docs/CONTROLS.md: the in-game instructions in controller terms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 03:21:10 +02:00

38 lines
1.4 KiB
C

// Controller state handed from the XR/input layer to the Wii remote emulation.
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct PortPadState {
int connected; // a Wii remote + Nunchuk is present
uint32_t buttons; // WPAD_BUTTON_* bits (remote and Nunchuk C/Z)
float stickX, stickY; // Nunchuk stick, -1..1 (right / up positive)
// Motion of the remote and the Nunchuk in g (shakes), 0 when held still.
// The emulation adds gravity (wpad.cpp). KPAD axes: x left, y out of the
// button face, z where the remote points.
float accX, accY, accZ;
float nunAccX, nunAccY, nunAccZ;
// Which way is down from the right controller, when `tilted`: a unit
// vector in its axes (x right, y up, z where it aims). The remote takes
// this tilt while the game steers by tilt (port_input_use_tilt).
int tilted;
float downX, downY, downZ;
int pointerValid; // pointer is on screen
float pointerX, pointerY; // -1..1 screen space (right / down positive, like KPAD)
float pointerDist; // metres from the "sensor bar"
} PortPadState;
// Called by the input layer (any thread).
void port_input_set(int chan, const PortPadState* state);
// Rumble requested by the game (0/1) for a channel; read by the input layer.
int port_input_rumble(int chan);
#ifdef __cplusplus
}
#endif