示例#1
0
        public override void Initialize()
        {
            base.Initialize();

            var viewListener = new ViewListener(this);
            gameView = Game.Context.Control;
            gameView.SetOnTouchListener(viewListener);
            gameView.SetOnKeyListener(viewListener);
            gameView.Resize += GameViewOnResize;

            GameViewOnResize(null, EventArgs.Empty);

            // Get the android sensors
            sensorManager = (SensorManager)PlatformAndroid.Context.GetSystemService(Context.SensorService);
            androidAccelerometer = sensorManager.GetDefaultSensor(SensorType.Accelerometer);
            androidGyroscope = sensorManager.GetDefaultSensor(SensorType.Gyroscope);
            androidUserAcceleration = sensorManager.GetDefaultSensor(SensorType.LinearAcceleration);
            androidGravity = sensorManager.GetDefaultSensor(SensorType.Gravity);
            androidRotationVector = sensorManager.GetDefaultSensor(SensorType.RotationVector);

            // Determine which sensor is available on the device
            Accelerometer.IsSupported = androidAccelerometer != null;
            Compass.IsSupported = androidRotationVector != null;
            Gyroscope.IsSupported = androidGyroscope != null;
            UserAcceleration.IsSupported = androidUserAcceleration != null;
            Gravity.IsSupported = androidGravity != null;
            Orientation.IsSupported = androidRotationVector != null;
        }
        protected override void ProcessPresentationParameters()
        {
            // Use aspect ratio of device
            gameWindow = (AndroidGameView)Description.DeviceWindowHandle.NativeHandle;
            var panelWidth = gameWindow.Size.Width;
            var panelHeight = gameWindow.Size.Height;
            var panelRatio = (float)panelWidth / panelHeight;

            var handler = ProcessPresentationParametersOverride; // TODO remove this hack when swap chain creation process is properly designed and flexible.
            if(handler != null) // override
            {
                handler(panelWidth, panelHeight, Description);
            }
            else // default behavior
            {
                var desiredWidth = Description.BackBufferWidth;
                var desiredHeight = Description.BackBufferHeight;

                if (panelRatio >= 1.0f) // Landscape => use height as base
                {
                    Description.BackBufferHeight = (int)(desiredWidth / panelRatio);
                }
                else // Portrait => use width as base
                {
                    Description.BackBufferWidth = (int)(desiredHeight * panelRatio);
                }
            }
        }
示例#3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set the android global context
            if (PlatformAndroid.Context == null)
                PlatformAndroid.Context = this;

            // Set the format of the window color buffer (avoid conversions)
            // TODO: PDX-364: depth format is currently hard coded (need to investigate how it can be transmitted)
            Window.SetFormat(Format.Rgba8888);

            // Remove the title bar
            RequestWindowFeature(WindowFeatures.NoTitle);

            // Unpack the files contained in the apk
            //await VirtualFileSystem.UnpackAPK();
            
            // Create the Android OpenGl view
            gameView = new AndroidXenkoGameView(this);

            // setup the application view and xenko game context
            SetupGameViewAndGameContext();

            // set up a listener to the android ringer mode (Normal/Silent/Vibrate)
            ringerModeIntentReceiver = new RingerModeIntentReceiver((AudioManager)GetSystemService(AudioService));
            RegisterReceiver(ringerModeIntentReceiver, new IntentFilter(AudioManager.RingerModeChangedAction));

            SetFullscreenView();
            InitializeFullscreenViewCallback();
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameContext" /> class.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="editTextLayout">The layout to use in order to display android <see cref="EditText"/></param>
 /// <param name="requestedWidth">Width of the requested.</param>
 /// <param name="requestedHeight">Height of the requested.</param>
 public GameContext(AndroidGameView control, RelativeLayout editTextLayout, int requestedWidth = 0, int requestedHeight = 0)
 {
     Control = control;
     EditTextLayout = editTextLayout;
     RequestedWidth = requestedWidth;
     RequestedHeight = requestedHeight;
     ContextType = AppContextType.Android;
 }
        public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters) : base(device, presentationParameters)
        {
            gameWindow = (AndroidGameView)Description.DeviceWindowHandle.NativeWindow;

            graphicsDevice = device;
            startingPresentationParameters = presentationParameters;
            device.InitDefaultRenderTarget(Description);

            backBuffer = Texture.New2D(device, Description.BackBufferWidth, Description.BackBufferHeight, presentationParameters.BackBufferFormat, TextureFlags.RenderTarget | TextureFlags.ShaderResource);
        }
        public override void Initialize()
        {
            var viewListener = new ViewListener(this);
            gameView = Game.Context.Control;
            gameView.SetOnTouchListener(viewListener);
            gameView.SetOnKeyListener(viewListener);
            gameView.Resize += GameViewOnResize;

            GameViewOnResize(null, EventArgs.Empty);
        }
示例#7
0
        public AndroidTextInput(AndroidGameView view)
        {
            this.view = view;
            activity  = (AndroidGameActivity)view.Context;

            if (view.Context != null)
            {
                inputMethodManager = view.Context.GetSystemService(Context.InputMethodService) as InputMethodManager;
            }
        }
示例#8
0
        /// <summary>
        /// Should be called by the driver only.
        /// </summary>
        /// <param name="View"></param>
        internal KeyboardDeviceImp(View view)
        {
            _view      = (AndroidGameView)view;
            _keymapper = new Keymapper();

            /*
             * _View.Keyboard.KeyDown += OnGameWinKeyDown;
             * _View.Keyboard.KeyUp += OnGameWinKeyUp;
             */
        }
        public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters) : base(device, presentationParameters)
        {
            gameWindow = (AndroidGameView)Description.DeviceWindowHandle.NativeHandle;

            graphicsDevice = device;
            startingPresentationParameters = presentationParameters;
            device.InitDefaultRenderTarget(Description);

            backBuffer = Texture.New2D(device, Description.BackBufferWidth, Description.BackBufferHeight, presentationParameters.BackBufferFormat, TextureFlags.RenderTarget | TextureFlags.ShaderResource);
        }
示例#10
0
        public override void Initialize()
        {
            var viewListener = new ViewListener(this);

            gameView = Game.Context.Control;
            gameView.SetOnTouchListener(viewListener);
            gameView.SetOnKeyListener(viewListener);
            gameView.Resize += GameViewOnResize;

            GameViewOnResize(null, EventArgs.Empty);
        }
示例#11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create our OpenGL view, and display it
            //view = new GLView_DrawTriangle(this);
            //view = new GLView1(this);
            //view = new GLViewDrawCube(this);
            view = new GLViewDrawTexture(this);

            SetContentView(view);
        }
        protected override void ProcessPresentationParameters()
        {
            // Use aspect ratio of device
            gameWindow = (AndroidGameView)Description.DeviceWindowHandle.NativeHandle;
            var panelWidth  = gameWindow.Size.Width;
            var panelHeight = gameWindow.Size.Height;
            var panelRatio  = (float)panelWidth / panelHeight;

            var desiredWidth  = Description.BackBufferWidth;
            var desiredHeight = Description.BackBufferHeight;

            if (panelRatio >= 1.0f) // Landscape => use height as base
            {
                Description.BackBufferHeight = (int)(desiredWidth / panelRatio);
            }
            else // Portrait => use width as base
            {
                Description.BackBufferWidth = (int)(desiredHeight * panelRatio);
            }
        }
示例#13
0
        public Window(AndroidGameView gameView)
        {
            this.context = gameView;
            // required for accessing assets
            assets      = gameView.Context.Assets;
            this.scaleX = 1;
            this.scaleY = 1;
            // on mobile refresh is capped to 60hz
            this._deltaTime = 1f / 60f;

            this.context.Resize += (sender, e) =>
            {
                this.FixMobileViewport();
            };

            this.context.Touch += (sender, e) =>
            {
                switch (e.Event.Action)
                {
                case MotionEventActions.Move:
                    touchX = (e.Event.GetX() / this.scaleX - this.viewportPosition.X) / (this.viewportSize.X / this.OrthoWidth);
                    touchY = (e.Event.GetY() / this.scaleY - this.viewportPosition.Y) / (this.viewportSize.Y / this.OrthoHeight);
                    break;

                case MotionEventActions.Up:
                    isTouching = false;
                    break;

                case MotionEventActions.Down:
                    isTouching = true;
                    break;

                default:
                    break;
                }
            };

            FinalizeSetup();
        }
示例#14
0
        /// <summary>
        /// Creates a new mouse input device instance using an existing <see cref="View"/>.
        /// </summary>
        /// <param name="View">The game window providing mouse input.</param>
        public MouseDeviceImp(View view)
        {
            _view = (AndroidGameView)view;

            /* TODO
             * _View.Mouse.ButtonDown += OnGameWinMouseDown;
             * _View.Mouse.ButtonUp += OnGameWinMouseUp;
             */

            _btnLeftDesc = new ButtonImpDescription
            {
                ButtonDesc = new ButtonDescription
                {
                    Name = "Left",
                    Id   = (int)MouseButtons.Left
                },
                PollButton = false
            };
            _btnMiddleDesc = new ButtonImpDescription
            {
                ButtonDesc = new ButtonDescription
                {
                    Name = "Middle",
                    Id   = (int)MouseButtons.Middle
                },
                PollButton = false
            };
            _btnRightDesc = new ButtonImpDescription
            {
                ButtonDesc = new ButtonDescription
                {
                    Name = "Right",
                    Id   = (int)MouseButtons.Right
                },
                PollButton = false
            };
        }
示例#15
0
 public override void SetContentView(View view)
 {
     gameView = view as AndroidGameView;
     SetupGameViewAndGameContext();
 }
示例#16
0
 public AndroidKeyboardHandler(AndroidGameView view)
 {
     this.view     = view;
     view.KeyDown += keyDown;
     view.KeyUp   += keyUp;
 }
示例#17
0
 public override void EndFrame(AndroidGameView game)
 {
     game.SwapBuffers();
 }
示例#18
0
 public override void SetContentView(View view, ViewGroup.LayoutParams @params)
 {
     gameView = view as AndroidGameView;
     SetupGameViewAndGameContext();
 }
示例#19
0
 public override void SetContentView(View view)
 {
     gameView = view as AndroidGameView;
     SetupGameViewAndGameContext();
 }
 public AndroidTextInput(AndroidGameView view)
 {
     this.view          = view;
     inputMethodManager = view.Activity.GetSystemService(Context.InputMethodService) as InputMethodManager;
 }
 public AndroidKeyboardHandler(AndroidGameView view)
     : base(view)
 {
 }
示例#22
0
 public GameViewContext(AndroidGameView androidGameView)
 {
     this.androidGameView = androidGameView;
 }
示例#23
0
 public override void SetVSync(AndroidGameView game, bool value)
 {
     //game.VSync = value; TODO: vsync
 }
示例#24
0
 public override void BeginFrame(AndroidGameView game)
 {
 }
示例#25
0
 public override void SetContentView(View view, ViewGroup.LayoutParams @params)
 {
     gameView = view as AndroidGameView;
     SetupGameViewAndGameContext();
 }
示例#26
0
 public override void OnWindowResize(AndroidGameView game)
 {
     GL.Viewport(0, 0, game.Width, game.Height);
 }
示例#27
0
 public AndroidTouchHandler(AndroidGameView view)
     : base(view)
 {
 }
 public AndroidInputConnection(AndroidGameView targetView, bool fullEditor)
     : base(targetView, fullEditor)
 {
     TargetView = targetView;
 }
 public AndroidTouchHandler(AndroidGameView view)
 {
     this.view   = view;
     view.Touch += handleTouch;
     view.Hover += handleHover;
 }
示例#30
0
 public AndroidTouchHandler(AndroidGameView view)
 {
     this.view   = view;
     view.Touch += handleTouches;
 }
示例#31
0
 public AndroidMouseHandler(AndroidGameView view)
     : base(view)
 {
 }
 protected AndroidInputHandler(AndroidGameView view)
 {
     View = view;
 }
示例#33
0
 public OpenTK(AndroidGameView window)
 {
 }