mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 02:11:36 -04:00
a4d1f31487
psx_mod_set_pad_transform(player, &PSXModPadTransform) registers stage 2b of pad_external_input: after the physical pad and any controller source, before the mouse policy. The transform sees the resolved pad plus the port's host extras (gamepad present, LT/RT 0..255 from SDL, unthresholded) and may rewrite buttons, sticks and the presented controller type, e.g. a NeGcon whose I/II come from the triggers. Output is pre-filled as a pass-through, validated (struct size, ranges, type within allowed_types) and replaced by neutral when invalid; detaching or a mod/session reset owes one neutral release frame. initial_type sets the boot/hotplug type. The resolver stays pure: host extras arrive through a new capture hook and the transform through another, both covered in pad_external_input_test. Under the input guard the transform runs on zero triggers and its output is neutralized. A NeGcon result resets the mouse policy rather than letting it overwrite the I/II bytes. Offline only: netplay, resim, selfcheck replay and plain debug overrides never reach it. With no transform registered every pad is bit-identical to before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17 lines
569 B
C
17 lines
569 B
C
/* SDL trigger axis -> 0..255 host-extras magnitude (no digital threshold). */
|
|
#include <stdio.h>
|
|
#include "psx_trigger.h"
|
|
|
|
#define CHECK(expr) do { if (!(expr)) { \
|
|
fprintf(stderr, "FAIL line %d: %s\n", __LINE__, #expr); return 1; } } while (0)
|
|
|
|
int main(void) {
|
|
CHECK(psx_trigger_axis_to_u8(-32768) == 0);
|
|
CHECK(psx_trigger_axis_to_u8(0) == 0);
|
|
CHECK(psx_trigger_axis_to_u8(8192) == 64);
|
|
CHECK(psx_trigger_axis_to_u8(16384) == 128);
|
|
CHECK(psx_trigger_axis_to_u8(24575) == 191);
|
|
CHECK(psx_trigger_axis_to_u8(32767) == 255);
|
|
return 0;
|
|
}
|