/// <summary>
 /// Attaches a void Action to an output sig's UserObject, to be run on release
 /// </summary>
 /// <returns>The Sig</returns>
 public static BoolOutputSig SetSigFalseAction(this BoolOutputSig sig, Action a)
 {
     return(sig.SetBoolSigAction(b => { if (!b)
                                        {
                                            a();
                                        }
                                 }));
 }
        /// <summary>
        /// Sets an action to a held sig as well as a released-without-hold action
        /// </summary>
        /// <returns></returns>
        public static BoolOutputSig SetSigHeldAction(this BoolOutputSig sig, uint heldMs, Action heldAction, Action holdReleasedAction, Action releaseAction)
        {
            CTimer heldTimer = null;
            bool   wasHeld   = false;

            return(sig.SetBoolSigAction(press =>
            {
                if (press)
                {
                    wasHeld = false;
                    // Could insert a pressed action here
                    heldTimer = new CTimer(o =>
                    {
                        // if still held and there's an action
                        if (sig.BoolValue && heldAction != null)
                        {
                            wasHeld = true;
                            // Hold action here
                            heldAction();
                        }
                    }, heldMs);
                }
                else if (!press && !wasHeld)                 // released, no hold
                {
                    heldTimer.Stop();
                    if (releaseAction != null)
                    {
                        releaseAction();
                    }
                }
                else                 // !press && wasHeld // released after held
                {
                    heldTimer.Stop();
                    if (holdReleasedAction != null)
                    {
                        holdReleasedAction();
                    }
                }
            }));
        }