Direction controls pin

Hello, for a project we are developing we would need to know if the uav is going forward or backwards. Best would be to have a pin on the servo rails that changes state, for example high if going forward and low if going backwards. Is it possible without modifying the source? I looked t the firmware for a while now but i can’t find any function that could be used to do that. Maybe someone has an idea on how i could do it.
Thanks