示例#1
0
 private void OnKeyPressed(object sender, RawInputEventArg e)
 {
     if (ActiveControl == adminTextBox || /*ActiveControl == exitTextBox ||*/ ActiveControl == entranceTextBox)
     {
         ActiveControl.Text = e.KeyPressEvent.DeviceName;
     }
 }
        /// <summary>
        /// Custom KeyDown Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnKeyPressed(object sender, RawInputEventArg e)
        {
            int controlIndex = GetLabelIndex(e.KeyPressEvent.DeviceName);

            if (controlIndex != -1)
            {
                int result = -1;
                if (e.KeyPressEvent.VKeyName != "ENTER" && int.TryParse(e.KeyPressEvent.VKeyName.Replace("D", ""), out result))
                {
                    Label control = (Label)this.FindName(string.Format("{0}{1}", TagValueLabelName, controlIndex));
                    cmx.SetTagVal(control.Content.ToString(), string.Empty);
                    cmx.SetTagVal(string.Format("{0}_D", control.Content.ToString()), "0");
                    keyNames.Add(result.ToString());
                }
                if (e.KeyPressEvent.VKeyName == "ENTER" && keyNames.Count != 0)
                {
                    for (int i = 0; i < keyNames.Count; i++)
                    {
                        if (i % 2 == 0)
                        {
                            keyNames.RemoveAt(i);
                        }
                    }

                    Label control = (Label)this.FindName(string.Format("{0}{1}", TagValueLabelName, controlIndex));
                    cmx.SetTagVal(control.Content.ToString(), String.Join("", keyNames.ToArray()));
                    cmx.SetTagVal(string.Format("{0}_D", control.Content.ToString()), "1");

                    keyNames.Clear();
                }
            }
        }
示例#3
0
        private static void RawListener_KeyPressed(object sender, RawInputEventArg e)
        {
            if (e.KeyPressEvent.KeyPressState == "MAKE")
            {
                if (e.KeyPressEvent.DeviceName.Contains("1D57"))
                {
                    Application.AddMessageFilter(Filter);
                }
            }
            else if (e.KeyPressEvent.KeyPressState == "BREAK")
            {
                Application.RemoveMessageFilter(Filter);

                if (e.KeyPressEvent.DeviceName.Contains("1D57"))
                {
                    if (e.KeyPressEvent.VKey != (int)Keys.Enter && e.KeyPressEvent.VKey != 16) // 16 = Data Link Escape
                    {
                        Buffer += string.Format("{0}", GetKeyNumericValue(e.KeyPressEvent.VKey));
                    }

                    if (e.KeyPressEvent.VKey == (int)Keys.Enter)
                    {
                        Debug.WriteLine(Buffer);
                        BarcodeScannedEventArgs m_Args = new BarcodeScannedEventArgs();
                        m_Args.Barcode   = Buffer;
                        m_Args.ScannedAt = DateTime.Now;
                        EventSink.InvokeBarcodeScanned(e.KeyPressEvent.DeviceName, m_Args);
                        Buffer = "";
                    }
                }
            }
        }
示例#4
0
 private void OnKeyPressed(object sender, RawInputEventArg e)
 {
     Device = e.KeyPressEvent.DeviceName;
     if (!uiBasicSale1.TxtCode.Focused && Device.ToLower().Contains(Pos_Barcode.ToLower()))
     {
         uiBasicSale1.TxtCode.Focus();
     }
 }
示例#5
0
 private void _kblistener_KeyPressed(object sender, RawInputEventArg e)
 {
     if (e.KeyPressEvent.DeviceName == SetUp.RfidDevID)
     {
         Handling = true;
     }
     else
     {
         Handling = false;
     }
 }
示例#6
0
 private void OnKeyPressed(object sender, RawInputEventArg e)
 {
     lblCoords.Text = "X:" + e.X + " Y:" + e.Y;
     //switch (e.KeyPressEvent.Message)
     //{
     //    case Win32.WM_KEYDOWN:
     //        Debug.WriteLine(e.KeyPressEvent.KeyPressState);
     //        break;
     //     case Win32.WM_KEYUP:
     //        Debug.WriteLine(e.KeyPressEvent.KeyPressState);
     //        break;
     //}
 }
        private void OnKeyPressed(object sender, RawInputEventArg e)
        {
            switch (e.KeyPressEvent.Message)
            {
            case Win32.WM_KEYDOWN:
            case Win32.WM_SYSKEYDOWN:
                _pressedKeys.GetOrAdd(e.KeyPressEvent.VKeyName, e.KeyPressEvent.VKey);
                break;

            case Win32.WM_KEYUP:
                _pressedKeys.TryRemove(e.KeyPressEvent.VKeyName, out int tmp);
                break;
            }
            e.Handled = true;

            if (ShowKeyMapping || _inWorkflowAddKey)
            {
                if (_inWorkflowAddKey)
                {
                    if (_pressedKeys.Count > _maxPressedKeys)
                    {
                        _pressedAddKeyCombo = _pressedKeys.ToDictionary(pair => pair.Key, pair => pair.Value);
                        _maxPressedKeys     = _pressedKeys.Count;
                        //ServiceRegistration.Get<ILogger>().Info("pressedKeys: {0}, maxPressedKEys: {1}, _pressedAddKeyCombo: {2}", _pressedKeys.Count, _maxPressedKeys, _pressedAddKeyCombo.Count);

                        _endTime = DateTime.Now.AddSeconds(5);
                        if (!_timer.Enabled)
                        {
                            _timer.Start();
                        }
                    }
                    AddKeyLabel = String.Join(" + ", string.Join(" + ", _pressedAddKeyCombo.Select(kv => kv.Key.ToString())));
                }
            }
            else
            {
                _currentInputDevice = e.KeyPressEvent.Source;
                UpdateKeymapping();
            }

            /*ServiceRegistration.Get<ILogger>().Info("Confscren: {0}", e.KeyPressEvent.DeviceHandle.ToString());
             * ServiceRegistration.Get<ILogger>().Info("Confscren: {0}", e.KeyPressEvent.DeviceType);
             * ServiceRegistration.Get<ILogger>().Info("Confscren: {0}", e.KeyPressEvent.DeviceName);
             * ServiceRegistration.Get<ILogger>().Info("Confscren: {0}", e.KeyPressEvent.Name);
             * ServiceRegistration.Get<ILogger>().Info("Confscren: {0}", e.KeyPressEvent.VKey.ToString(CultureInfo.InvariantCulture));
             * ServiceRegistration.Get<ILogger>().Info("Confscren: {0}", _rawinput.NumberOfKeyboards.ToString(CultureInfo.InvariantCulture));
             * ServiceRegistration.Get<ILogger>().Info("Confscren: {0}", e.KeyPressEvent.VKeyName);
             * ServiceRegistration.Get<ILogger>().Info("Confscren: {0}", e.KeyPressEvent.Source);
             * ServiceRegistration.Get<ILogger>().Info("Confscren: {0}", e.KeyPressEvent.KeyPressState);
             * ServiceRegistration.Get<ILogger>().Info("0x{0:X4} ({0})", e.KeyPressEvent.Message);*/
        }
示例#8
0
        private void OnKeyPressed(object sender, RawInputEventArg e)
        {
            string recordedVertualKey = e.KeyPressEvent.VKeyName;

            if ((isNaming) && (e.KeyPressEvent.KeyPressState == "MAKE"))
            {
                if (SetFileName(recordedVertualKey))
                {
                    if (fileName != "")
                    {
                        buttonName.Text = fileName;
                    }
                    else
                    {
                        buttonName.Text = "Set Configuration Name";
                    }
                    buttonName.BackColor = Control.DefaultBackColor;
                    labelMessage.Text    = "";
                    isNaming             = false;
                }
                else
                {
                    buttonName.Text = fileName + "_";
                }
            }
            else if ((isRecording) && (e.KeyPressEvent.KeyPressState != "MAKE"))
            {
                isRecording       = false;
                labelMessage.Text = "";
                int keyPosition = SearchKeyPosition(recordedVertualKey);

                if (controllerKeyToSet == "keyDelete")
                {
                    ClearKey(keyPosition, recordedVertualKey);
                    UpdateState();
                }
                else if (((recordedVertualKey == controllerKeys[0, 0]) || (recordedVertualKey == controllerKeys[0, 1])) || (controllerKeys[keyPosition, isGameMode] != null))
                {
                    if (WarningResponse("You already assigned this key to elsewhere. Do you want to keep the new setting?", "Duplicate Key"))
                    {
                        ClearKey(keyPosition, recordedVertualKey);
                        AssignKey(keyPosition, recordedVertualKey);
                    }
                }
                else
                {
                    AssignKey(keyPosition, recordedVertualKey);
                }
            }
        }
示例#9
0
 /// <summary>
 /// Custom KeyDown Event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void OnKeyPressed(object sender, RawInputEventArg e)
 {
     if (DeviceGrid.ItemsSource is DataView)
     {
         foreach (DataRowView dataRow in (DataView)DeviceGrid.ItemsSource)
         {
             if (dataRow["DeviceName"].ToString() == e.KeyPressEvent.DeviceName)
             {
                 // This is the data row view record you want...
                 DeviceGrid.SelectedItem = dataRow;
             }
         }
     }
 }
示例#10
0
 private void OnKeyPressed(object sender, RawInputEventArg e)
 {
     if (e.KeyPressEvent.VKey.ToString(CultureInfo.InvariantCulture) == "13" && hidscanner1 == null && e.KeyPressEvent.KeyPressState == "BREAK")
     {
         hidscanner1 = e.KeyPressEvent.DeviceName;
         label1.Text = "Please Scan For Operator 2";
     }
     else if (e.KeyPressEvent.VKey.ToString(CultureInfo.InvariantCulture) == "13" && hidscanner1 != null && e.KeyPressEvent.KeyPressState == "BREAK")
     {
         hidscanner2       = e.KeyPressEvent.DeviceName;
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
 }
示例#11
0
        private void _rawinput_KeyPressed(object sender, RawInputEventArg e)
        {
            if (e.KeyPressEvent.KeyPressState == "MAKE" & e.KeyPressEvent.VKeyName.ToString() != "LSHIFT")
            {
                Getrawinput.CardAsync = Getrawinput.CardAsync + e.KeyPressEvent.VKeyName.ToString();
            }

            if (Getrawinput.CardAsync != null & e.KeyPressEvent.VKeyName.ToString() != "BREAK")
            {
                if (Getrawinput.CardAsync.Length >= 5)
                {
                    Getrawinput.GetCardinfo(Getrawinput.CardAsync);
                    ShowPicture(Getrawinput.FilenameAsync);
                }
            }
        }
示例#12
0
        private void OnKeyPressed(object sender, RawInputEventArg e)
        {
            lbHandle.Focus();

            if (e.KeyPressEvent.VKey == 13 && e.KeyPressEvent.Message == Win32.WM_KEYUP)
            {
                lbHandle.Text      = e.KeyPressEvent.DeviceHandle.ToString();
                lbType.Text        = e.KeyPressEvent.DeviceType;
                lbName.Text        = e.KeyPressEvent.DeviceName;
                lbDescription.Text = e.KeyPressEvent.Name;
                lbSource.Text      = e.KeyPressEvent.Source;

                Settings.Default.barcode_scanner_name = e.KeyPressEvent.DeviceName;
                DeviceName = e.KeyPressEvent.DeviceName;
            }
        }
示例#13
0
        public void ProcessKeyInput(RawInputEventArg e)
        {
            //e.KeyPressEvent.DeviceHandle;
            //e.KeyPressEvent.DeviceType;
            //e.KeyPressEvent.DeviceName;
            //e.KeyPressEvent.Name;
            //e.KeyPressEvent.VKey.ToString(CultureInfo.InvariantCulture);
            //_rawinput.NumberOfKeyboards.ToString(CultureInfo.InvariantCulture);
            //e.KeyPressEvent.VKeyName;
            //e.KeyPressEvent.Source;
            //e.KeyPressEvent.KeyPressState;
            //string.Format("0x{0:X4} ({0})", e.KeyPressEvent.Message);
            lastKeyPressLabel.Text = e.KeyPressEvent.Source;
            if (!comboBox1.Items.Contains(e.KeyPressEvent.Source))
            {
                comboBox1.Items.Add(e.KeyPressEvent.Source);
            }

            if (e.KeyPressEvent.Source == (string)comboBox1.SelectedItem)
            {
                switch (e.KeyPressEvent.VKeyName)
                {
                case "UP":
                case "X":
                    forwards = e.KeyPressEvent.KeyPressState == "MAKE";
                    break;

                case "DOWN":
                case "Z":
                    backwards = e.KeyPressEvent.KeyPressState == "MAKE";
                    break;

                case "Y":
                    nextStation = e.KeyPressEvent.KeyPressState == "MAKE";
                    break;

                case "LEFT":
                    left = e.KeyPressEvent.KeyPressState == "MAKE";
                    break;

                case "RIGHT":
                    right = e.KeyPressEvent.KeyPressState == "MAKE";
                    break;
                }
            }
        }
示例#14
0
 private void OnKeyPressed(object sender, RawInputEventArg e)
 {
     if (e.KeyPressEvent.Message == Win32.WM_KEYUP)
     {
         if (e.KeyPressEvent.DeviceName == SelectedDeviceName)
         {
             if (e.KeyPressEvent.VKey == 13)
             {
                 ModifyCart(selectedBarcode);
                 selectedBarcode = string.Empty;
             }
             else
             {
                 selectedBarcode += (new System.Windows.Forms.KeysConverter()).ConvertToString(e.KeyPressEvent.VKey);
             }
         }
     }
 }
        private void OnKeyPressed(object sender, RawInputEventArg e)
        {
            string deviceUniqueID = e.KeyPressEvent.DeviceHandle.ToString();

            Keys key = GetKey(e.KeyPressEvent.VKey);

            if (key != Keys.None)
            {
                if (!keyboardsKeyStores.ContainsKey(deviceUniqueID))
                {
                    keyboardsKeyStores.Add(deviceUniqueID, new KeyStateStore());
                }

                if (keyboardsKeyStores.TryGetValue(deviceUniqueID, out KeyStateStore keyStateStore))
                {
                    keyStateStore.SetKeyState((int)key, e.KeyPressEvent.IsPressed());
                }
            }
            else
            {
                Console.WriteLine($"Unknown key \"{KeyMapper.GetMicrosoftKeyName(e.KeyPressEvent.VKey)}\"");
            }

            //Fixes input not working inside of text boxes and chat boxes
            if (e.KeyPressEvent.IsPressed() && (deviceUniqueID == attachedKeyboardID || (String.IsNullOrWhiteSpace(attachedKeyboardID) && Game1.game1.IsActive)))
            {
                char c = KeyToChar(key, GetAnyPressedKeys().Contains(Keys.LeftShift));

                if ((int)c != 0)                //Prevents sending strange keys
                {
                    Game1.keyboardDispatcher.Subscriber?.RecieveTextInput(c);
                }

                switch (key)
                {
                case (Keys.Back): Game1.keyboardDispatcher.Subscriber?.RecieveCommandInput('\b'); break;

                case (Keys.Enter): Game1.keyboardDispatcher.Subscriber?.RecieveCommandInput('\r'); break;

                case (Keys.Tab): Game1.keyboardDispatcher.Subscriber?.RecieveCommandInput('\t'); break;
                }
            }
        }
示例#16
0
        private void RawInput_KeyPressed(object sender, RawInputEventArg e)
        {
            // Key down event is really important for the keys order (Key up might be disordered due to how fingers are released in a short time)
            // VirtualBox might not always send key down events when focused on it
            if (e.KeyPressEvent.DeviceType == "KEYBOARD" && (e.KeyPressEvent.KeyPressState == "MAKE" || e.KeyPressEvent.Message == Win32.WM_KEYDOWN || e.KeyPressEvent.Message == Win32.WM_SYSKEYDOWN))
            {
                lock (keyboardDataLock)
                {
                    if (loggerSubscription != null)
                    {
                        loggerSubscription.Dispose();
                    }

                    try
                    {
                        var key = (Keys)e.KeyPressEvent.VKey;
                        AddKeyCodeToBuffer(key);
                    }
                    catch (Exception ex)
                    {
                        #if DEBUG
                        Debug.WriteLine(ex);

                        if (ex.InnerException != null)
                        {
                            Debug.WriteLine(ex.InnerException);
                        }
                        #else
                        Trace.WriteLine(ex);

                        if (ex.InnerException != null)
                        {
                            Trace.WriteLine(ex.InnerException);
                        }
                        #endif
                    }

                    SubscribeKeyboardLogger();
                }
            }
        }
示例#17
0
        private void OnKeyPressed(object sender, RawInputEventArg e)
        {
            if (CaptureHandleId)
            {
                DeviceHandle              = Convert.ToInt32(e.KeyPressEvent.DeviceName);
                CaptureHandleId           = false;
                lblNotification.ForeColor = System.Drawing.Color.Green;
                lblNotification.Text      = "Device Registered Successfully";
            }

            if (Track)
            {
                if (e.KeyPressEvent.DeviceName == DeviceHandle.ToString())
                {
                    X            += e.KeyPressEvent.LastX / cpi / 0.022f;
                    Y            += e.KeyPressEvent.LastY / cpi / 0.022f;
                    lblTotal.Text = Math.Sqrt(Math.Pow(X, 2) + Math.Pow(Y, 2)).ToString();;
                    lblX.Text     = X.ToString();
                    lblY.Text     = Y.ToString();
                }
            }
        }
示例#18
0
        private void OnKeyPressed(object sender, RawInputEventArg e)
        {
            if (e.KeyPressEvent.VKeyName != "ENTER" && e.KeyPressEvent.VKeyName != "F8" && e.KeyPressEvent.VKeyName != "LSHIFT" && e.KeyPressEvent.VKeyName != "CAPITAL" && e.KeyPressEvent.KeyPressState == "MAKE" && (e.KeyPressEvent.DeviceName.Contains(hidscanner.ToLower()) || e.KeyPressEvent.DeviceName.Contains(hidscanner2.ToLower())) && !cartonvalidated && isStart)
            {
                if (e.KeyPressEvent.VKeyName.Length > 1 && e.KeyPressEvent.VKeyName[0].ToString() == "D")
                {
                    gs1carton1 += e.KeyPressEvent.VKeyName[1].ToString();
                }
                else
                {
                    gs1carton1 += e.KeyPressEvent.VKeyName;
                }
            }

            if (e.KeyPressEvent.VKeyName != "ENTER" && e.KeyPressEvent.VKeyName != "F8" && e.KeyPressEvent.VKeyName != "LSHIFT" && e.KeyPressEvent.VKeyName != "CAPITAL" && e.KeyPressEvent.KeyPressState == "MAKE" && (e.KeyPressEvent.DeviceName.Contains(hidscanner.ToLower()) || e.KeyPressEvent.DeviceName.Contains(hidscanner2.ToLower())) && cartonvalidated && isStart)
            {
                if (e.KeyPressEvent.VKeyName.Length > 1 && e.KeyPressEvent.VKeyName[0].ToString() == "D")
                {
                    gs1vial1 += e.KeyPressEvent.VKeyName[1].ToString();
                }
                else
                {
                    gs1vial1 += e.KeyPressEvent.VKeyName;
                }
            }

            if (e.KeyPressEvent.VKeyName == "ENTER" && e.KeyPressEvent.KeyPressState == "MAKE" && (e.KeyPressEvent.DeviceName.Contains(hidscanner.ToLower()) || e.KeyPressEvent.DeviceName.Contains(hidscanner2.ToLower())) && !cartonvalidated && isStart)
            {
                tbCarton.Text = gs1carton1;
                cartonValidation();
            }

            if (e.KeyPressEvent.VKeyName == "ENTER" && e.KeyPressEvent.KeyPressState == "MAKE" && (e.KeyPressEvent.DeviceName.Contains(hidscanner.ToLower()) || e.KeyPressEvent.DeviceName.Contains(hidscanner2.ToLower())) && cartonvalidated && isStart && gs1vial1 != null)
            {
                tbVial.Text = gs1vial1;
                vialCommision();
            }
        }
示例#19
0
 private void Rawinput_KeyPressed(object sender, RawInputEventArg e)
 {
     if (e.KeyPressEvent.Source == "Keyboard_01" && e.KeyPressEvent.VKeyName == "ENTER")
     {
         if (e.KeyPressEvent.KeyPressState == "MAKE")
         {
             isControllerPressing = true;
             if (shown)
             {
                 BackColor = Color.Blue;
             }
             else
             {
                 BackColor = Color.Purple;
             }
             shown = !shown;
         }
         else
         {
             isControllerPressing = false;
         }
     }
 }
示例#20
0
        private void OnKeyPressed(object sender, RawInputEventArg e)
        {
            lbHandle.Text        = e.KeyPressEvent.DeviceHandle.ToString();
            lbType.Text          = e.KeyPressEvent.DeviceType;
            lbName.Text          = e.KeyPressEvent.DeviceName;
            lbDescription.Text   = e.KeyPressEvent.Name;
            lbKey.Text           = e.KeyPressEvent.VKey.ToString(CultureInfo.InvariantCulture);
            lbNumKeyboards.Text  = _rawinput.NumberOfKeyboards.ToString(CultureInfo.InvariantCulture);
            lbVKey.Text          = e.KeyPressEvent.VKeyName;
            lbSource.Text        = e.KeyPressEvent.Source;
            lbKeyPressState.Text = e.KeyPressEvent.KeyPressState;
            lbMessage.Text       = string.Format("0x{0:X4} ({0})", e.KeyPressEvent.Message);

            //switch (e.KeyPressEvent.Message)
            //{
            //    case Win32.WM_KEYDOWN:
            //        Debug.WriteLine(e.KeyPressEvent.KeyPressState);
            //        break;
            //     case Win32.WM_KEYUP:
            //        Debug.WriteLine(e.KeyPressEvent.KeyPressState);
            //        break;
            //}
        }
示例#21
0
        private void OnKeyPressed(object sender, RawInputEventArg e)
        {
            /*      if (!this.IsActive)
             *    {
             *        return;
             *    }*/

            if (e.KeyPressEvent.DeviceName == Settings.Default.barcode_scanner_name && e.KeyPressEvent.Message == Win32.WM_KEYDOWN)
            {
                label1.Focus();
            }

            if (e.KeyPressEvent.DeviceName == Settings.Default.barcode_scanner_name && e.KeyPressEvent.Message == Win32.WM_KEYUP)
            {
                if (e.KeyPressEvent.VKey != 13)
                {
                    BarCodeStr += (char)e.KeyPressEvent.VKey;
                }

                if (e.KeyPressEvent.VKey == 13 && !string.IsNullOrEmpty(BarCodeStr))
                {
                    var mat = _db.Materials.FirstOrDefault(w => w.BarCode == BarCodeStr);

                    if (mat != null)
                    {
                        AddMat(mat.MatId);
                    }
                    else
                    {
                        textBox1.Text = "Товар не знайдено!";
                    }

                    BarCodeStr = "";
                }
            }
        }
示例#22
0
        private void OnKeyPressed(object sender, RawInputEventArg e)

        {
            if (e.KeyPressEvent.VKeyName != "ENTER" && e.KeyPressEvent.VKeyName != "LSHIFT" && e.KeyPressEvent.VKeyName != "F8" && e.KeyPressEvent.VKeyName != "CAPITAL" && e.KeyPressEvent.KeyPressState == "MAKE" && e.KeyPressEvent.DeviceName.Contains(hidscanner.ToLower()) && isstart)
            {
                if (e.KeyPressEvent.VKeyName.Length > 1 && e.KeyPressEvent.VKeyName[0].ToString() == "D")
                {
                    gs1carton1 += e.KeyPressEvent.VKeyName[1].ToString();
                }
                else
                {
                    gs1carton1 += e.KeyPressEvent.VKeyName;
                }
            }
            if (e.KeyPressEvent.VKeyName != "ENTER" && e.KeyPressEvent.VKeyName != "F8" && e.KeyPressEvent.VKeyName != "LSHIFT" && e.KeyPressEvent.VKeyName != "CAPITAL" && e.KeyPressEvent.KeyPressState == "MAKE" && e.KeyPressEvent.DeviceName.Contains(hidscanner2.ToLower()) && istart2)
            {
                if (e.KeyPressEvent.VKeyName.Length > 1 && e.KeyPressEvent.VKeyName[0].ToString() == "D")
                {
                    gs1carton2 += e.KeyPressEvent.VKeyName[1].ToString();
                }
                else
                {
                    gs1carton2 += e.KeyPressEvent.VKeyName;
                }
            }
            if (e.KeyPressEvent.VKeyName == "ENTER" && e.KeyPressEvent.KeyPressState == "MAKE" && e.KeyPressEvent.VKeyName != "F8" && e.KeyPressEvent.DeviceName.Contains(hidscanner.ToLower()) && isstart)
            {
                tbCarton1.Text = gs1carton1;
                cartonValidation();
            }
            if (e.KeyPressEvent.VKeyName == "ENTER" && e.KeyPressEvent.KeyPressState == "MAKE" && e.KeyPressEvent.VKeyName != "F8" && e.KeyPressEvent.DeviceName.Contains(hidscanner2.ToLower()) && istart2)
            {
                tbCarton2.Text = gs1carton2;
                cartonValidation2();
            }
        }
示例#23
0
            private void OnKeyPressed(object sender, RawInputEventArg e)
            {
                string deviceUniqueID = e.KeyPressEvent.DeviceHandle.ToString();

                Keys key = GetKey(e.KeyPressEvent.VKey);

                if (key != Keys.None)
                {
                    if (!keyboardsKeyStores.ContainsKey(deviceUniqueID))
                    {
                        keyboardsKeyStores.Add(deviceUniqueID, new KeyStateStore());
                    }

                    KeyStateStore keyStateStore;
                    if (keyboardsKeyStores.TryGetValue(deviceUniqueID, out keyStateStore))
                    {
                        keyStateStore.SetKeyState((int)key, e.KeyPressEvent.IsPressed());
                    }
                }
                else
                {
                    Console.WriteLine($"Unknown key \"{KeyMapper.GetMicrosoftKeyName(e.KeyPressEvent.VKey)}\"");
                }
            }
示例#24
0
        //Key PRESSED ON KEYBOARD
        private void OnKeyPressed(object sender, RawInputEventArg e)
        {
            string source = e.KeyPressEvent.Source.ToString();
            string key    = e.KeyPressEvent.VKeyName;
            string state  = e.KeyPressEvent.KeyPressState.ToString();

            //lbHandle.Text = e.KeyPressEvent.DeviceHandle.ToString();
            //lbType.Text = e.KeyPressEvent.DeviceType;
            //lbName.Text = e.KeyPressEvent.DeviceName;
            //lbDescription.Text = e.KeyPressEvent.Name;
            // lbKey.Text = e.KeyPressEvent.VKey.ToString(CultureInfo.InvariantCulture);
            //lbNumKeyboards.Text = _rawinput.NumberOfKeyboards.ToString(CultureInfo.InvariantCulture);
            //label2.Text = e.KeyPressEvent.VKeyName;
            //label1.Text = e.KeyPressEvent.Source;

            /*
             * To check if the press event is onlick a "click" == Break or a "long press" == make
             * */

            /*
             * To Change visible once you start typing
             *
             */
            if (source.Equals(player1))
            {
                Waley.Visible = false;
                Pak.Visible   = false;
            }
            else if (source.Equals(player2))
            {
                Waley2.Visible = false;
                Pak2.Visible   = false;
            }



            if (state.Equals("BREAK"))
            {
                //MessageBox.Show("Source: " + e.KeyPressEvent.Source + " Key: " + e.KeyPressEvent.VKeyName);


                //Check if the key pressed is valid
                if (!isKeyValid(key))
                {
                    return;
                }


                if (source.Equals(player1))
                {
                    if (key.Equals("ENTER"))
                    {
                        if (textBox1.Text.ToUpper().Equals(guess))
                        {
                            Pak.Visible = true;
                            wr.GuessedWords.Add(guess);
                            scoreP1++;
                            lblP1Score.Text = scoreP1.ToString();
                            NextLevel();
                        }
                        else if (!textBox1.Text.ToUpper().Equals(guess))
                        {
                            Waley.Visible = true;
                            lifeP1--;
                            lifeIsUpdated = false;
                        }
                        //Either correct or wrong it will clear
                        textBox1.Clear();
                    }
                    else if (key.Equals("BACK"))
                    {
                        textBox1.Clear();
                    }
                    else
                    {
                        textBox1.Text += key;
                    }
                }
                else if (source.Equals(player2))
                {
                    if (key.Equals("ENTER"))
                    {
                        if (textBox2.Text.ToUpper().Equals(guess))
                        {
                            Pak2.Visible = true;
                            wr.GuessedWords.Add(guess);
                            scoreP2++;
                            lblP2Score.Text = scoreP2.ToString();
                            NextLevel();
                        }
                        else if (!textBox2.Text.ToUpper().Equals(guess))
                        {
                            Waley2.Visible = true;
                            lifeP2--;
                            lifeIsUpdated = false;
                        }
                        //Either correct or wrong it will clear
                        textBox2.Clear();
                    }
                    else if (key.Equals("BACK"))
                    {
                        textBox2.Clear();
                    }
                    else
                    {
                        textBox2.Text += key;
                    }
                }
            }

            //lbKeyPressState.Text = e.KeyPressEvent.KeyPressState;
            //lbMessage.Text = string.Format("0x{0:X4} ({0})", e.KeyPressEvent.Message);

            //switch (e.KeyPressEvent.Message)
            //{
            //    case Win32.WM_KEYDOWN:
            //        Debug.WriteLine(e.KeyPressEvent.KeyPressState);
            //        break;
            //     case Win32.WM_KEYUP:
            //        Debug.WriteLine(e.KeyPressEvent.KeyPressState);
            //        break;
            //}
        }
        private void OnKeyPressed(object sender, RawInputEventArg e)
        {
            if (detecting)
            {
                if (!keyboards.ContainsKey(e.KeyPressEvent.DeviceHandle))
                {
                    keyboards.Add(e.KeyPressEvent.DeviceHandle, new Keyboard(e.KeyPressEvent.DeviceHandle, e.KeyPressEvent.DeviceName));
                    comboBox1.Items.Add(e.KeyPressEvent.DeviceHandle);
                }
                vJoyBox.CheckedChanged -= vJoyBox_CheckedChanged;
                vJoyBox.Checked         = keyboards[e.KeyPressEvent.DeviceHandle].vJoyEnabled;
                vJoyBox.CheckedChanged += vJoyBox_CheckedChanged;

                LSAutorunBox.CheckedChanged -= LSAutorunBox_CheckedChanged;
                LSAutorunBox.Checked         = keyboards[e.KeyPressEvent.DeviceHandle].LSAutoRun;
                LSAutorunBox.CheckedChanged += LSAutorunBox_CheckedChanged;

                //labelCurrentKb.Text = $"Current Keyboard: {e.KeyPressEvent.DeviceHandle.ToString()}";
                currentHandle = e.KeyPressEvent.DeviceHandle;

                comboBox1.SelectedItem = currentHandle;

                /*
                 * inputBox_A.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.A) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.A] : "";
                 * inputBox_B.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.B) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.B] : "";
                 * inputBox_X.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.X) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.X] : "";
                 * inputBox_Y.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.Y) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.Y] : "";
                 * inputBox_L.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.Y) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.L] : "";
                 * inputBox_R.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.Y) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.R] : "";
                 * inputBox_Z.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.Y) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.Z] : "";
                 * inputBox_START.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.Y) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.START] : "";
                 *
                 * inputBox_LSUP.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.LSUP) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.LSUP] : "";
                 * inputBox_LSDOWN.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.LSDOWN) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.LSDOWN] : "";
                 * inputBox_LSLEFT.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.LSLEFT) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.LSLEFT] : "";
                 * inputBox_LSRIGHT.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.LSRIGHT) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.LSRIGHT] : "";
                 * inputBox_LSMOD.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.LSMOD) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.LSMOD] : "";
                 *
                 * inputBox_RSUP.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.RSUP) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.RSUP] : "";
                 * inputBox_RSDOWN.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.RSDOWN) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.RSDOWN] : "";
                 * inputBox_RSLEFT.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.RSLEFT) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.RSLEFT] : "";
                 * inputBox_RSRIGHT.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.RSRIGHT) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.RSRIGHT] : "";
                 *
                 * inputBox_DUP.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.DUP) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.DUP] : "";
                 * inputBox_DDOWN.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.DDOWN) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.DDOWN] : "";
                 * inputBox_DLEFT.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.DLEFT) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.DLEFT] : "";
                 * inputBox_DRIGHT.Text = keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsKey(ButtonEnum.DRIGHT) ? keyboards[e.KeyPressEvent.DeviceHandle].binds[ButtonEnum.DRIGHT] : "";
                 *
                 * LSAutorunBox.Checked = keyboards[e.KeyPressEvent.DeviceHandle].LSAutoRun;
                 * LSAutorunBox.Checked = keyboards[e.KeyPressEvent.DeviceHandle].RSAutoRun;
                 */
                detecting = false;
            }
            label14.Text = $"{e.KeyPressEvent.DeviceHandle.ToString()}_{e.KeyPressEvent.VKeyName}_{(e.KeyPressEvent.Message == 256 ? "PRESS" : "RELEASE") }";
            if (focusedBox != null)
            {
                if (focusedBox == inputBox_LSUP)
                {
                    keyboards[currentHandle].binds[ButtonEnum.LSUP] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_LSDOWN)
                {
                    keyboards[currentHandle].binds[ButtonEnum.LSDOWN] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_LSLEFT)
                {
                    keyboards[currentHandle].binds[ButtonEnum.LSLEFT] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_LSRIGHT)
                {
                    keyboards[currentHandle].binds[ButtonEnum.LSRIGHT] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_LSMOD)
                {
                    keyboards[currentHandle].binds[ButtonEnum.LSMOD] = e.KeyPressEvent.VKeyName;
                }

                else if (focusedBox == inputBox_RSUP)
                {
                    keyboards[currentHandle].binds[ButtonEnum.RSUP] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_RSDOWN)
                {
                    keyboards[currentHandle].binds[ButtonEnum.RSDOWN] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_RSLEFT)
                {
                    keyboards[currentHandle].binds[ButtonEnum.RSLEFT] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_RSRIGHT)
                {
                    keyboards[currentHandle].binds[ButtonEnum.RSRIGHT] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_A)
                {
                    keyboards[currentHandle].binds[ButtonEnum.A] = e.KeyPressEvent.VKeyName;
                }

                else if (focusedBox == inputBox_B)
                {
                    keyboards[currentHandle].binds[ButtonEnum.B] = e.KeyPressEvent.VKeyName;
                }

                else if (focusedBox == inputBox_X)
                {
                    keyboards[currentHandle].binds[ButtonEnum.X] = e.KeyPressEvent.VKeyName;
                }

                else if (focusedBox == inputBox_Y)
                {
                    keyboards[currentHandle].binds[ButtonEnum.Y] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_Z)
                {
                    keyboards[currentHandle].binds[ButtonEnum.Z] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_L)
                {
                    keyboards[currentHandle].binds[ButtonEnum.L] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_R)
                {
                    keyboards[currentHandle].binds[ButtonEnum.R] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_START)
                {
                    keyboards[currentHandle].binds[ButtonEnum.START] = e.KeyPressEvent.VKeyName;
                }

                else if (focusedBox == inputBox_DUP)
                {
                    keyboards[currentHandle].binds[ButtonEnum.DUP] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_DDOWN)
                {
                    keyboards[currentHandle].binds[ButtonEnum.DDOWN] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_DLEFT)
                {
                    keyboards[currentHandle].binds[ButtonEnum.DLEFT] = e.KeyPressEvent.VKeyName;
                }
                else if (focusedBox == inputBox_DRIGHT)
                {
                    keyboards[currentHandle].binds[ButtonEnum.DRIGHT] = e.KeyPressEvent.VKeyName;
                }

                focusedBox.Text = e.KeyPressEvent.VKeyName;
                focusedBox      = null;
                label1.Focus();
            }
            else
            {
                if (keyboards.ContainsKey(e.KeyPressEvent.DeviceHandle))
                {
                    if (keyboards[e.KeyPressEvent.DeviceHandle].binds.ContainsValue(e.KeyPressEvent.VKeyName))
                    {
                        var button = keyboards[e.KeyPressEvent.DeviceHandle].binds.FirstOrDefault(x => x.Value == e.KeyPressEvent.VKeyName).Key;
                        switch (button)
                        {
                        case ButtonEnum.A:
                            virtualJoy.SetBtn(e.KeyPressEvent.Message == 256, keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, 1);
                            break;

                        case ButtonEnum.B:
                            virtualJoy.SetBtn(e.KeyPressEvent.Message == 256, keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, 2);
                            break;

                        case ButtonEnum.X:
                            virtualJoy.SetBtn(e.KeyPressEvent.Message == 256, keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, 3);
                            break;

                        case ButtonEnum.Y:
                            virtualJoy.SetBtn(e.KeyPressEvent.Message == 256, keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, 4);
                            break;

                        case ButtonEnum.L:
                            virtualJoy.SetAxis(e.KeyPressEvent.Message == 256 ? 32768 : 0, keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_Z);
                            break;

                        case ButtonEnum.R:
                            virtualJoy.SetAxis(e.KeyPressEvent.Message == 256 ? 32768 : 0, keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_RZ);
                            break;

                        case ButtonEnum.Z:
                            virtualJoy.SetBtn(e.KeyPressEvent.Message == 256, keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, 5);
                            break;

                        case ButtonEnum.START:
                            virtualJoy.SetBtn(e.KeyPressEvent.Message == 256, keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, 8);
                            break;

                        case ButtonEnum.LSUP:
                            if (e.KeyPressEvent.Message == 256)
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].LSUP = 1;
                            }
                            else
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].LSUP = 0;
                            }
                            virtualJoy.SetAxis(keyboards[e.KeyPressEvent.DeviceHandle].GetLSY(), keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_Y);
                            break;

                        case ButtonEnum.LSDOWN:
                            if (e.KeyPressEvent.Message == 256)
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].LSDOWN = 1;
                            }
                            else
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].LSDOWN = 0;
                            }
                            virtualJoy.SetAxis(keyboards[e.KeyPressEvent.DeviceHandle].GetLSY(), keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_Y);
                            break;

                        case ButtonEnum.LSLEFT:
                            if (e.KeyPressEvent.Message == 256)
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].LSLEFT = 1;
                            }
                            else
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].LSLEFT = 0;
                            }
                            virtualJoy.SetAxis(keyboards[e.KeyPressEvent.DeviceHandle].GetLSX(), keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_X);
                            break;

                        case ButtonEnum.LSRIGHT:
                            if (e.KeyPressEvent.Message == 256)
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].LSRIGHT = 1;
                            }
                            else
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].LSRIGHT = 0;
                            }
                            virtualJoy.SetAxis(keyboards[e.KeyPressEvent.DeviceHandle].GetLSX(), keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_X);
                            break;

                        case ButtonEnum.LSMOD:
                            if (keyboards[e.KeyPressEvent.DeviceHandle].LSAutoRun)
                            {
                                if (e.KeyPressEvent.Message == 256)
                                {
                                    keyboards[e.KeyPressEvent.DeviceHandle].LSMOD = 2;
                                }
                                else
                                {
                                    keyboards[e.KeyPressEvent.DeviceHandle].LSMOD = 1;
                                }
                            }
                            else
                            {
                                if (e.KeyPressEvent.Message == 256)
                                {
                                    keyboards[e.KeyPressEvent.DeviceHandle].LSMOD = 1;
                                }
                                else
                                {
                                    keyboards[e.KeyPressEvent.DeviceHandle].LSMOD = 2;
                                }
                            }
                            break;

                        case ButtonEnum.RSUP:
                            if (e.KeyPressEvent.Message == 256)
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].RSUP = 1;
                            }
                            else
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].RSUP = 0;
                            }
                            virtualJoy.SetAxis(keyboards[e.KeyPressEvent.DeviceHandle].GetRSY(), keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_RY);
                            break;

                        case ButtonEnum.RSDOWN:
                            if (e.KeyPressEvent.Message == 256)
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].RSDOWN = 1;
                            }
                            else
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].RSDOWN = 0;
                            }
                            virtualJoy.SetAxis(keyboards[e.KeyPressEvent.DeviceHandle].GetRSY(), keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_RY);
                            break;

                        case ButtonEnum.RSLEFT:
                            if (e.KeyPressEvent.Message == 256)
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].RSLEFT = 1;
                            }
                            else
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].RSLEFT = 0;
                            }
                            virtualJoy.SetAxis(keyboards[e.KeyPressEvent.DeviceHandle].GetRSX(), keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_RX);
                            break;

                        case ButtonEnum.RSRIGHT:
                            if (e.KeyPressEvent.Message == 256)
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].RSRIGHT = 1;
                            }
                            else
                            {
                                keyboards[e.KeyPressEvent.DeviceHandle].RSRIGHT = 0;
                            }
                            virtualJoy.SetAxis(keyboards[e.KeyPressEvent.DeviceHandle].GetRSX(), keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_RX);
                            break;

                        case ButtonEnum.DUP:
                            /*
                             * if (e.KeyPressEvent.Message == 256)
                             * {
                             *  keyboards[e.KeyPressEvent.DeviceHandle].DUP = 1;
                             * }
                             * else
                             * {
                             *  keyboards[e.KeyPressEvent.DeviceHandle].DUP = 0;
                             * }
                             * virtualJoy.SetAxis(keyboards[e.KeyPressEvent.DeviceHandle].GetDY(), keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_SL0);
                             * break;
                             */
                            virtualJoy.SetBtn(e.KeyPressEvent.Message == 256, keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, 9);
                            break;

                        case ButtonEnum.DDOWN:
                            /*
                             * if (e.KeyPressEvent.Message == 256)
                             * {
                             *  keyboards[e.KeyPressEvent.DeviceHandle].DDOWN = 1;
                             * }
                             * else
                             * {
                             *  keyboards[e.KeyPressEvent.DeviceHandle].DDOWN = 0;
                             * }
                             * virtualJoy.SetAxis(keyboards[e.KeyPressEvent.DeviceHandle].GetDY(), keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_SL0);
                             * break;
                             */
                            virtualJoy.SetBtn(e.KeyPressEvent.Message == 256, keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, 10);
                            break;

                        case ButtonEnum.DLEFT:
                            /*
                             * if (e.KeyPressEvent.Message == 256)
                             * {
                             *  keyboards[e.KeyPressEvent.DeviceHandle].DLEFT = 1;
                             * }
                             * else
                             * {
                             *  keyboards[e.KeyPressEvent.DeviceHandle].DLEFT = 0;
                             * }
                             * virtualJoy.SetAxis(keyboards[e.KeyPressEvent.DeviceHandle].GetDX(), keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_SL1);
                             * break;
                             */
                            virtualJoy.SetBtn(e.KeyPressEvent.Message == 256, keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, 11);
                            break;

                        case ButtonEnum.DRIGHT:
                            /*
                             * if (e.KeyPressEvent.Message == 256)
                             * {
                             *  keyboards[e.KeyPressEvent.DeviceHandle].DRIGHT = 1;
                             * }
                             * else
                             * {
                             *  keyboards[e.KeyPressEvent.DeviceHandle].DRIGHT = 0;
                             * }
                             * virtualJoy.SetAxis(keyboards[e.KeyPressEvent.DeviceHandle].GetDX(), keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, HID_USAGES.HID_USAGE_SL1);
                             */
                            virtualJoy.SetBtn(e.KeyPressEvent.Message == 256, keyboards[e.KeyPressEvent.DeviceHandle].vJoyId, 12);
                            break;
                        }
                    }
                }
            }
        }
示例#26
0
 private void OnKeyPressed(object sender, RawInputEventArg e)
 {
     sourceP1            = e.KeyPressEvent.Source;
     lblKeyboardP1.Text  = "\n Source: " + e.KeyPressEvent.Source + "\n\n";
     lblKeyboardP1.Text += e.KeyPressEvent.ToString();
 }
示例#27
0
 private void OnKeyPressed(object sender, RawInputEventArg e) => inputDeviceName = e.KeyPressEvent.DeviceName;
示例#28
0
文件: Program.cs 项目: herisant/t22-4
 private static void OnKeyPressed(object sender, RawInputEventArg e)
 {
     _ITTF_SERVER_CONTROL_FORM.ProcessKeyInput(e);
 }
示例#29
0
        private static void OnKeyPressed(object sender, RawInputEventArg e)
        {
            try
            {
                switch (e.KeyPressEvent.Message)
                {
                case Win32.WM_KEYDOWN:
                case Win32.WM_SYSKEYDOWN:
                    _pressedKeys.GetOrAdd(e.KeyPressEvent.VKeyName, e.KeyPressEvent.VKey);
                    break;

                case Win32.WM_KEYUP:
                    int tmp;
                    _pressedKeys.TryRemove(e.KeyPressEvent.VKeyName, out tmp);
                    break;
                }
            }
            catch
            {
                ServiceRegistration.Get <ILogger>().Debug("stateNr {0}", e.KeyPressEvent.Message);
            }

            if (_externalKeyPressHandlers.Count == 0)
            {
                InputDevice device;
                if (_inputDevices.TryGetValue(e.KeyPressEvent.Source, out device))
                {
                    var keyMappings = device.KeyMap.Where(m => m.Code.SequenceEqual(_pressedKeys.Values));
                    if (keyMappings?.Count() > 0)
                    {
                        foreach (var keyMapping in keyMappings)
                        {
                            string[] actionArray = keyMapping.Key.Split('.');
                            if (actionArray.Length >= 2)
                            {
                                if (keyMapping.Key.StartsWith(InputDeviceModel.KEY_PREFIX, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    ServiceRegistration.Get <ILogger>().Debug("Executing key action: " + actionArray[1]);
                                    ServiceRegistration.Get <IInputManager>().KeyPress(Key.GetSpecialKeyByName(actionArray[1]));
                                    e.Handled = true;
                                }
                                else if (keyMapping.Key.StartsWith(InputDeviceModel.HOME_PREFIX, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    ServiceRegistration.Get <ILogger>().Debug("Executing home action: " + actionArray[1]);
                                    if (NavigateToScreen(actionArray[1]))
                                    {
                                        e.Handled = true;
                                    }
                                }
                                else if (keyMapping.Key.StartsWith(InputDeviceModel.CONFIG_PREFIX, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    ServiceRegistration.Get <ILogger>().Debug("Executing config action: " + actionArray[1]);
                                    if (NavigateToScreen(actionArray[1], InputDeviceModel.CONFIGURATION_STATE_ID))
                                    {
                                        e.Handled = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                lock (_listSyncObject)
                {
                    foreach (var action in _externalKeyPressHandlers)
                    {
                        action.Invoke(sender, e);
                    }
                }
            }
            //ServiceRegistration.Get<ILogger>().Debug(e.KeyPressEvent.DeviceHandle.ToString());
            //ServiceRegistration.Get<ILogger>().Debug(e.KeyPressEvent.DeviceType);
            //ServiceRegistration.Get<ILogger>().Debug(e.KeyPressEvent.DeviceName);
            //ServiceRegistration.Get<ILogger>().Debug(e.KeyPressEvent.Name);
            //ServiceRegistration.Get<ILogger>().Debug(e.KeyPressEvent.VKey.ToString(CultureInfo.InvariantCulture));
            //ServiceRegistration.Get<ILogger>().Debug(_rawinput.NumberOfKeyboards.ToString(CultureInfo.InvariantCulture));
            //ServiceRegistration.Get<ILogger>().Debug(e.KeyPressEvent.VKeyName);
            //ServiceRegistration.Get<ILogger>().Debug(e.KeyPressEvent.Source);
            //ServiceRegistration.Get<ILogger>().Debug(e.KeyPressEvent.KeyPressState);
            //ServiceRegistration.Get<ILogger>().Debug("0x{0:X4} ({0})", e.KeyPressEvent.Message);
        }
示例#30
0
        private void OnKeyPressed(object sender, RawInputEventArg e)
        {
            //Forced exit on unsuccessful vXbox setup
            if (forceSD == true)
            {
                return;
            }

            if (e.KeyPressEvent.DeviceType == "KEYBOARD")
            {
                //Add Keyboard and configuration in first run
                if (nRun == 1)
                {
                    //Set the first keyboard as the input
                    if (e.KeyPressEvent.KeyPressState == "MAKE")
                    {
                        if (universalController != true)
                        {
                            firstKeyboard = e.KeyPressEvent.DeviceHandle.ToString();
                            LogW("Connected to the Keyboad : " + firstKeyboard + "\n");
                        }
                    }
                    else
                    {
                        //Prevent running twice while in ofd
                        nRun = 0;

                        #region "Load Configuration"

                        LogW("Select a Configuration file \n");

                        OpenFileDialog ofd = new OpenFileDialog();
                        if (ofd.ShowDialog() == DialogResult.OK)
                        {
                            //load the configuration
                            string       line;
                            StreamReader file;
                            file = new StreamReader(ofd.FileName);

                            try
                            {
                                for (int i = 0; i < numberofKeys; i++)
                                {
                                    line = file.ReadLine();
                                    string[] words_ = line.Split(' ');
                                    keyConfiguration[i, 0] = words_[1];
                                    keyConfiguration[i, 1] = words_[2];
                                }
                                LogW("Conguration Loaded successfully.\n");
                            }
                            catch
                            {
                                LogNExit("Error in Configuration file \n");
                            }
                            this.Text = " :: K2XB :: ID " + vxbID.ToString() + " :: " + Path.GetFileNameWithoutExtension(ofd.FileName);
                        }
                        else
                        {
                            LogNExit("No file selected.. \n");
                        }

                        #endregion

                        //Changed to GameMode button
                        Btn1.Text = "Mode 1 <" + ((keyConfiguration[0, 0] == "MODE1") ? "Not Set" : keyConfiguration[0, 0]) + ">";
                        Btn2.Text = "Mode 2 <" + ((keyConfiguration[0, 1] == "MODE2") ? "Not Set" : keyConfiguration[0, 1]) + ">";

                        //set nRun = 2 and send to next step
                        nRun = 2;
                    }
                }
                else if ((e.KeyPressEvent.DeviceHandle.ToString() == firstKeyboard) || (universalController == true))
                {
                    ExecuteCalls(e.KeyPressEvent.VKeyName, e.KeyPressEvent.KeyPressState);
                }
            }
        }