예제 #1
0
		private static void wnd_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs e)
		{
			lock (keysPressed)
			{
				keysPressed[e.Key] = true;
			}

			KeyEventHandler h = OnKeyDown;
			if (h != null)
			{
				try
				{
					KeyEventArgs e2 = new KeyEventArgs((int)e.ScanCode, (Key)e.Key, e.Alt, e.Control, e.Shift, e.IsRepeat);
					h(sender, e2);
				}
				catch (Exception ex)
				{
					Debug.WriteLine(ex.Message);
					Debug.WriteLine(ex.StackTrace.ToString());
				}
			}

			// Keys no longer forwarded to KeyPress by OpenTK. Need to forward them manually:
			switch (e.Key)
			{
				case OpenTK.Input.Key.Enter:
					wnd_KeyPress(sender, new KeyPressEventArgs('\r'));
					break;

				case OpenTK.Input.Key.Escape:
					wnd_KeyPress(sender, new KeyPressEventArgs((char)27));
					break;

				case OpenTK.Input.Key.Tab:
					wnd_KeyPress(sender, new KeyPressEventArgs('\t'));
					break;

				case OpenTK.Input.Key.BackSpace:
					wnd_KeyPress(sender, new KeyPressEventArgs('\b'));
					break;

				case OpenTK.Input.Key.C:
					if (e.Control)
						wnd_KeyPress(sender, new KeyPressEventArgs((char)3));
					break;
			}
		}
예제 #2
0
		private static void MPE_Wait_OnKeyDown(object Sender, KeyEventArgs e)
		{
			if (e.Key == Key.Escape && MPE.State == MultiPlayerState.FindingPlayers)
				MPE.ConnectPlayers();
		}
예제 #3
0
		private static void wnd_KeyUp(object sender, OpenTK.Input.KeyboardKeyEventArgs e)
		{
			lock (keysPressed)
			{
				keysPressed.Remove(e.Key);
			}

			KeyEventHandler h = OnKeyUp;
			if (h != null)
			{
				try
				{
					KeyEventArgs e2 = new KeyEventArgs((int)e.ScanCode, (Key)e.Key, e.Alt, e.Control, e.Shift, e.IsRepeat);
					h(sender, e2);
				}
				catch (Exception ex)
				{
					Debug.WriteLine(ex.Message);
					Debug.WriteLine(ex.StackTrace.ToString());
				}
			}
		}