/// <summary> /// Initialise the input system. Note that accelerometer input defaults to off. /// </summary> /// <param name="game"></param> public InputManager(Project2Game game) : base(game) { // initialisation useMouseDelta = false; accelerometerEnabled = false; mouseDelta = new Vector2(); keyboardManager = new KeyboardManager(game); mouseManager = new MouseManager(game); pointerManager = new PointerManager(game); keyMapping = new KeyMapping(); // get the accelerometer. Returns null if no accelerometer found accelerometer = Accelerometer.GetDefault(); window = Window.Current.CoreWindow; // Set up the gesture recognizer. In this game, it only responds to TranslateX, TranslateY and Tap events gestureRecognizer = new Windows.UI.Input.GestureRecognizer(); gestureRecognizer.GestureSettings = GestureSettings.ManipulationTranslateX | GestureSettings.ManipulationTranslateY | GestureSettings.Tap; // Register event handlers for pointer events window.PointerPressed += OnPointerPressed; window.PointerMoved += OnPointerMoved; window.PointerReleased += OnPointerReleased; // automatically enable accelerometer if we have one this.AccelerometerEnabled(true); this.MouseDeltaEnabled(true); }
/// <summary> /// Initializes a new instance of <see cref="PointerPlatform"/> class /// </summary> /// <param name="nativeWindow">The platform-specific reference to window object</param> /// <param name="manager">The <see cref="PointerManager"/> whose events will be raised in response to platform-specific events</param> /// <exception cref="ArgumentNullException">Is thrown when either <paramref name="nativeWindow"/> or <paramref name="manager"/> is null.</exception> protected PointerPlatform(object nativeWindow, PointerManager manager) { if (nativeWindow == null) throw new ArgumentNullException("nativeWindow"); if (manager == null) throw new ArgumentNullException("manager"); this.manager = manager; BindWindow(nativeWindow); }
/// <summary> /// Creates a platform-specific instance of <see cref="PointerPlatform"/> class. /// </summary> /// <param name="nativeWindow">The platform-specific reference to window object</param> /// <param name="manager">The <see cref="PointerManager"/> whose events will be raised in response to platform-specific events</param> /// <exception cref="ArgumentNullException">Is thrown when either <paramref name="nativeWindow"/> or <paramref name="manager"/> is null.</exception> /// <exception cref="NotSupportedException">Is thrown when this functionality is not supported on current platform</exception> /// <returns>The platform-specific instance.</returns> internal static PointerPlatform Create(object nativeWindow, PointerManager manager) { #if !W8CORE return new PointerPlatformDesktop(nativeWindow, manager); #elif WIN8METRO return new PointerPlatformWinRT(nativeWindow, manager); #else throw new NotSupportedException("This functionality is not supported on current platform."); // no other platforms are supported at this time #endif }
/// <summary> /// Initializes a new instance of the <see cref="ModelRenderingGame" /> class. /// </summary> public ModelRenderingGame() { // Creates a graphics manager. This is mandatory. graphicsDeviceManager = new GraphicsDeviceManager(this); graphicsDeviceManager.PreferredGraphicsProfile = new FeatureLevel[] { FeatureLevel.Level_9_1, }; pointer = new PointerManager(this); // Setup the relative directory to the executable directory // for loading contents with the ContentManager Content.RootDirectory = "Content"; }
/// <summary> /// Creates a platform-specific instance of <see cref="PointerPlatform"/> class. /// </summary> /// <param name="nativeWindow">The platform-specific reference to window object</param> /// <param name="manager">The <see cref="PointerManager"/> whose events will be raised in response to platform-specific events</param> /// <exception cref="ArgumentNullException">Is thrown when either <paramref name="nativeWindow"/> or <paramref name="manager"/> is null.</exception> /// <exception cref="NotSupportedException">Is thrown when this functionality is not supported on current platform</exception> /// <returns>The platform-specific instance.</returns> internal static PointerPlatform Create(object nativeWindow, PointerManager manager) { #if !W8CORE return(new PointerPlatformDesktop(nativeWindow, manager)); #elif WIN8METRO return(new PointerPlatformWinRT(nativeWindow, manager)); #elif WP8 return(new PointerPlatformWP8(nativeWindow, manager)); #else throw new NotSupportedException("This functionality is not supported on current platform."); // no other platforms are supported at this time #endif }
/// <summary> /// Initializes a new instance of the <see cref="GeometricsGame" /> class. /// </summary> public GeometricsGame() { // Creates a graphics manager. This is mandatory. graphicsDeviceManager = new GraphicsDeviceManager(this); // Creates the pointer manager pointer = new PointerManager(this); // Setup the relative directory to the executable directory // for loading contents with the ContentManager Content.RootDirectory = "Content"; }
public Camera( Vector2 clientSize, KeyboardManager keyboardManager, MouseManager mouseManager, PointerManager pointerManager, Vector3 position, Vector3 target, float nearPlane = 1, float farPlane = 20000) : this(clientSize, position, target, nearPlane, farPlane) { KeyboardManager = keyboardManager; MouseManager = mouseManager; PointerManager = pointerManager; }
/// <summary> /// Initializes a new instance of <see cref="PointerPlatform"/> class /// </summary> /// <param name="nativeWindow">The platform-specific reference to window object</param> /// <param name="manager">The <see cref="PointerManager"/> whose events will be raised in response to platform-specific events</param> /// <exception cref="ArgumentNullException">Is thrown when either <paramref name="nativeWindow"/> or <paramref name="manager"/> is null.</exception> protected PointerPlatform(object nativeWindow, PointerManager manager) { if (nativeWindow == null) { throw new ArgumentNullException("nativeWindow"); } if (manager == null) { throw new ArgumentNullException("manager"); } this.manager = manager; BindWindow(nativeWindow); }
/// <summary> /// Creates a platform-specific instance of <see cref="PointerPlatform"/> class. /// </summary> /// <param name="nativeWindow">The platform-specific reference to window object</param> /// <param name="manager">The <see cref="PointerManager"/> whose events will be raised in response to platform-specific events</param> /// <exception cref="ArgumentNullException">Is thrown when either <paramref name="nativeWindow"/> or <paramref name="manager"/> is null.</exception> /// <exception cref="NotSupportedException">Is thrown when this functionality is not supported on current platform</exception> /// <returns>The platform-specific instance.</returns> internal static PointerPlatform Create(object nativeWindow, PointerManager manager) { #if !W8CORE if (nativeWindow is System.Windows.Forms.Control || nativeWindow is IntPtr) return new PointerPlatformDesktop(nativeWindow, manager); // WinForms platform #if !W8CORE && NET35Plus && !DIRECTX11_1 if (nativeWindow is SharpDXElement) return new PointerPlatformDesktopWpf(nativeWindow, manager); // WPF platform #endif throw new ArgumentException("Unsupported window control.", "nativeWindow"); #elif WIN8METRO return new PointerPlatformWinRT(nativeWindow, manager); #elif WP8 return new PointerPlatformWP8(nativeWindow, manager); #else throw new NotSupportedException("This functionality is not supported on current platform."); // no other platforms are supported at this time #endif }
/// <summary> /// Creates a platform-specific instance of <see cref="PointerPlatform"/> class. /// </summary> /// <param name="nativeWindow">The platform-specific reference to window object</param> /// <param name="manager">The <see cref="PointerManager"/> whose events will be raised in response to platform-specific events</param> /// <exception cref="ArgumentNullException">Is thrown when either <paramref name="nativeWindow"/> or <paramref name="manager"/> is null.</exception> /// <exception cref="NotSupportedException">Is thrown when this functionality is not supported on current platform</exception> /// <returns>The platform-specific instance.</returns> internal static PointerPlatform Create(object nativeWindow, PointerManager manager) { #if !W8CORE if (nativeWindow is System.Windows.Forms.Control || nativeWindow is IntPtr) { return(new PointerPlatformDesktop(nativeWindow, manager)); // WinForms platform } #if !W8CORE && NET35Plus && !DIRECTX11_1 if (nativeWindow is SharpDXElement) { return(new PointerPlatformDesktopWpf(nativeWindow, manager)); // WPF platform } #endif throw new ArgumentException("Unsupported window control.", "nativeWindow"); #elif WIN8METRO return(new PointerPlatformWinRT(nativeWindow, manager)); #elif WP8 return(new PointerPlatformWP8(nativeWindow, manager)); #else throw new NotSupportedException("This functionality is not supported on current platform."); // no other platforms are supported at this time #endif }
public AudioGame() { // Creates a graphics manager. This is mandatory. graphicsDeviceManager = new GraphicsDeviceManager(this); // Create the pointer manager pointerManager = new PointerManager(this); pointerState = new PointerState(); IsMouseVisible = true; random = new Random(); audioManager = new AudioManager(this); audioManager.EnableMasterVolumeLimiter(); //EnableSpatialAudioWithReverb(); // Setup the relative directory to the executable directory // for loading contents with the ContentManager Content.RootDirectory = "Content"; }
/// <summary> /// Initializes a new instace of <see cref="PointerPlatformWP8"/> class. /// </summary> /// <param name="nativeWindow">The platform-specific reference to window object</param> /// <param name="manager">The <see cref="PointerManager"/> whose events will be raised in response to platform-specific events</param> /// <exception cref="ArgumentNullException">Is thrown when either <paramref name="nativeWindow"/> or <paramref name="manager"/> is null.</exception> public PointerPlatformWP8(object nativeWindow, PointerManager manager) : base(nativeWindow, manager) { }
/// <summary> /// Initializes a new instance of the <see cref="PointerPlatformWinRT"/> class. /// </summary> /// <param name="nativeWindow">The platform-specific reference to window object</param> /// <param name="manager">The <see cref="PointerManager"/> whose events will be raised in response to platform-specific events</param> /// <exception cref="ArgumentNullException">Is thrown when either <paramref name="nativeWindow"/> or <paramref name="manager"/> is null.</exception> internal PointerPlatformWinRT(object nativeWindow, PointerManager manager) : base(nativeWindow, manager) { }
/// <summary> /// Initializes a new instance of <see cref="PointerPlatformDesktop"/> class. /// </summary> /// <param name="nativeWindow">The platform-specific reference to window object</param> /// <param name="manager">The <see cref="PointerManager"/> whose events will be raised in response to platform-specific events</param> /// <exception cref="ArgumentNullException">Is thrown when either <paramref name="nativeWindow"/> or <paramref name="manager"/> is null.</exception> public PointerPlatformDesktop(object nativeWindow, PointerManager manager) : base(nativeWindow, manager) { }
/// <summary> /// Initializes a new instance of the <see cref="PointerPlatformWinRT"/> class. /// </summary> /// <param name="nativeWindow">The platform-specific reference to window object</param> /// <param name="manager">The <see cref="PointerManager"/> whose events will be raised in response to platform-specific events</param> /// <exception cref="ArgumentNullException">Is thrown when either <paramref name="nativeWindow"/> or <paramref name="manager"/> is null.</exception> internal PointerPlatformWinRT(object nativeWindow, PointerManager manager) : base(nativeWindow, manager) { }
/// <summary> /// Initializes a new instance of <see cref="PointerPlatformDesktopWpf"/> class. /// </summary> /// <param name="nativeWindow">The platform-specific reference to window object</param> /// <param name="manager">The <see cref="PointerManager"/> whose events will be raised in response to platform-specific events</param> /// <exception cref="ArgumentNullException">Is thrown when either <paramref name="nativeWindow"/> or <paramref name="manager"/> is null.</exception> public PointerPlatformDesktopWpf(object nativeWindow, PointerManager manager) : base(nativeWindow, manager) { }