public KeyModifiedStep(KeystrokesSettings Settings, KeymapViewModel Keymap) { _keymap = Keymap; _keystrokesSettings = Settings; _modifierStates = ModifierStates.GetCurrent(); }
private void LateUpdate() { // удаление ImDone модификаторов с вызовом OnDisable Modifiers.RemoveAll(x => x.ImDone); // заполнение States для танка перебором всех модификаторов в Modifiers States = new ModifierStates(); foreach (Modifier modifier in Modifiers) { if (modifier.GetModifierStates().HasFlag(ModifierStates.MODIFIER_STATE_ATTACK_IMMUNE) && !States.HasFlag(ModifierStates.MODIFIER_STATE_ATTACK_IMMUNE)) { States |= ModifierStates.MODIFIER_STATE_ATTACK_IMMUNE; } } }
private void NativeHookWrapper_KeyboardHookCalled(object sender, KeyboardHookEventArgs e) { lock (_syncRootMods) { if (ModifierStates.ContainsKey(e.Key)) { bool newValue = e.Type == KeyboardHookEventArgs.EventType.KeyDown; if (ModifierStates[e.Key] != newValue) { ModifierStates[e.Key] = newValue; ModifierStateChanged?.Invoke(this, EventArgs.Empty); } } else { if (e.Type == KeyboardHookEventArgs.EventType.KeyDown) { KeyEvent?.Invoke(this, e); } } } }
/// <summary> /// Update the array of modifier state. /// </summary> /// <param name="index">The index of the modifier</param> /// <param name="side">The state of the modifier</param> /// <param name="released">Whether the modifier was released or pressed</param> private void updateModifierState(ModifierIndexes index, ModifierStates side, bool released) { if (released) mModifierStates[(uint)index] &= (~side); else mModifierStates[(uint)index] |= side; }