Пример #1
0
        private void HandleTouchEvent(EmulatorTouchEvent touchEvent)
        {
            if (touchEvent.pointers.Count < 1)
            {
                return;
            }
            EmulatorTouchEvent.Pointer pointer = touchEvent.pointers[0];

            lock (state) {
                state.touchPos = new Vector2(pointer.normalizedX, pointer.normalizedY);
                switch (touchEvent.getActionMasked())
                {
                case EmulatorTouchEvent.Action.kActionDown:
                    state.buttonsState |= GvrControllerButton.TouchPadTouch;
                    break;

                case EmulatorTouchEvent.Action.kActionMove:
                    state.buttonsState |= GvrControllerButton.TouchPadTouch;
                    break;

                case EmulatorTouchEvent.Action.kActionUp:
                    state.buttonsState &= ~GvrControllerButton.TouchPadTouch;
                    break;
                }
            }
        }
        private void HandleTouchEvent(EmulatorTouchEvent touchEvent)
        {
            if (touchEvent.pointers.Count < 1)
            {
                return;
            }
            EmulatorTouchEvent.Pointer pointer = touchEvent.pointers[0];

            lock (state) {
                state.touchPos = new Vector2(pointer.normalizedX, pointer.normalizedY);
                switch (touchEvent.getActionMasked())
                {
                case EmulatorTouchEvent.Action.kActionDown:
                    state.touchDown  = true;
                    state.isTouching = true;
                    break;

                case EmulatorTouchEvent.Action.kActionMove:
                    state.isTouching = true;
                    break;

                case EmulatorTouchEvent.Action.kActionUp:
                    state.isTouching = false;
                    state.touchUp    = true;
                    break;
                }
            }
        }
Пример #3
0
 private void ProcessEventAtEndOfFrame(PhoneEvent e) {
   switch (e.Type) {
     case PhoneEvent.Types.Type.MOTION:
       EmulatorTouchEvent touchEvent = new EmulatorTouchEvent(e.MotionEvent, lastDownTimeMs);
       onTouchEvent(touchEvent);
       if (touchEvent.getActionMasked() == EmulatorTouchEvent.Action.kActionDown) {
         lastDownTimeMs = e.MotionEvent.Timestamp;
       }
       break;
     case PhoneEvent.Types.Type.GYROSCOPE:
       EmulatorGyroEvent gyroEvent = new EmulatorGyroEvent(e.GyroscopeEvent);
       onGyroEvent(gyroEvent);
       break;
     case PhoneEvent.Types.Type.ACCELEROMETER:
       EmulatorAccelEvent accelEvent = new EmulatorAccelEvent(e.AccelerometerEvent);
       onAccelEvent(accelEvent);
       break;
     case PhoneEvent.Types.Type.ORIENTATION:
       EmulatorOrientationEvent orientationEvent =
           new EmulatorOrientationEvent(e.OrientationEvent);
       onOrientationEvent(orientationEvent);
       break;
     case PhoneEvent.Types.Type.KEY:
       EmulatorButtonEvent buttonEvent = new EmulatorButtonEvent(e.KeyEvent);
       onButtonEvent(buttonEvent);
       break;
     default:
       Debug.Log("Unsupported PhoneEvent type: " + e.Type);
       break;
   }
 }
    private void HandleTouchEvent(EmulatorTouchEvent touchEvent) {
      if (touchEvent.pointers.Count < 1) return;
      EmulatorTouchEvent.Pointer pointer = touchEvent.pointers[0];

      lock (state) {
        state.touchPos = new Vector2(pointer.normalizedX, pointer.normalizedY);
        switch (touchEvent.getActionMasked()) {
          case EmulatorTouchEvent.Action.kActionDown:
            state.touchDown = true;
            state.isTouching = true;
            break;
          case EmulatorTouchEvent.Action.kActionMove:
            state.isTouching = true;
            break;
          case EmulatorTouchEvent.Action.kActionUp:
            state.isTouching = false;
            state.touchUp = true;
            break;
        }
      }
    }
Пример #5
0
 private void ProcessEventAtEndOfFrame(PhoneEvent e)
 {
     switch (e.Type) {
     case PhoneEvent.Types.Type.MOTION:
       EmulatorTouchEvent touchEvent = new EmulatorTouchEvent(e.MotionEvent, lastDownTimeMs);
       onTouchEvent(touchEvent);
       if (touchEvent.getActionMasked() == EmulatorTouchEvent.Action.kActionDown) {
     lastDownTimeMs = e.MotionEvent.Timestamp;
       }
       break;
     case PhoneEvent.Types.Type.GYROSCOPE:
       EmulatorGyroEvent gyroEvent = new EmulatorGyroEvent(e.GyroscopeEvent);
       onGyroEvent(gyroEvent);
       break;
     case PhoneEvent.Types.Type.ACCELEROMETER:
       EmulatorAccelEvent accelEvent = new EmulatorAccelEvent(e.AccelerometerEvent);
       onAccelEvent(accelEvent);
       break;
     case PhoneEvent.Types.Type.ORIENTATION:
       EmulatorOrientationEvent orientationEvent =
       new EmulatorOrientationEvent(e.OrientationEvent);
       onOrientationEvent(orientationEvent);
       break;
     case PhoneEvent.Types.Type.KEY:
       EmulatorButtonEvent buttonEvent = new EmulatorButtonEvent(e.KeyEvent);
       onButtonEvent(buttonEvent);
       break;
     default:
       Debug.Log("Unsupported PhoneEvent type: " + e.Type);
       break;
       }
 }