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); } } }
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(); }
/// <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); }
public AndroidTextInput(AndroidGameView view) { this.view = view; activity = (AndroidGameActivity)view.Context; if (view.Context != null) { inputMethodManager = view.Context.GetSystemService(Context.InputMethodService) as InputMethodManager; } }
/// <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); }
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); } }
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(); }
/// <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 }; }
public override void SetContentView(View view) { gameView = view as AndroidGameView; SetupGameViewAndGameContext(); }
public AndroidKeyboardHandler(AndroidGameView view) { this.view = view; view.KeyDown += keyDown; view.KeyUp += keyUp; }
public override void EndFrame(AndroidGameView game) { game.SwapBuffers(); }
public override void SetContentView(View view, ViewGroup.LayoutParams @params) { 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) { }
public GameViewContext(AndroidGameView androidGameView) { this.androidGameView = androidGameView; }
public override void SetVSync(AndroidGameView game, bool value) { //game.VSync = value; TODO: vsync }
public override void BeginFrame(AndroidGameView game) { }
public override void OnWindowResize(AndroidGameView game) { GL.Viewport(0, 0, game.Width, game.Height); }
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; }
public AndroidTouchHandler(AndroidGameView view) { this.view = view; view.Touch += handleTouches; }
public AndroidMouseHandler(AndroidGameView view) : base(view) { }
protected AndroidInputHandler(AndroidGameView view) { View = view; }
public OpenTK(AndroidGameView window) { }