コード例 #1
0
ファイル: KeyboardPlugin.cs プロジェクト: tagaf/FreePIE
        public override Action Start()
        {

            IntPtr handle = Process.GetCurrentProcess().MainWindowHandle;

            KeyboardDevice = new Keyboard(DirectInputInstance);
            if (KeyboardDevice == null)
                throw new Exception("Failed to create keyboard device");

            KeyboardDevice.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
            KeyboardDevice.Acquire();

            KeyboardDevice.GetCurrentState(ref KeyState);

            setKeyPressedStrategy = new SetPressedStrategy(KeyDown, KeyUp);
            getKeyPressedStrategy = new GetPressedStrategy<int>(IsKeyDown);

            OnStarted(this, new EventArgs());
            return null;
        }
コード例 #2
0
ファイル: Input.cs プロジェクト: crissian/planets
        /// <summary>
        /// Initialize the input.
        /// </summary>
        public static void ModuleInit()
        {
            directInput = new DirectInput();
            keyboard = new Keyboard(directInput);
            keyboard.SetCooperativeLevel(Scene.Instance.GraphicsEngine.Form, CooperativeLevel.Nonexclusive | CooperativeLevel.Background);
            keyboard.Acquire();
            mouse = new Mouse(directInput);
            mouse.SetCooperativeLevel(Scene.Instance.GraphicsEngine.Form, CooperativeLevel.Nonexclusive | CooperativeLevel.Background);
            mouse.Acquire();

            s_lastFrameState = keyboard.GetCurrentState();
            s_thisState = s_lastFrameState;
            s_lastFrameMouseState = mouse.GetCurrentState();
            s_thisMouseState = s_lastFrameMouseState;
        }