Esempio n. 1
0
        public void GetsAllPressedModifiers()
        {
            var nmm = new NativeMethodsMock()
            {
                PressedKeys =
                {
                    VirtualKey.VK_LCONTROL,
                    (VirtualKey)'A',
                },
            };

            using var mkw = new ModifierKeysWatcher(nmm);

            var key1 = FromXml <DeviceKey>("<Key1 Device='Keyboard' Key='Key_LeftControl' />");
            var key2 = FromXml <DeviceKey>("<Key1 Device='Keyboard' Key='Key_LeftShift' />");
            var key3 = FromXml <DeviceKey>("<Key2 Device='Keyboard' Key='Key_A' />");

            mkw.Watch(new[] { key1, key2, key3 }, "en-US", false);

            var keys = mkw.InvokePrivateMethod <IEnumerable <DeviceKey> >("GetAllPressedModifiers").ToList();

            Assert.Contains(key1, keys);
            Assert.DoesNotContain(key2, keys);
            Assert.Contains(key3, keys);
        }
 private void BindingsWatcher_Changed(object sender, BindingPreset e)
 {
     _modifierKeysWatcher.Watch(GetAllModifiers(e.Bindings.Values), e.KeyboardLayout);
     _gameState.BindingPreset = e;
     OnChanged(ChangeType.BindingPreset);
 }
 private void BindingsWatcher_Changed(object sender, BindingPreset e)
 {
     _modifierKeysWatcher.Watch(GetAllModifiers(e.Bindings.Values));
     GameState.Bindings = e.Bindings;
     OnChanged();
 }