How to make "sticky" joystick buttons?

Hello All,
I’m wondering how to create “sticky” joystick buttons, AKA an action (let’s say set Relay to ON) is defaulted on at the beginning of a match, and pressing a specific button will toggle the relay ON or OFF, not momentarily changing it’s status.

Thanks!
dwmcc

It’s a little complicated. You need to start by detecting each button press as a unique event (instead of toggling for every loop during which the button is held down). At the end of every loop save the old button value. Only when the current value is pressed and the one from the previous loop is not pressed should you toggle the setting. Then you create a variable to store the state of your toggle and then you just change it every time we see a button press with the above logic.

http://www.chiefdelphi.com/forums/showpost.php?p=1026930&postcount=3
*
*