public static void OnkeyUpEvent(KeyUpEventArgs e)
 {
     if (keyUpEvent != null)
     {
         keyUpEvent(e);
     }
 }
Exemplo n.º 2
0
 private void HeardUp(KeyUpEventArgs e)
 {
     RunFeederUp(e);
 }
        private static IntPtr HookCallback(
            int nCode, IntPtr wParam, IntPtr lParam)
        {
            int vkCode = Marshal.ReadInt32(lParam);
                string keyTest = ((Keys)vkCode).ToString();
                if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
                {
                    foreach (string bind in KeyBindings.binds)
                    {
                        if (bind == keyTest)
                        {
                            if (send)
                            {
                                KeyDEventArgs keyD = new KeyDEventArgs();
                                keyD.KeyD = keyTest;
                                KeyD.OnkeyDownEvent(keyD);
                            }
                            if (block)
                            {
                                return (System.IntPtr)1;
                            }
                            else
                            {
                                return CallNextHookEx(_hookID, nCode, wParam, lParam);
                            }
                        }
                    }
                }

                if (nCode >= 0 && wParam == (IntPtr)WM_KEYUP)
                {
                    foreach (string bind in KeyBindings.binds)
                    {
                        if (bind == keyTest)
                        {
                            if (send)
                            {
                                KeyUpEventArgs keyUp = new KeyUpEventArgs();
                                keyUp.KeyUp = keyTest;
                                KeyUp.OnkeyUpEvent(keyUp);
                            }
                            if (block)
                            {
                                return (System.IntPtr)1;
                            }
                            else
                            {
                                return CallNextHookEx(_hookID, nCode, wParam, lParam);
                            }
                        }
                    }
                }

            return CallNextHookEx(_hookID, nCode, wParam, lParam);
        }
Exemplo n.º 4
0
        public void RunFeederUp(KeyUpEventArgs e)
        {
            long maxval = 0;
            int X, Y;
            joystick.GetVJDAxisMax(1, HID_USAGES.HID_USAGE_X, ref maxval);

            if (e.KeyUp == KeyBindings.binds[0])
            {
                upKeyBool = false;
                if (downKeyBool)
                {
                    Y = (int)(maxval);
                    joystick.SetAxis(Y, 1, HID_USAGES.HID_USAGE_Y);
                }
                else
                {
                    Y = (int)((maxval / 2) + 1.2);
                    joystick.SetAxis(Y, 1, HID_USAGES.HID_USAGE_Y);
                }
            }
            else if (e.KeyUp == KeyBindings.binds[1])
            {
                leftKeyBool = false;
                if (rightKeyBool)
                {
                    X = (int)(maxval);
                    joystick.SetAxis(X, 1, HID_USAGES.HID_USAGE_X);
                }
                else
                {
                    X = (int)((maxval / 2) + 1.2);
                    joystick.SetAxis(X, 1, HID_USAGES.HID_USAGE_X);
                }

            }
            else if (e.KeyUp == KeyBindings.binds[2])
            {
                downKeyBool = false;
                if (upKeyBool)
                {
                    Y = 0;
                    joystick.SetAxis(Y, 1, HID_USAGES.HID_USAGE_Y);
                }
                else
                {
                    Y = (int)((maxval / 2) + 1.2);
                    joystick.SetAxis(Y, 1, HID_USAGES.HID_USAGE_Y);
                }
            }
            else if (e.KeyUp == KeyBindings.binds[3])
            {
                rightKeyBool = false;
                if (leftKeyBool)
                {
                    X = 0;
                    joystick.SetAxis(X, 1, HID_USAGES.HID_USAGE_X);
                }
                else
                {
                    X = (int)((maxval / 2) + 1.2);
                    joystick.SetAxis(X, 1, HID_USAGES.HID_USAGE_X);
                }
            }
            else
            {
                for (int i = 4; i < KeyBindings.binds.Length; i++)
                {
                    uint butid = (uint)(i - 3);
                    if (e.KeyUp == KeyBindings.binds[i])
                    {
                        joystick.SetBtn(false, 1, butid);
                    }
                }
            }
        }