private static void CreateCommandModeObservers(List <IDisposable> observers) { observers.Add(_leapObservable .EnsureOneHande() .Where(f => { var hand = f.Hands[0]; var avgAngl = hand.Fingers.Average(fi => fi.Direction.AngleTo(hand.Direction)); var palmRotation = Math.Abs(hand.Rotation.z); return(avgAngl <= CommandAngleSensetivity && // fingers are in the same plain as hand palmRotation < PalmRotationSensetivity && (Math.Abs(hand.PalmVelocity.y) >= CommandVerticalSensetivity || Math.Abs(hand.PalmVelocity.x) >= CommandHorizontalSensetivity)); // ensured movement }) .Buffer(BufferingWindow) // use Buffer instead of Scan to accumulate multiple values .Select(b => new VelocityInfo(b.Select(f => f.Hands[0].PalmVelocity.x).Sum(), b.Select(f => f.Hands[0].PalmVelocity.y).Sum(), b.Select(f => f.Hands[0].PalmVelocity.z).Sum())) .Subscribe(new PalmVelocityObserver(_modeSwitchSubject))); observers.Add(_leapObservable .EnsureOneHande() .Where(f => { var hand = f.Hands[0]; var rotation = Math.Abs(hand.Rotation.z); var avgAngl = hand.Fingers.Average(fi => fi.Direction.AngleTo(hand.Direction)); // react with opened hand only if (_searchReactionStoped && rotation < PalmRotationSensetivity) { // lets react on palm rotations again. _searchReactionStoped = false; } return(rotation > PalmRotationThreshold && avgAngl <= CommandAngleSensetivity && !_searchReactionStoped); }) .Subscribe(r => { // stop reacting on next to avoid multiple search "hits" _searchReactionStoped = true; WindowsInput.GotoSearch(); })); }
public static void CloseSwitchApplication() { WindowsInput.SendInput((uint)_altUp.Length, _altUp, Marshal.SizeOf <INPUT>()); }
public static void Del() { WindowsInput.SendInput((uint)_del.Length, _del, Marshal.SizeOf <INPUT>()); }
public static void Enter() { WindowsInput.SendInput((uint)_enter.Length, _enter, Marshal.SizeOf <INPUT>()); }
public static void Tab() { WindowsInput.SendInput((uint)_tab.Length, _tab, Marshal.SizeOf <INPUT>()); }
public static void Down() { WindowsInput.SendInput((uint)_down.Length, _down, Marshal.SizeOf <INPUT>()); }
public static void Up() { WindowsInput.SendInput((uint)_up.Length, _up, Marshal.SizeOf <INPUT>()); }
public static void Right() { WindowsInput.SendInput((uint)_right.Length, _right, Marshal.SizeOf <INPUT>()); }
public static void Left() { WindowsInput.SendInput((uint)_left.Length, _left, Marshal.SizeOf <INPUT>()); }