예제 #1
0
파일: Form1.cs 프로젝트: 0xdhac/MK2360
        private void Intercept()
        {
            IntPtr context = Interception.interception_create_context();

            Interception.Stroke stroke = new Interception.Stroke();
            int device;

            // Check for keyboard changes
            Interception.InterceptionPredicate interception_is_keyboard = Interception.interception_is_keyboard;
            Interception.interception_set_filter(
                context,
                interception_is_keyboard,
                ((ushort)Interception.FilterKeyState.KeyDown |
                 (ushort)Interception.FilterKeyState.KeyUp));

            // Check for mouse changes
            Interception.InterceptionPredicate interception_is_mouse = Interception.interception_is_mouse;
            Interception.interception_set_filter(
                context,
                interception_is_mouse,
                (ushort)Interception.FilterMouseState.All);

            while (Interception.interception_receive(context, device = Interception.interception_wait(context), ref stroke, 1) > 0)
            {
                byte[] strokeBytes = Interception.getBytes(stroke);
                if (Interception.interception_is_keyboard(device) != 0)
                {
                    Interception.KeyStroke kstroke = stroke;

                    if (kstroke.code == (ushort)Input.DIK.LWin || kstroke.code == (ushort)Input.DIK.RWin)
                    {
                        Interception.interception_send(context, device, strokeBytes, 1);
                        continue;
                    }

                    Input i = new Input(kstroke);

                    if (i.m_InputType == Input.InputType.Keyboard && Config.m_Config.m_KillSwitch == (Input.DIK)i.Code[0] && i.m_InputState[0] == Input.InputState.Down)
                    {
                        if (XMode.IsActive())
                        {
                            XMode.Stop(false);
                        }
                        else
                        {
                            XMode.Start();
                        }

                        continue;
                    }

                    Input.InputAction act = i.CallKeyListeners();

                    if ((act & Input.InputAction.Block) == 0)
                    {
                        Interception.interception_send(context, device, strokeBytes, 1);
                    }
                }
                else if (Interception.interception_is_mouse(device) != 0)
                {
                    Interception.MouseStroke kstroke = stroke;
                    Input i = new Input(kstroke);

                    Input.InputAction act = i.CallKeyListeners();

                    if ((act & Input.InputAction.Block) == 0)
                    {
                        Interception.interception_send(context, device, strokeBytes, 1);
                    }
                }
            }

            Interception.interception_destroy_context(context);
        }