Example #1
0
 private Buttons.ButtonStates GetDebounced()
 {
     Buttons.ButtonStates s2 = Buttons.ButtonStates.None;
     for (;;)
     {
         Buttons.ButtonStates s1 = ReadStates();
         if (s1 == s2)
         {
             return(s1);
         }
         Thread.Sleep(debounceTime);
         s2 = ReadStates();
     }
 }
Example #2
0
 public Buttons.ButtonStates GetKeypress(CancellationToken token)
 {
     Buttons.ButtonStates bs = GetDebounced();
     while (bs != Buttons.ButtonStates.None && !token.IsCancellationRequested)
     {
         bs = GetDebounced();
     }
     do
     {
         Thread.Sleep(pollTime);
         bs = GetDebounced();
     } while (bs == Buttons.ButtonStates.None && !token.IsCancellationRequested);
     return(bs);
 }
Example #3
0
		public void EnterReleased()
		{
			state &= ~Buttons.ButtonStates.Enter;
		}
Example #4
0
 public void EscPressed()
 {
     state = state | Buttons.ButtonStates.Escape;
 }
Example #5
0
		public void EscPressed()
		{
			state = state | Buttons.ButtonStates.Escape;
		}
Example #6
0
		public void RightPressed()
		{
			state = state | Buttons.ButtonStates.Right;
		}
Example #7
0
		public void LeftPressed()
		{
			state = state | Buttons.ButtonStates.Left;
		}
Example #8
0
		public void UpPressed()
		{
			state = state | Buttons.ButtonStates.Up;
		}
Example #9
0
 public void UpPressed()
 {
     state = state | Buttons.ButtonStates.Up;
 }
Example #10
0
 public void DownReleased()
 {
     state &= ~Buttons.ButtonStates.Down;
 }
Example #11
0
 public void DownPressed()
 {
     state = state | Buttons.ButtonStates.Down;
 }
Example #12
0
 public void EnterReleased()
 {
     state &= ~Buttons.ButtonStates.Enter;
 }
Example #13
0
 public void EnterPressed()
 {
     state = state | Buttons.ButtonStates.Enter;
 }
Example #14
0
 public void EscReleased()
 {
     state &= ~Buttons.ButtonStates.Escape;
 }
Example #15
0
		public void DownPressed()
		{
			state = state | Buttons.ButtonStates.Down;
		}
Example #16
0
		public void DownReleased()
		{
			state &= ~Buttons.ButtonStates.Down;
		}
Example #17
0
 public void UpReleased()
 {
     state &= ~Buttons.ButtonStates.Up;
 }
Example #18
0
		public void UpReleased()
		{
			state &= ~Buttons.ButtonStates.Up;	
		}
Example #19
0
 public void LeftPressed()
 {
     state = state | Buttons.ButtonStates.Left;
 }
Example #20
0
		public void LeftReleased()
		{
			state &= ~Buttons.ButtonStates.Left;	
		}
Example #21
0
 public void LeftReleased()
 {
     state &= ~Buttons.ButtonStates.Left;
 }
Example #22
0
		public void RightReleased()
		{
			state &= ~Buttons.ButtonStates.Right;	
		}
Example #23
0
 public void RightPressed()
 {
     state = state | Buttons.ButtonStates.Right;
 }
Example #24
0
        void ButtonPollThread()
        {
            Thread.CurrentThread.IsBackground = true;
            Buttons.ButtonStates lastState = Buttons.Instance.GetDebounced();
            while (!stopPolling.WaitOne(pollTime))
            {
                Buttons.ButtonStates bs = Buttons.Instance.GetDebounced();
                if (bs != lastState)
                {
                    Buttons.ButtonStates pressed = (bs ^ lastState) & (~lastState);
                    switch (pressed)
                    {
                    case Buttons.ButtonStates.Down:
                        queue.Enqueue(DownPressed);
                        break;

                    case Buttons.ButtonStates.Enter:
                        queue.Enqueue(EnterPressed);
                        break;

                    case Buttons.ButtonStates.Escape:
                        queue.Enqueue(EscapePressed);
                        break;

                    case Buttons.ButtonStates.Left:
                        queue.Enqueue(LeftPressed);
                        break;

                    case Buttons.ButtonStates.Right:
                        queue.Enqueue(RightPressed);
                        break;

                    case Buttons.ButtonStates.Up:
                        queue.Enqueue(UpPressed);
                        break;
                    }

                    Buttons.ButtonStates released = (bs ^ lastState) & lastState;
                    switch (released)
                    {
                    case Buttons.ButtonStates.Down:
                        queue.Enqueue(DownReleased);
                        break;

                    case Buttons.ButtonStates.Enter:
                        queue.Enqueue(EnterReleased);
                        break;

                    case Buttons.ButtonStates.Escape:
                        queue.Enqueue(EscapeReleased);
                        break;

                    case Buttons.ButtonStates.Left:
                        queue.Enqueue(LeftReleased);
                        break;

                    case Buttons.ButtonStates.Right:
                        queue.Enqueue(RightReleased);
                        break;

                    case Buttons.ButtonStates.Up:
                        queue.Enqueue(UpReleased);
                        break;
                    }
                    lastState = bs;
                }
            }
        }
Example #25
0
		public void EscReleased()
		{
			state &= ~Buttons.ButtonStates.Escape;	
		}
Example #26
0
		public void EnterPressed()
		{
			state = state | Buttons.ButtonStates.Enter;
		}
Example #27
0
 public void RightReleased()
 {
     state &= ~Buttons.ButtonStates.Right;
 }