Filament sensor using z-max endstop pin

I’m considering adding a mechanical filament run-out sensor to my toolhead. I’d like to use an existing pin that is unused (max endstops) as the trigger. I’m comfortable with editing the fw but haven’t messed with pin configs. I’d appreciate some guidance on where to grab power (3.3v?) And how to reassign a pin to the filament sensor.