mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 10:19:47 -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>
12 lines
387 B
C
12 lines
387 B
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
/* SDL trigger axes use 0..32767 for released..pressed. Preserve intermediate
|
|
* values and round to the host-plugin byte range without a digital threshold. */
|
|
static inline uint8_t psx_trigger_axis_to_u8(int16_t value) {
|
|
if (value <= 0) return 0;
|
|
if (value >= 32767) return 255;
|
|
return (uint8_t)(((int32_t)value * 255 + 16383) / 32767);
|
|
}
|