internal KeySetting CreateNew(Win32.VK inputKey)
        {
            ConfigurationElement element  = CreateNewElement();
            KeySetting           settings = element as KeySetting;

            settings.InputKey  = inputKey;
            settings.OutputKey = inputKey;
            base.BaseAdd(element);
            return(settings);
        }
 public KeySetting GetOrCreateNew(Win32.VK inputKey)
 {
     foreach (KeySetting s in this)
     {
         if (s.InputKey.Equals(inputKey))
         {
             return(s);
         }
     }
     return(CreateNew(inputKey));
 }
Beispiel #3
0
 private void ToggleButton_Unchecked(object sender, RoutedEventArgs e)
 {
     try
     {
         Win32.VK vk = (Win32.VK)Enum.Parse(typeof(Win32.VK), (e.OriginalSource as System.Windows.Controls.Primitives.ToggleButton).Tag as string, true);
         Mubox.Configuration.KeySetting keySetting;
         if (KeySettings.TryGetKeySetting(vk, out keySetting))
         {
             this.DisableCallback(keySetting);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
         Debug.WriteLine(ex.StackTrace);
     }
 }
        void OnInput(IntPtr hwnd, IntPtr code, IntPtr hRawInput)
        {
            uint dwSize = 0;

            GetRawInputData(hRawInput, (uint)RID.Input, IntPtr.Zero, ref dwSize, (uint)Marshal.SizeOf(typeof(RAWINPUTHEADER)));

            IntPtr buffer = Marshal.AllocHGlobal((int)dwSize);

            if (GetRawInputData(hRawInput, (uint)RID.Input, buffer, ref dwSize, (uint)Marshal.SizeOf(typeof(RAWINPUTHEADER))) == dwSize)
            {
                RAWINPUT raw = (RAWINPUT)Marshal.PtrToStructure(buffer, typeof(RAWINPUT));

                Win32.VK vk = (Win32.VK)raw.keyboard.VKey;

                Console.WriteLine("RAWINPUT.header->hDevice: " + raw.header.hDevice + " key: " + raw.keyboard.VKey + " (" + vk.ToString() + ")");

                _callbackRawInput(raw.header.hDevice, (Win32.VK)raw.keyboard.VKey);
            }
        }
        // TODO: You'd probably want to convert this into regular Key etc
        private void OnRawInput(IntPtr hDevice, Win32.VK key)
        {
            // TODO: You really want to use an ObservableDictionary instead of this fun
            var found = false;

            foreach (var item in Keyboards)
            {
                if (item.Device == hDevice.ToString())
                {
                    found = true;

                    item.Key = key.ToString();
                    break;
                }
            }

            if (!found)
            {
                Keyboards.Add(new RawKeyboard()
                {
                    Device = hDevice.ToString(), Key = key.ToString()
                });
            }
        }
Beispiel #6
0
 public static bool GetKeyStateUp(Win32.VK vk)
 {
     return(!Convert.ToBoolean(Win32.GetAsyncKeyState(vk) & 0x8000));
 }
 public bool TryGetKeySetting(Win32.VK vk, out KeySetting keySetting)
 {
     keySetting = base.BaseGet(vk) as KeySetting;
     return(keySetting != null);
 }
 public void Remove(Win32.VK inputKey)
 {
     base.BaseRemove(inputKey);
 }