Example #1
0
        private void HandleMouseDetailsClick(Object sender, RoutedEventArgs e)
        {
            var    capabilities = new MouseCapabilities();
            String message;

            if (capabilities.MousePresent == 1)
            {
                var rawMessage =
                    "There is a mouse present.  " +
                    "The connected mice have a max of {0} buttons.  " +
                    "There {1} a vertical wheel present.  " +
                    "There {2} a horizontal wheel present. " +
                    "Mouse buttons {3} been swapped.";

                message = String.Format(rawMessage
                                        , capabilities.NumberOfButtons
                                        , capabilities.VerticalWheelPresent == 1 ? "is" : "is not"
                                        , capabilities.HorizontalWheelPresent == 1 ? "is" : "is not"
                                        , capabilities.SwapButtons == 1 ? "have" : "have not"
                                        );
            }
            else
            {
                message = "There are no mice present.";
            }
            ShowMessage(message, "Mouse Properties");
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        public DeviceGestureService()
        {
            IsHardwareBackButtonPresent   = ApiInformation.IsEventPresent("Windows.Phone.UI.Input.HardwareButtons", "BackPressed");
            IsHardwareCameraButtonPresent = ApiInformation.IsEventPresent("Windows.Phone.UI.Input.HardwareButtons", "CameraPressed");

            IsKeyboardPresent = new KeyboardCapabilities().KeyboardPresent != 0;
            IsMousePresent    = new MouseCapabilities().MousePresent != 0;
            IsTouchPresent    = new TouchCapabilities().TouchPresent != 0;

            if (IsHardwareBackButtonPresent)
            {
                HardwareButtons.BackPressed += OnHardwareButtonsBackPressed;
            }

            if (IsHardwareCameraButtonPresent)
            {
                HardwareButtons.CameraHalfPressed += OnHardwareButtonCameraHalfPressed;
                HardwareButtons.CameraPressed     += OnHardwareButtonCameraPressed;
                HardwareButtons.CameraReleased    += OnHardwareButtonCameraReleased;
            }

            if (IsMousePresent)
            {
                MouseDevice.GetForCurrentView().MouseMoved += OnMouseMoved;
            }

            SystemNavigationManager.GetForCurrentView().BackRequested += OnSystemNavigationManagerBackRequested;

            Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += OnAcceleratorKeyActivated;

            Window.Current.CoreWindow.PointerPressed += OnPointerPressed;
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        public DeviceGestureService()
        {
            IsHardwareBackButtonPresent   = ApiInformation.IsEventPresent("Windows.Phone.UI.Input.HardwareButtons", "BackPressed");
            IsHardwareCameraButtonPresent = ApiInformation.IsEventPresent("Windows.Phone.UI.Input.HardwareButtons", "CameraPressed");

            IsKeyboardPresent = new KeyboardCapabilities().KeyboardPresent != 0;
            IsMousePresent    = new MouseCapabilities().MousePresent != 0;
            IsTouchPresent    = new TouchCapabilities().TouchPresent != 0;
        }
Example #4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            todayListView.SelectedIndex = weekListView.SelectedIndex = monthListView.SelectedIndex = -1;

            MouseCapabilities mouseCapabilities = new MouseCapabilities();
            bool hasMouse = mouseCapabilities.MousePresent != 0;
        }
Example #5
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            RepoListView.SelectedIndex = StarredRepoListView.SelectedIndex = -1;

            ViewModel.User = (User)e.Parameter;

            MouseCapabilities mouseCapabilities = new MouseCapabilities();
            bool hasMouse = mouseCapabilities.MousePresent != 0;
        }
Example #6
0
        public override void Initialize(InputManager inputManager)
        {
            var mouseCapabilities = new MouseCapabilities();

            if (mouseCapabilities.MousePresent > 0)
            {
                pointer = new MouseUWP(this, coreWindow);
                RegisterDevice(pointer);
            }

            var keyboardCapabilities = new KeyboardCapabilities();

            if (keyboardCapabilities.KeyboardPresent > 0)
            {
                keyboard = new KeyboardUWP(this, coreWindow);
                RegisterDevice(keyboard);
            }

            // get sensor default instances
            windowsAccelerometer = WindowsAccelerometer.GetDefault();
            if (windowsAccelerometer != null)
            {
                accelerometer = new AccelerometerSensor(this, "UWP");
                RegisterDevice(accelerometer);
            }

            windowsCompass = WindowsCompass.GetDefault();
            if (windowsCompass != null)
            {
                compass = new CompassSensor(this, "UWP");
                RegisterDevice(compass);
            }

            windowsGyroscope = WindowsGyroscope.GetDefault();
            if (windowsGyroscope != null)
            {
                gyroscope = new GyroscopeSensor(this, "UWP");
                RegisterDevice(gyroscope);
            }

            windowsOrientation = WindowsOrientation.GetDefault();
            if (windowsOrientation != null)
            {
                orientation = new OrientationSensor(this, "UWP");
                RegisterDevice(orientation);
            }

            // Virtual sensors
            if (windowsOrientation != null && windowsAccelerometer != null)
            {
                gravity          = new GravitySensor(this, "UWP");
                userAcceleration = new UserAccelerationSensor(this, "UWP");
                RegisterDevice(gravity);
                RegisterDevice(userAcceleration);
            }

            Gamepad.GamepadAdded   += GamepadOnGamepadAdded;
            Gamepad.GamepadRemoved += GamepadOnGamepadRemoved;

            Scan();
        }
Example #7
0
        public override void Initialize(InputManager inputManager)
        {
            var nativeWindow = inputManager.Game.Window.NativeWindow;

            CoreWindow coreWindow;

            if (nativeWindow.Context == AppContextType.UWPCoreWindow)
            {
                coreWindow = (CoreWindow)nativeWindow.NativeWindow;
            }
            else if (nativeWindow.Context == AppContextType.UWPXaml)
            {
                coreWindow = Window.Current.CoreWindow;
            }
            else
            {
                throw new ArgumentException(string.Format("WindowContext [{0}] not supported", nativeWindow.Context));
            }

            var mouseCapabilities = new MouseCapabilities();

            if (mouseCapabilities.MousePresent > 0)
            {
                pointer = new MouseUWP(this, coreWindow);
                RegisterDevice(pointer);
            }

            var keyboardCapabilities = new KeyboardCapabilities();

            if (keyboardCapabilities.KeyboardPresent > 0)
            {
                keyboard = new KeyboardUWP(this, coreWindow);
                RegisterDevice(keyboard);
            }

            // get sensor default instances
            windowsAccelerometer = WindowsAccelerometer.GetDefault();
            if (windowsAccelerometer != null)
            {
                accelerometer = new AccelerometerSensor(this, "UWP");
                RegisterDevice(accelerometer);
            }

            windowsCompass = WindowsCompass.GetDefault();
            if (windowsCompass != null)
            {
                compass = new CompassSensor(this, "UWP");
                RegisterDevice(compass);
            }

            windowsGyroscope = WindowsGyroscope.GetDefault();
            if (windowsGyroscope != null)
            {
                gyroscope = new GyroscopeSensor(this, "UWP");
                RegisterDevice(gyroscope);
            }

            windowsOrientation = WindowsOrientation.GetDefault();
            if (windowsOrientation != null)
            {
                orientation = new OrientationSensor(this, "UWP");
                RegisterDevice(orientation);
            }

            // Virtual sensors
            if (windowsOrientation != null && windowsAccelerometer != null)
            {
                gravity          = new GravitySensor(this, "UWP");
                userAcceleration = new UserAccelerationSensor(this, "UWP");
                RegisterDevice(gravity);
                RegisterDevice(userAcceleration);
            }

            Gamepad.GamepadAdded   += GamepadOnGamepadAdded;
            Gamepad.GamepadRemoved += GamepadOnGamepadRemoved;

            Scan();
        }
Example #8
0
        /// <summary>
        /// Is mouse allowed.
        /// </summary>
        private static bool IsMouseAllowed()
        {
            var mouseCapabilities = new MouseCapabilities();

            return(mouseCapabilities.MousePresent != 0 && mouseCapabilities.NumberOfButtons >= 2);
        }
        /// <summary>
        /// Returns whether a Mouse is present on the current device. Get more mouse capabilities information by using <see cref="MouseCapabilities"/>.
        /// </summary>
        public static bool IsMousePresent()
        {
            MouseCapabilities mouse = new MouseCapabilities();

            return(mouse.MousePresent > 0);
        }