public static void OnkeyDownEvent(KeyDEventArgs e)
 {
     if (keyDownEvent != null)
     {
     keyDownEvent(e);
     }
 }
Example #2
0
        public void RunFeederDown(KeyDEventArgs e)
        {
            long maxval = 0;
            int X, Y;
            joystick.GetVJDAxisMax(1, HID_USAGES.HID_USAGE_X, ref maxval);

            if (e.KeyD == KeyBindings.binds[0])
            {
                upKeyBool = true;
                if (downKeyBool)
                {
                    if (Form1.UpPrio)
                    {
                        Y = (int)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
                {
                    Y = (int)0;
                    joystick.SetAxis(Y, 1, HID_USAGES.HID_USAGE_Y);
                }
            }
            else if (e.KeyD == KeyBindings.binds[1])
            {
                leftKeyBool = true;
                if (rightKeyBool)
                {
                    X = (int)((maxval / 2) + 1.2);
                    joystick.SetAxis(X, 1, HID_USAGES.HID_USAGE_X);
                }
                else
                {
                    X = 0;
                    joystick.SetAxis(X, 1, HID_USAGES.HID_USAGE_X);
                }

            }
            else if (e.KeyD == KeyBindings.binds[2])
            {
                downKeyBool = true;
                if (upKeyBool)
                {
                    if (Form1.UpPrio)
                    {
                        Y = (int)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
                {
                    Y = (int)(maxval);
                    joystick.SetAxis(Y, 1, HID_USAGES.HID_USAGE_Y);
                }
            }
            else if (e.KeyD == KeyBindings.binds[3])
            {
                rightKeyBool = true;
                if (leftKeyBool)
                {
                    X = (int)((maxval / 2) + 1.2);
                    joystick.SetAxis(X, 1, HID_USAGES.HID_USAGE_X);
                }
                else
                {
                    X = (int)(maxval);
                    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.KeyD == KeyBindings.binds[i])
                    {
                        joystick.SetBtn(true, 1, butid);
                    }
                }
            }
        }
        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);
        }
Example #4
0
 private void HeardDown(KeyDEventArgs e)
 {
     RunFeederDown(e);
 }