Пример #1
0
 public NintyControl()
 {
     _currentState = ShiftState.None;
     InitializeComponent();
     Loaded         += UserControl_Loaded;
     subMenu.Loaded += ContextMenu_Loaded;
 }
        private void ChangeShiftState(ShiftState state)
        {
            IniFile ini = new IniFile();

            ini.Load(IniData.SettingIniFile);
            IniSection resSect       = ini["Resources"];
            string     keyPadResPath = System.IO.Directory.GetCurrentDirectory() + $@"{resSect["ResourceFolder"]}{resSect["KeyPadFolder"]}";

            switch (state)
            {
            case ShiftState.NONE:
                Shift_Key(Shift.LOWER);
                shiftState = ShiftState.NONE;
                Btn_Key_ShiftL.BackgroundImage = Image.FromFile(keyPadResPath + @"\n_shiftL.png");
                Btn_Key_ShiftR.BackgroundImage = Image.FromFile(keyPadResPath + @"\n_shiftR.png");
                break;

            case ShiftState.ONETIME:
                Shift_Key(Shift.UPPER);
                shiftState = ShiftState.ONETIME;
                Btn_Key_ShiftL.BackgroundImage = Image.FromFile(keyPadResPath + @"\n_shiftL_OT.png");
                Btn_Key_ShiftR.BackgroundImage = Image.FromFile(keyPadResPath + @"\n_shiftR_OT.png");
                break;

            case ShiftState.CONTINUOUS:
                Shift_Key(Shift.UPPER);
                shiftState = ShiftState.CONTINUOUS;
                Btn_Key_ShiftL.BackgroundImage = Image.FromFile(keyPadResPath + @"\n_shiftL_CNT.png");
                Btn_Key_ShiftR.BackgroundImage = Image.FromFile(keyPadResPath + @"\n_shiftR_CNT.png");
                break;
            }
        }
Пример #3
0
        public void ChangeState(ShiftState newState)
        {
            if (_currentState != newState)
            {
                // TODO: This would unpress any keys from all controllers, make it device specific
                KeyboardDirector.Access.Release();
                MouseDirector.Access.Release();
                _currentState = newState;

                _nintroller.SetPlayerLED((int)newState + 1);

                Dispatcher.Invoke(new Action(() =>
                {
                    if (newState == ShiftState.None)
                    {
                        _controller.ChangeLEDs(true, false, false, false);
                    }
                    else if (newState == ShiftState.Red)
                    {
                        _controller.ChangeLEDs(false, true, false, false);
                    }
                    else if (newState == ShiftState.Blue)
                    {
                        _controller.ChangeLEDs(false, false, true, false);
                    }
                    else if (newState == ShiftState.Green)
                    {
                        _controller.ChangeLEDs(false, false, false, true);
                    }
                }));
            }
        }
Пример #4
0
        private void UpdateKeyboardShift(ShiftState shiftState)
        {
            m_shiftState = shiftState;
            SetValue(IsShiftHeldProperty, IsShiftHeld);
            SetValue(IsShiftPressedProperty, IsShiftPressed);

            UpdateButtonLabels();
        }
Пример #5
0
 private void OnShiftChanged(ShiftState shift)
 {
     if (null != ShiftChanged)
     {
         ShiftChanged(this, new ShiftChangedEventArgs {
             ShiftState = shift
         });
     }
 }
Пример #6
0
        void ProcessKeyShiftState(IntPtr hkl, KeysEx[] lpKeyState, uint iKey, ShiftState ss, KeyboardLayoutContent kbl, Dictionary <char, DeadKey> deadKeys)
        {
            // Skip Alt and Shift+Alt because they ain't supported
            if (ss == ShiftState.Menu || ss == ShiftState.ShftMenu)
            {
                return;
            }

            // Scratchpad used in many places
            StringBuilder sbBuffer;

            for (int caps = 0; caps <= 1; caps++)
            {
                Utilities.ClearKeyboardBuffer((uint)KeysEx.VK_DECIMAL, kbl.Keys[(uint)KeysEx.VK_DECIMAL].SC, hkl);
                Utilities.FillKeyState(kbl, lpKeyState, ss, (caps == 0));
                sbBuffer = new StringBuilder(10);
                int rc = NativeMethods.User32.ToUnicodeEx((uint)kbl.Keys[iKey].VK, kbl.Keys[iKey].SC, lpKeyState, sbBuffer, sbBuffer.Capacity, 0, hkl);
                if (rc > 0)
                {
                    if (sbBuffer.Length == 0)
                    {
                        // Someone defined NULL on the keyboard; let's coddle them
                        kbl.Keys[iKey].SetShiftState(ss, "\u0000", false, (caps == 0));
                    }
                    else
                    {
                        if ((rc == 1) &&
                            (ss == ShiftState.Ctrl || ss == ShiftState.ShftCtrl) &&
                            ((uint)kbl.Keys[iKey].VK == ((uint)sbBuffer[0] + 0x40)))
                        {
                            // ToUnicodeEx has an internal knowledge about those
                            // VK_A ~ VK_Z keys to produce the control characters,
                            // when the conversion rule is not provided in keyboard
                            // layout files
                            continue;
                        }
                        kbl.Keys[iKey].SetShiftState(ss, sbBuffer.ToString().Substring(0, rc), false, (caps == 0));
                    }
                }
                else if (rc < 0)
                {
                    kbl.Keys[iKey].SetShiftState(ss, sbBuffer.ToString().Substring(0, 1), true, (caps == 0));

                    // It's a dead key; let's flush out whats stored in the keyboard state.
                    Utilities.ClearKeyboardBuffer((uint)KeysEx.VK_DECIMAL, kbl.Keys[(uint)KeysEx.VK_DECIMAL].SC, hkl);
                    char ch = kbl.Keys[iKey].GetShiftState(ss, caps == 0).Characters[0];
                    if (deadKeys.ContainsKey(ch) == false)
                    {
                        DeadKey dk = Utilities.ProcessDeadKey(kbl, iKey, ss, lpKeyState, kbl.Keys, caps == 0, hkl);
                        deadKeys.Add(ch, dk);
                    }
                }
            }
        }
Пример #7
0
        // from the has been pressed list

        public bool HasBeenPressed(Keys key, ShiftState state)       // is pressed and in this state, remove from list saying it has been pressed.
        {
            bool ret = false;

            if (hasbeenpressed.ContainsKey(key) && hasbeenpressed[key] == state)
            {
                ret = true;
                hasbeenpressed.Remove(key);
            }

            return(ret);
        }
Пример #8
0
        /// <summary> Is key pressed and in this state, remove from list saying it has been pressed.</summary>
        public bool HasBeenPressed(Keys key, ShiftState state)
        {
            bool ret = false;

            if (hasbeenpressed.ContainsKey(key) && hasbeenpressed[key] == state)
            {
                ret = true;
                hasbeenpressed.Remove(key);
            }

            return(ret);
        }
Пример #9
0
        public bool IsCurrentlyPressed(ShiftState state, params Keys[] keys)  // is currently pressed and in this shift state
        {
            System.Diagnostics.Debug.Assert(keys.Length > 0);
            foreach (var k in keys)
            {
                if (IsCurrentlyPressed(state, k))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #10
0
        /// <summary>Are any keys pressed and in this state, remove from list saying it has been pressed. </summary>
        public int HasBeenPressed(ShiftState state, params Keys[] keys)
        {
            for (int i = 0; i < keys.Length; i++)
            {
                if (hasbeenpressed.ContainsKey(keys[i]) && hasbeenpressed[keys[i]] == state)
                {
                    hasbeenpressed.Remove(keys[i]);
                    return(i);
                }
            }

            return(-1);
        }
Пример #11
0
        /// <summary> Is any keys currently pressed and in this shift state, return index into first key found which is down </summary>
        public int IsCurrentlyPressed(ShiftState state, params Keys[] keys)
        {
            System.Diagnostics.Debug.Assert(keys.Length > 0);
            for (int i = 0; i < keys.Length; i++)
            {
                if (IsCurrentlyPressed(state, keys[i]))
                {
                    return(i);
                }
            }

            return(-1);
        }
Пример #12
0
        public override bool Equals(object obj)
        {
            if (obj is ParserAction parserAction)
            {
                if (Action.Equals(parserAction.Action) &&
                    ShiftState.Equals(parserAction.ShiftState) &&
                    (Variable?.Equals(parserAction.Variable) ?? false))
                {
                    return(Handle?.ToList().SequenceEqual(parserAction.Handle) ?? false);
                }
            }

            return(false);
        }
Пример #13
0
        /// <summary>
        /// Returns an array of values that correspond to the pressed keys,
        /// processed by this keyboard layout using the specified flags.
        /// </summary>
        /// <param name="state">The keyboard state to process.</param>
        /// <param name="flags">Flags.</param>
        /// <returns>The virtual key values.</returns>
        public VirtualKeyValue[] ProcessKeys(KeyboardState state, ProcessKeysFlags flags)
        {
            ShiftState shiftState =
                (state.IsKeyDown(XnaKeys.LeftShift) || state.IsKeyDown(XnaKeys.RightShift) ? ShiftState.Shft : 0) |
                (state.IsKeyDown(XnaKeys.LeftControl) || state.IsKeyDown(XnaKeys.RightControl) ? ShiftState.Ctrl : 0) |
                // FIXME: RightAlt may be specialShiftVk, even though ShiftState.Menu is not supported in keyboard layouts
                (state.IsKeyDown(XnaKeys.LeftAlt) || state.IsKeyDown(XnaKeys.RightAlt) ? ShiftState.Menu : 0) |
                // FIXME: ensure that XnaKeys == KeysEx
                (specialShiftVk != KeysEx.None ? state.IsKeyDown((XnaKeys)specialShiftVk) ? ShiftState.Spcl : 0 : 0);

            // Toggle caps lock state on first caps lock press
            if (capsPressed == false && state.IsKeyDown(XnaKeys.CapsLock) == true)
            {
                capsLocked = !capsLocked;
            }
            capsPressed = state.IsKeyDown(XnaKeys.CapsLock);
            bool applyCapsLock = (flags & ProcessKeysFlags.IgnoreCapsLock) != 0 ? false : capsLocked;

#if IGNORED
            XnaKeys[] keys        = state.GetPressedKeys();
            KeysEx[]  pressedKeys = new KeysEx[keys.Length];
            // Filter out control keys
            int i = 0;
            foreach (XnaKeys key in keys)
            {
                VirtualKey vk = keys[(int)key];
                if (vk != null && char.IsControl(vk.GetShiftState(ShiftState.Base, false).Characters[0]) == false)
                {
                    //FIXME: ensure that XnaKeys == KeysEx
                    pressedKeys[i++] = (KeysEx)key;
                }
            }
#else
            XnaKeys[] pressedKeys = state.GetPressedKeys();
#endif
            List <VirtualKeyValue> res     = new List <VirtualKeyValue>(pressedKeys.Length);
            List <XnaKeys>         pressed = new List <Keys>();
            foreach (XnaKeys key in pressedKeys)
            {
                VirtualKey vk = keys[(int)key];
                if (vk != null)
                {
                    res.Add(vk.GetShiftState(shiftState, applyCapsLock));
                    pressed.Add(key);
                }
            }
            filteredPressedKeys = pressed.ToArray();
            return(res.ToArray());
        }
Пример #14
0
        public static bool uppercase(this ShiftState f)
        {
            switch (f)
            {
            case ShiftState.Disabled:
                return(false);

            case ShiftState.Enabled:
                return(true);

            case ShiftState.Locked:
                return(true);
            }
            return(false);
        }
        public static VKey GetVirtualKey(char c, out ShiftState shift)
        {
            shift = ShiftState.NONE;
            short result = VkKeyScanEx(c, loadedKeyboard);

            if (result == -1)
            {
                return(VKey.UNDEFINED);
            }

            VKey key = (VKey)(result & 0xFF);

            shift = (ShiftState)(result >> 8);

            return(key);
        }
Пример #16
0
        public void Apply(float value)
        {
            bool isDown = value > Threshold;

            if (_isEnabled != isDown)
            {
                _isEnabled = isDown;

                if (Toggles)
                {
                    if (isDown)
                    {
                        if (ToggleStates.Contains(_control.CurrentShiftState))
                        {
                            int index = ToggleStates.IndexOf(_control.CurrentShiftState);

                            if (ToggleStates.Count > index + 1)
                            {
                                _control.ChangeState(ToggleStates[index + 1]);
                            }
                            else
                            {
                                _control.ChangeState(ToggleStates[0]);
                            }
                        }
                        else
                        {
                            _control.ChangeState(ToggleStates[0]);
                        }
                    }
                }
                else if (isDown)
                {
                    if (TargetState != _control.CurrentShiftState)
                    {
                        _previousState = _control.CurrentShiftState;
                    }

                    _control.ChangeState(TargetState);
                }
                else
                {
                    _control.ChangeState(_previousState);
                }
            }
        }
Пример #17
0
        void ProcessKeys(IntPtr hkl, KeyboardLayoutContent kbl)
        {
            Dictionary <char, DeadKey> deadKeys = new Dictionary <char, DeadKey>();

            KeysEx[] lpKeyState = new KeysEx[256];

            for (uint iKey = 0; iKey < kbl.Keys.Length; iKey++)
            {
                if (kbl.Keys[iKey] != null)
                {
                    for (ShiftState ss = ShiftState.Base; ss <= kbl.MaxShiftState; ss++)
                    {
                        ProcessKeyShiftState(hkl, lpKeyState, iKey, ss, kbl, deadKeys);
                    }
                }
            }

            kbl.DeadKeys = deadKeys;
        }
        public static KeyEvent[] ToKeyboardInput(this string input)
        {
            List <KeyEvent> events       = new List <KeyEvent>();
            ShiftState      pressedState = ShiftState.NONE;

            for (int i = 0; i < input.Length; i++)
            {
                ShiftState newState;
                VKey       key = GetVirtualKey(input[i], out newState);

                if (!newState.Equals(pressedState))            //state is different from current one
                {
                    if (!pressedState.Equals(ShiftState.NONE)) //release all keys
                    {
                        events.AddRange(pressedState.ToEvents(false));
                    }

                    if (!newState.Equals(ShiftState.NONE)) //press new keys
                    {
                        events.AddRange(newState.ToEvents(true));
                    }

                    pressedState = newState;
                }

                KeyEvent down = new KeyEvent {
                    keycode = key, downpress = true
                };
                KeyEvent up = new KeyEvent {
                    keycode = key, downpress = false
                };

                events.Add(down);
                events.Add(up);
            }

            if (!pressedState.Equals(ShiftState.NONE)) //release last keys
            {
                events.AddRange(pressedState.ToEvents(false));
            }

            return(events.ToArray());
        }
        public static KeyEvent[] ToEvents(this ShiftState shift, bool downpress)
        {
            List <KeyEvent> events = new List <KeyEvent>();

            ShiftState[] flags = new ShiftState[] { ShiftState.ALT, ShiftState.CTRL, ShiftState.HANKAKU, ShiftState.SHIFT };
            VKey[]       mapto = new VKey[] { VKey.ALT, VKey.CONTROL, VKey.UNDEFINED, VKey.SHIFT };

            for (int i = 0; i < flags.Length; i++)
            {
                if ((shift | flags[i]) > 0)
                {
                    events.Add(new KeyEvent()
                    {
                        keycode = mapto[i], downpress = downpress
                    });
                }
            }

            return(events.ToArray());
        }
Пример #20
0
        private static void AddInputs(
            List <NativeMethods.INPUT> inputs,
            VirtualKey virtualKey,
            ShiftState shiftState = 0
            )
        {
            if ((shiftState & ShiftState.Shift) != 0)
            {
                AddInputs(inputs, VirtualKey.Shift, NativeMethods.KEYEVENTF_NONE);
            }

            if ((shiftState & ShiftState.Ctrl) != 0)
            {
                AddInputs(inputs, VirtualKey.Control, NativeMethods.KEYEVENTF_NONE);
            }

            if ((shiftState & ShiftState.Alt) != 0)
            {
                AddInputs(inputs, VirtualKey.Alt, NativeMethods.KEYEVENTF_NONE);
            }

            AddInputs(inputs, virtualKey, NativeMethods.KEYEVENTF_NONE);
            AddInputs(inputs, virtualKey, NativeMethods.KEYEVENTF_KEYUP);

            if ((shiftState & ShiftState.Shift) != 0)
            {
                AddInputs(inputs, VirtualKey.Shift, NativeMethods.KEYEVENTF_KEYUP);
            }

            if ((shiftState & ShiftState.Ctrl) != 0)
            {
                AddInputs(inputs, VirtualKey.Control, NativeMethods.KEYEVENTF_KEYUP);
            }

            if ((shiftState & ShiftState.Alt) != 0)
            {
                AddInputs(inputs, VirtualKey.Alt, NativeMethods.KEYEVENTF_KEYUP);
            }
        }
Пример #21
0
        public void AddDeadKeyRow(uint scancode, int caps, ShiftState ss,
                                  char combinedCharacter)
        {
            char value;
            ushort icaps, uindex, iss, isc;
            if (caps == 1)
                icaps = 16;
            else
                icaps = 0;
            isc = Convert.ToUInt16(scancode);
            isc *= 256;
            iss = Convert.ToUInt16((int)ss);
            uindex = (ushort)(isc + iss + icaps);

            if (this.m_rgdeadkeys.TryGetValue(uindex, out value))
            {
                this.m_rgdeadkeys[uindex] = combinedCharacter;
            }
            else
            {
                this.m_rgdeadkeys.Add(uindex, combinedCharacter);
            }
        }
Пример #22
0
 public void SetShiftStateFlag(VirtualKey virtualKey, bool capslock)
 {
     this.shiftState |= VirtualKeyToShiftState(virtualKey);
     ChangeLabel(capslock);
 }
Пример #23
0
 private static void FillKeyState(KeysEx[] lpKeyState, ShiftState ss, bool fCapsLock)
 {
     lpKeyState[(int)KeysEx.VK_SHIFT] = (((ss & ShiftState.Shft) != 0) ? (KeysEx)0x80 : (KeysEx)0x00);
       lpKeyState[(int)KeysEx.VK_CONTROL] = (((ss & ShiftState.LCtrl) != 0) ? (KeysEx)0x80 : (KeysEx)0x00);
       lpKeyState[(int)KeysEx.VK_MENU] = (((ss & ShiftState.Menu) != 0) ? (KeysEx)0x80 : (KeysEx)0x00);
       if (Loader.RCtrlVk != KeysEx.None) {
     // The RCtrl key has been assigned, so let's include it
     lpKeyState[(int)Loader.RCtrlVk] = (((ss & ShiftState.RCtrl) != 0) ? (KeysEx)0x80 : (KeysEx)0x00);
       }
       lpKeyState[(int)KeysEx.VK_CAPITAL] = (fCapsLock ? (KeysEx)0x01 : (KeysEx)0x00);
 }
Пример #24
0
 public void SetShiftState(ShiftState shiftState, string value, bool isDeadKey, bool capsLock)
 {
     this.m_rgfDeadKey[(uint)shiftState, (capsLock ? 1 : 0)] = isDeadKey;
       this.m_rgss[(uint)shiftState, (capsLock ? 1 : 0)] = value;
 }
Пример #25
0
 public string GetShiftState(ShiftState shiftState, bool capsLock)
 {
     if (this.m_rgss[(uint)shiftState, (capsLock ? 1 : 0)] == null) {
     return ("");
       }
       return (this.m_rgss[(uint)shiftState, (capsLock ? 1 : 0)]);
 }
Пример #26
0
 // The keyboard layout
 private static DeadKey ProcessDeadKey(
     uint iKeyDead,              // The index into the VirtualKey of the dead key
     ShiftState shiftStateDead,  // The shiftstate that contains the dead key
     KeysEx[] lpKeyStateDead,    // The key state for the dead key
     VirtualKey[] rgKey,         // Our array of dead keys
     bool fCapsLock,             // Was the caps lock key pressed?
     IntPtr hkl)
 {
     KeysEx[] lpKeyState = new KeysEx[256];
       DeadKey deadKey = new DeadKey(rgKey[iKeyDead].GetShiftState(shiftStateDead, fCapsLock)[0]);
       for (uint iKey = 0; iKey < rgKey.Length; iKey++) {
     if (rgKey[iKey] != null) {
       StringBuilder sbBuffer = new StringBuilder(10);   // Scratchpad we use many places
       for (ShiftState ss = ShiftState.Base; ss <= Loader.MaxShiftState; ss++) {
     int rc = 0;
     if (ss == ShiftState.Menu || ss == ShiftState.ShftMenu) {
       // Alt and Shift+Alt don't work, so skip them
       continue;
     }
     for (int caps = 0; caps <= 1; caps++) {
       // First the dead key
       while (rc >= 0) {
         // We know that this is a dead key coming up, otherwise
         // this function would never have been called. If we do
         // *not* get a dead key then that means the state is
         // messed up so we run again and again to clear it up.
         // Risk is technically an infinite loop but per Hiroyama
         // that should be impossible here.
         rc = ToUnicodeEx((uint)rgKey[iKeyDead].VK, rgKey[iKeyDead].SC,
                          lpKeyStateDead, sbBuffer, sbBuffer.Capacity, 0, hkl);
       }
       // Now fill the key state for the potential base character
       FillKeyState(lpKeyState, ss, (caps != 0));
       sbBuffer = new StringBuilder(10);
       rc = ToUnicodeEx((uint)rgKey[iKey].VK, rgKey[iKey].SC,
                        lpKeyState, sbBuffer, sbBuffer.Capacity, 0, hkl);
       if (rc == 1) {
         // That was indeed a base character for our dead key.
         // And we now have a composite character. Let's run
         // through one more time to get the actual base
         // character that made it all possible?
         char combchar = sbBuffer[0];
         sbBuffer = new StringBuilder(10);
         rc = ToUnicodeEx((uint)rgKey[iKey].VK, rgKey[iKey].SC,
                          lpKeyState, sbBuffer, sbBuffer.Capacity, 0, hkl);
         char basechar = sbBuffer[0];
         if (deadKey.DeadCharacter == combchar) {
           // Since the combined character is the same as the dead key,
           // we must clear out the keyboard buffer.
           ClearKeyboardBuffer((uint)KeysEx.VK_DECIMAL, rgKey[(uint)KeysEx.VK_DECIMAL].SC, hkl);
         }
         if ((((ss == ShiftState.LCtrl) || (ss == ShiftState.ShftLCtrl)) &&
             (char.IsControl(basechar))) ||
             (basechar.Equals(combchar))) {
           // ToUnicodeEx has an internal knowledge about those
           // VK_A ~ VK_Z keys to produce the control characters,
           // when the conversion rule is not provided in keyboard
           // layout files
           // Additionally, dead key state is lost for some of these
           // character combinations, for unknown reasons.
           // Therefore, if the base character and combining are equal,
           // and its a CTRL or CTRL+SHIFT state, and a control character
           // is returned, then we do not add this "dead key" (which
           // is not really a dead key).
           continue;
         }
         if (caps == 0 && (ss == ShiftState.Base || ss == ShiftState.Shft))
           deadKey.AddDeadKeyRow(rgKey[iKey].SC, caps, ss, combchar);
       } else if (rc > 1) {
         // Not a valid dead key combination, sorry! We just ignore it.
       } else if (rc < 0) {
         // It's another dead key, so we ignore it (other than to flush it from the state)
         ClearKeyboardBuffer((uint)KeysEx.VK_DECIMAL, rgKey[(uint)KeysEx.VK_DECIMAL].SC, hkl);
       }
     }
       }
     }
       }
       return deadKey;
 }
Пример #27
0
 //need a better way to do this ......
 static bool IsAltOrShiftAlt(ShiftState ss)
 {
     switch (ss)
     {
         case ShiftState.LMenu:
         case ShiftState.RMenu:
         case (ShiftState.LMenu | ShiftState.RMenu):
         case (ShiftState.LMenu | ShiftState.LShft):
         case (ShiftState.LMenu | ShiftState.RShft):
         case (ShiftState.RMenu | ShiftState.LShft):
         case (ShiftState.RMenu | ShiftState.RShft):
         case (ShiftState.LMenu | ShiftState.RShft | ShiftState.LShft):
         case (ShiftState.RMenu | ShiftState.RShft | ShiftState.LShft):
         case (ShiftState.LMenu | ShiftState.RMenu | ShiftState.LShft):
         case (ShiftState.LMenu | ShiftState.RMenu | ShiftState.RShft):
         case (ShiftState.LMenu | ShiftState.RMenu | ShiftState.RShft | ShiftState.LShft):
             return true;
         default:
             return false;
     }
 }
Пример #28
0
 private void FillShiftState(VirtualKey[] lpKeyState, out ShiftState ss, out bool caps)
 {
     ss = ShiftState.None;
     if ((((int)lpKeyState[(int)VirtualKey.VK_LSHIFT] & 0x80) == 0x80)
         && (((int)lpKeyState[(int)VirtualKey.VK_SHIFT] & 0x80) == 0x80))
     {
         ss |= ShiftState.LShft;
     }
     if ((((int)lpKeyState[(int)VirtualKey.VK_RSHIFT] & 0x80) == 0x80)
         && (((int)lpKeyState[(int)VirtualKey.VK_SHIFT] & 0x80) == 0x80))
     {
         ss |= ShiftState.RShft;
     }
     if ((((int)lpKeyState[(int)VirtualKey.VK_LCONTROL] & 0x80) == 0x80)
         && (((int)lpKeyState[(int)VirtualKey.VK_CONTROL] & 0x80) == 0x80))
     {
         ss |= ShiftState.LCtrl;
     }
     if ((((int)lpKeyState[(int)VirtualKey.VK_RCONTROL] & 0x80) == 0x80)
         && (((int)lpKeyState[(int)VirtualKey.VK_CONTROL] & 0x80) == 0x80))
     {
         ss |= ShiftState.RCtrl;
     }
     if ((((int)lpKeyState[(int)VirtualKey.VK_LMENU] & 0x80) == 0x80)
         && (((int)lpKeyState[(int)VirtualKey.VK_MENU] & 0x80) == 0x80))
     {
         ss |= ShiftState.LMenu;
     }
     if ((((int)lpKeyState[(int)VirtualKey.VK_RMENU] & 0x80) == 0x80)
         && (((int)lpKeyState[(int)VirtualKey.VK_MENU] & 0x80) == 0x80))
     {
         ss |= ShiftState.RMenu;
     }
     if (((int)lpKeyState[(int)VirtualKey.VK_CAPITAL] & 0x01) == 0x01)
         caps = true;
     else
         caps = false;
 }
Пример #29
0
 public bool IsDeadKey(ShiftState ss, bool capsLock)
 {
     return m_rgfDeadKey[(int)ss, (capsLock ? 1 : 0)];
 }
Пример #30
0
        private void FillKeyState(VirtualKey[] lpKeyState, ShiftState ss, bool fCapsLock)
        {
            if ((ss & ShiftState.LShft) == ShiftState.LShft)
            {
                lpKeyState[(int)VirtualKey.VK_SHIFT] = lpKeyState[(int)VirtualKey.VK_LSHIFT] = (VirtualKey)0x80;
            }

            if ((ss & ShiftState.RShft) == ShiftState.RShft)
            {
                lpKeyState[(int)VirtualKey.VK_SHIFT] = lpKeyState[(int)VirtualKey.VK_RSHIFT] = (VirtualKey)0x80;
            }

            if ((ss & ShiftState.LCtrl) == ShiftState.LCtrl)
            {
                lpKeyState[(int)VirtualKey.VK_CONTROL] = lpKeyState[(int)VirtualKey.VK_LCONTROL] = (VirtualKey)0x80;
            }

            if ((ss & ShiftState.RCtrl) == ShiftState.RCtrl)
            {
                lpKeyState[(int)VirtualKey.VK_CONTROL] = lpKeyState[(int)VirtualKey.VK_RCONTROL] = (VirtualKey)0x80;
            }

            if ((ss & ShiftState.LMenu) == ShiftState.LMenu)
            {
                lpKeyState[(int)VirtualKey.VK_MENU] = lpKeyState[(int)VirtualKey.VK_LMENU] = (VirtualKey)0x80;
            }

            if ((ss & ShiftState.RMenu) == ShiftState.RMenu)
            {
                lpKeyState[(int)VirtualKey.VK_MENU] = lpKeyState[(int)VirtualKey.VK_RMENU] = (VirtualKey)0x80;
            }

            lpKeyState[(int)VirtualKey.VK_CAPITAL] = (fCapsLock ? (VirtualKey)0x01 : (VirtualKey)0x00);
        }
Пример #31
0
 public KeyPress(VirtualKey virtualKey, ShiftState shiftState)
 {
     VirtualKey = virtualKey;
     ShiftState = shiftState;
 }
Пример #32
0
 /// <summary>
 /// Rotates the camera about theboard in the specifed direction.
 /// </summary>
 /// <param name="state">The direction in which to turn.</param>
 public void TurnBoard(ShiftState state)
 {
     if (isShifting) return;
     switch (state)
     {
         case ShiftState.Up:
             prevPosition = destPosition;
             destPosition = Vector3.Transform(CurrentPosition, Matrix.CreateRotationX(MathHelper.ToRadians(-90)));
             transitionAmount = 0.0f;
             isShifting = true;
             break;
         case ShiftState.Down:
             prevPosition = destPosition;
             destPosition = Vector3.Transform(CurrentPosition, Matrix.CreateRotationX(MathHelper.ToRadians(90)));
             transitionAmount = 0.0f;
             isShifting = true;
             break;
         case ShiftState.Right:
             prevPosition = destPosition;
             destPosition = Vector3.Transform(CurrentPosition, Matrix.CreateRotationY(MathHelper.ToRadians(90)));
             transitionAmount = 0.0f;
             isShifting = true;
             break;
         case ShiftState.Left:
             prevPosition = destPosition;
             destPosition = Vector3.Transform(CurrentPosition, Matrix.CreateRotationY(MathHelper.ToRadians(-90)));
             transitionAmount = 0.0f;
             isShifting = true;
             break;
     }
 }
Пример #33
0
 private void OnShiftChanged(ShiftState shift)
 {
     ShiftChanged?.Invoke(this, new ShiftChangedEventArgs {
         ShiftState = shift
     });
 }
Пример #34
0
 /// <summary>
 /// Checks the Shift Status for the specified keys
 /// </summary>
 /// <param name="state"></param>
 /// <returns></returns>
 public virtual bool IsShiftState(ShiftState state)
 {
     return((this.shiftState & state) != 0);
 }
Пример #35
0
        private void SendVirtualKey(InputSimulator inputSimulator, VirtualKeyCode virtualKey, ShiftState shiftState = ShiftState.None)
        {
            var modifiers = new List <VirtualKeyCode>();

            if (shiftState.HasFlag(ShiftState.Shift))
            {
                modifiers.Add(VirtualKeyCode.SHIFT);
            }

            if (shiftState.HasFlag(ShiftState.Ctrl))
            {
                modifiers.Add(VirtualKeyCode.CONTROL);
            }

            if (shiftState.HasFlag(ShiftState.Alt))
            {
                modifiers.Add(VirtualKeyCode.MENU);
            }

            inputSimulator.Keyboard.ModifiedKeyStroke(modifiers, virtualKey);
        }
Пример #36
0
        // Currently pressed

        public bool IsCurrentlyPressed(ShiftState state, Keys key)             // is currently pressed and in this shift state
        {
            return(keyspressed.ContainsKey(key) && keyspressed[key] == state);
        }
Пример #37
0
 public KeyPress(VirtualKey virtualKey, ShiftState shiftState)
 {
     this.VirtualKey = virtualKey;
     this.ShiftState = shiftState;
 }
Пример #38
0
 protected KeyPress KeyPress(VirtualKey virtualKey, ShiftState shiftState)
 {
     return(new KeyPress(virtualKey, shiftState));
 }
Пример #39
0
 protected KeyPress KeyPress(VirtualKey virtualKey, ShiftState shiftState)
 => new KeyPress(virtualKey, shiftState);
Пример #40
0
 protected KeyPress KeyPress(VirtualKey virtualKey, ShiftState shiftState)
 {
     return new KeyPress(virtualKey, shiftState);
 }
Пример #41
0
 //need a better way to do this ......
 static bool IsCtrlOrShiftCtrl(ShiftState ss)
 {
     switch (ss)
     {
         case ShiftState.LCtrl:
         case ShiftState.RCtrl:
         case (ShiftState.LCtrl | ShiftState.RCtrl):
         case (ShiftState.LCtrl | ShiftState.LShft):
         case (ShiftState.LCtrl | ShiftState.RShft):
         case (ShiftState.RCtrl | ShiftState.LShft):
         case (ShiftState.RCtrl | ShiftState.RShft):
         case (ShiftState.LCtrl | ShiftState.RShft | ShiftState.LShft):
         case (ShiftState.RCtrl | ShiftState.RShft | ShiftState.LShft):
         case (ShiftState.LCtrl | ShiftState.RCtrl | ShiftState.LShft):
         case (ShiftState.LCtrl | ShiftState.RCtrl | ShiftState.RShft):
         case (ShiftState.LCtrl | ShiftState.RCtrl | ShiftState.RShft | ShiftState.LShft):
             return true;
         default:
             return false;
     }
 }
Пример #42
0
 public NintyControl()
 {
     _currentState = ShiftState.None;
     InitializeComponent();
 }
Пример #43
0
 public static void Notify(ShiftState state)
 {
     MainPageVM?.OnStateChanged(state);
 }
Пример #44
0
        private static void AddInputs(List<NativeMethods.INPUT> inputs, VirtualKey virtualKey, ShiftState shiftState = 0)
        {
            if ((shiftState & ShiftState.Shift) != 0)
            {
                AddInputs(inputs, VirtualKey.Shift, NativeMethods.KEYEVENTF_NONE);
            }

            if ((shiftState & ShiftState.Ctrl) != 0)
            {
                AddInputs(inputs, VirtualKey.Control, NativeMethods.KEYEVENTF_NONE);
            }

            if ((shiftState & ShiftState.Alt) != 0)
            {
                AddInputs(inputs, VirtualKey.Alt, NativeMethods.KEYEVENTF_NONE);
            }

            AddInputs(inputs, virtualKey, NativeMethods.KEYEVENTF_NONE);
            AddInputs(inputs, virtualKey, NativeMethods.KEYEVENTF_KEYUP);

            if ((shiftState & ShiftState.Shift) != 0)
            {
                AddInputs(inputs, VirtualKey.Shift, NativeMethods.KEYEVENTF_KEYUP);
            }

            if ((shiftState & ShiftState.Ctrl) != 0)
            {
                AddInputs(inputs, VirtualKey.Control, NativeMethods.KEYEVENTF_KEYUP);
            }

            if ((shiftState & ShiftState.Alt) != 0)
            {
                AddInputs(inputs, VirtualKey.Alt, NativeMethods.KEYEVENTF_KEYUP);
            }
        }
        private bool processShiftState(ShiftState shiftState, KeyEvent keyEvent)
        {
            switch (shiftState)
            {
                case ShiftState.None: return false;

                case ShiftState.Shift:
                    bufferKey((byte)NativeMethods.VK_SHIFT, NativeMethods.SHIFT_CODE, keyEvent);
                    break;
                case ShiftState.Ctrl:
                    bufferKey((byte)NativeMethods.VK_CONTROL, NativeMethods.CTRL_CODE, keyEvent);
                    break;
                case ShiftState.Alt:
                    bufferKey((byte)NativeMethods.VK_MENU, NativeMethods.ALT_CODE, keyEvent);
                    break;

                default:
                    throw new Exception("Unsupported shift state detected. Cannot process PressKey request.");
            }

            return true;
        }