コード例 #1
0
ファイル: LunarView.cs プロジェクト: MahendrenGanesan/samples
		/// <summary>
		/// Standard override for key-up. We actually care about these, so we can
		/// turn off the engine or stop rotating.
		/// </summary>
		public override bool OnKeyUp(int keyCode, KeyEvent msg)
		{
			return thread.DoKeyUp(keyCode, msg);
		}
コード例 #2
0
ファイル: LunarView.cs プロジェクト: MahendrenGanesan/samples
			/// <summary>
			/// Handles a key-up event.
			/// </summary>
			/// <param name="keyCode"> the key that was pressed </param>
			/// <param name="msg"> the original event object </param>
			/// <returns> true if the key was handled and consumed, or else false </returns>
			internal bool DoKeyUp(int keyCode, KeyEvent msg)
			{
				bool handled = false;

				lock (mSurfaceHolder)
				{
					if (mMode == STATE_RUNNING)
					{
						if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_SPACE)
						{
							Firing = false;
							handled = true;
						}
						else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_Q || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_W)
						{
							mRotating = 0;
							handled = true;
						}
					}
				}

				return handled;
			}
コード例 #3
0
ファイル: TextView.cs プロジェクト: nguyenkien/api
 public bool OnEditorAction(TextView v, int actionId, KeyEvent @event)
 {
     var args = new EditorActionEventArgs(actionId, @event);
     EditorAction.Invoke(v, args);
     return args.IsHandled;
 }
コード例 #4
0
ファイル: LunarView.cs プロジェクト: MahendrenGanesan/samples
			/// <summary>
			/// Handles a key-down event.
			/// </summary>
			/// <param name="keyCode"> the key that was pressed </param>
			/// <param name="msg"> the original event object </param>
			/// <returns> true </returns>
			internal bool DoKeyDown(int keyCode, KeyEvent msg)
			{
				lock (mSurfaceHolder)
				{
					bool okStart = false;
					if (keyCode == KeyEvent.KEYCODE_DPAD_UP)
					{
						okStart = true;
					}
					if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN)
					{
						okStart = true;
					}
					if (keyCode == KeyEvent.KEYCODE_S)
					{
						okStart = true;
					}

					if (okStart && (mMode == STATE_READY || mMode == STATE_LOSE || mMode == STATE_WIN))
					{
						// ready-to-start -> start
						DoStart();
						return true;
					}
					else if (mMode == STATE_PAUSE && okStart)
					{
						// paused -> running
						Unpause();
						return true;
					}
					else if (mMode == STATE_RUNNING)
					{
						// center/space -> fire
						if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_SPACE)
						{
							Firing = true;
							return true;
							// left/q -> left
						}
						else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_Q)
						{
							mRotating = -1;
							return true;
							// right/w -> right
						}
						else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_W)
						{
							mRotating = 1;
							return true;
							// up -> pause
						}
						else if (keyCode == KeyEvent.KEYCODE_DPAD_UP)
						{
							Pause();
							return true;
						}
					}

					return false;
				}
			}
コード例 #5
0
	    public EditorActionEventArgs(int actionId, KeyEvent @event)
	    {
	        Event = @event;
	        ActionId = actionId;
	    }