Esempio n. 1
0
 public void AddEvents(Func <bool> onPressEvent = null, Func <bool> onHoldEvent = null, Func <bool> onReleaseEvent = null,
                       InvokeSet pressFunc      = null, InvokeSet holdFunc      = null, InvokeSet releaseFunc = null)
 {
     if (onPressEvent != null)
     {
         AddPress(onPressEvent);
     }
     if (onHoldEvent != null)
     {
         AddHold(onHoldEvent);
     }
     if (onReleaseEvent != null)
     {
         AddRelease(onReleaseEvent);
     }
     if (pressFunc != null)
     {
         AddPress(pressFunc);
     }
     if (holdFunc != null)
     {
         AddHold(holdFunc);
     }
     if (releaseFunc != null)
     {
         AddRelease(releaseFunc);
     }
 }
Esempio n. 2
0
 public void AddPress(InvokeSet a)
 {
     if (onPress == null)
     {
         onPress = new UnityEvent();
     }
     a.Bind(onPress);
 }
Esempio n. 3
0
 public void AddRelease(InvokeSet a)
 {
     if (onRelease == null)
     {
         onRelease = new UnityEvent();
     }
     a.Bind(onRelease);
 }
Esempio n. 4
0
 public void AddHold(InvokeSet a)
 {
     if (onHold == null)
     {
         onHold = new UnityEvent();
     }
     a.Bind(onHold);
 }
Esempio n. 5
0
 public void AddKeyCombinations(KCombination[] keyCombo, string nameToUse, Func <bool> onPress = null, Func <bool> onHold = null, Func <bool> onRelease = null,
                                InvokeSet setPress = null, InvokeSet setHold = null, InvokeSet setRelease = null)
 {
     if (keyCombo != null)
     {
         AddComplexKeyPresses(keyCombo);
     }
     if (string.IsNullOrEmpty(name))
     {
         name = nameToUse;
     }
     keyEvent.AddEvents(onPress, onHold, onRelease, setPress, setHold, setRelease);
 }
Esempio n. 6
0
 /// <summary>
 /// describes functions to execute when any of the specified key-combinations are pressed/held/released
 /// </summary>
 public KBind(KCombination[] kCombos, string name = null, Func <bool> onPressEvent          = null, Func <bool> onHoldEvent = null,
              Func <bool> onReleaseEvent          = null, Func <bool> additionalRequirement = null,
              bool eventAlwaysTriggerable         = false, InvokeSet pressFunc              = null, InvokeSet holdFunc = null, InvokeSet releaseFunc = null)
 {
     keyCombinations = kCombos;
     Init();
     Array.Sort(keyCombinations); Array.Reverse(keyCombinations);             // put least complex key bind first, backwards from usual processing
     this.name = name;
     keyEvent.AddEvents(onPressEvent, onHoldEvent, onReleaseEvent, pressFunc, holdFunc, releaseFunc);
     if (additionalRequirement != null)
     {
         this.additionalRequirement = additionalRequirement;
     }
     this.eventAlwaysTriggerable = eventAlwaysTriggerable;
 }
Esempio n. 7
0
 /// <summary>
 /// describes functions to execute when a specific key-combination is pressed/held/released
 /// </summary>
 public KBind(KCombination kCombo, string name = null, Func <bool> onPressEvent          = null, Func <bool> onHoldEvent = null,
              Func <bool> onReleaseEvent       = null, Func <bool> additionalRequirement = null,
              bool eventAlwaysTriggerable      = false, InvokeSet pressFunc              = null, InvokeSet holdFunc = null, InvokeSet releaseFunc = null)
     : this(new[] { kCombo }, name, onPressEvent, onHoldEvent, onReleaseEvent, additionalRequirement, eventAlwaysTriggerable, pressFunc, holdFunc, releaseFunc)
 {
 }