Example #1
0
        /// <include file='ManagedHooks.xml' path='Docs/KeyboardHook/HookCallback/*'/>
        protected override void HookCallback(int code, UIntPtr wparam, IntPtr lparam)
        {
            if (KeyboardEvent == null)
            {
                return;
            }

            int            vkCode = 0;
            KeyboardEvents kEvent = (KeyboardEvents)wparam.ToUInt32();

            if (kEvent != KeyboardEvents.KeyDown &&
                kEvent != KeyboardEvents.KeyUp &&
                kEvent != KeyboardEvents.SystemKeyDown &&
                kEvent != KeyboardEvents.SystemKeyUp)
            {
                return;
            }

            GetKeyboardReading(wparam, lparam, ref vkCode);
            //VirtualKeys vk = (VirtualKeys)vkCode;

            //System.Windows.Forms.Keys key  = ConvertKeyCode(vk);
            Keys key = (Keys)vkCode;

            if (key == System.Windows.Forms.Keys.Attn)
            {
                return;
            }

            KeyboardEvent(kEvent, key);
        }
Example #2
0
        public static IntPtr KeyboardHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode < 0)
            {
                return(NativeMethods.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
            }

            KeyboardEvents  kEvent = (KeyboardEvents)wParam.ToInt32();
            KBDLLHOOKSTRUCT kbd    = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT));

            int         scanCode = (int)kbd.scanCode;
            VirtualKeys vk       = (VirtualKeys)kbd.vkCode;

            if (vk == VirtualKeys.VK_PAUSE && kEvent == KeyboardEvents.KeyDown)
            {
                s_bPausing = !s_bPausing;
            }

            // Record encoded key virtual key
            if (s_bPausing == false)
            {
                MouseKeyboardEventHandler.RecordKey(kEvent, vk, scanCode);
            }

            return(NativeMethods.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
        }
Example #3
0
        public GamePlayScene(GraphicsDevice device,
                             IXleScreen screen,
                             IXleRunner gameRunner,
                             IXleInput xleInput,
                             IRectangleRenderer rects,
                             ICommandExecutor commandExecutor,
                             XleSystemState systemState,
                             XleRenderer renderer,
                             GameState gameState)
            : base(device, 680, 440)
        {
            this.device          = device;
            this.screen          = screen;
            this.gameRunner      = gameRunner;
            this.xleInput        = xleInput;
            this.rects           = rects;
            this.commandExecutor = commandExecutor;
            this.systemState     = systemState;
            this.renderer        = renderer;
            this.gameState       = gameState;

            this.spriteBatch = new SpriteBatch(device);

            keyboard = new KeyboardEvents();

            keyboard.KeyPress += (_, e) => xleInput.OnKeyPress(e);
            keyboard.KeyDown  += (_, e) => xleInput.OnKeyDown(e.Key);
            keyboard.KeyUp    += (_, e) => xleInput.OnKeyUp(e.Key);
        }
        public void Input(KeyboardEvents kEvents, Keys currentKey)
        {
            if (visualStudioOnly && !NativeHelpers.ActiveApplTitle().Contains("Microsoft Visual Studio"))
            {
                return;
            }

            if (((kEvents == KeyboardEvents.SystemKeyDown) || (kEvents == KeyboardEvents.KeyDown)) &&
                currentKey.IsComboKey())
            {
                keyStates[currentKey] = true;
                isSystemKeyDown       = true;
            }
            if (((kEvents == KeyboardEvents.SystemKeyUp) || (kEvents == KeyboardEvents.KeyUp)) &&
                currentKey.IsComboKey())
            {
                keyStates[currentKey] = false;
                isSystemKeyDown       = AreAllSystemKeysDown(keyStates);
            }
            if (((kEvents == KeyboardEvents.SystemKeyDown) || (kEvents == KeyboardEvents.KeyDown)) &&
                (!currentKey.IsComboKey() && isSystemKeyDown))
            {
                ShortcutActivated(BuildKeyMessage(keyStates, currentKey));
            }
            else if ((kEvents == KeyboardEvents.KeyDown) && (currentKey.IsSpecialSingleKey() ||
                                                             currentKey.IsOtherKey()))
            {
                ShortcutActivated(BuildKeyMessage(keyStates, currentKey));
            }
        }
Example #5
0
        private void OnKeyboardEvent(KeyboardEvents kEvent, Keys key)
        {
            if (this.recording)
            {
                this.keys = key;
            }

            if (this.keys == key || this.recording)
            {
                if (this.inputState != InputState.On && kEvent == KeyboardEvents.KeyDown)
                {
                    this.inputState = InputState.On;
                }
                else if (kEvent == KeyboardEvents.KeyUp)
                {
                    this.inputState = InputState.Off;
                }
                else
                {
                    return;
                }

                var ev = this.InputStateChanged;
                if (ev != null)
                {
                    ev(this, new InputStateChangedEventArgs(this.inputState));
                }
            }
        }
Example #6
0
        public static IntPtr KeyboardHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode < 0 || MouseKeyboardEventHandler.s_threadRecorder == null || MainWindow.s_mainWin.IsRecording == false)
            {
                return(NativeMethods.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
            }

            KeyboardEvents  kEvent = (KeyboardEvents)wParam.ToInt32();
            KBDLLHOOKSTRUCT kbd    = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT));

            int         scanCode = (int)kbd.scanCode;
            VirtualKeys vk       = (VirtualKeys)kbd.vkCode;

            if (vk == VirtualKeys.VK_PAUSE && kEvent == KeyboardEvents.KeyDown)
            {
                s_bPauseMouseKeyboard = !s_bPauseMouseKeyboard;

                if (s_bPauseMouseKeyboard == true)
                {
                    NativeMethods.PostMessage(MainWindow.s_windowHandle, (int)MainWindow.UiThreadTask.PauseRecording, 0, 0);
                }
                else
                {
                    NativeMethods.PostMessage(MainWindow.s_windowHandle, (int)MainWindow.UiThreadTask.Active, 0, 0);
                }
            }

            if (s_bPauseMouseKeyboard == false)
            {
                MouseKeyboardEventHandler.RecordKey(kEvent, vk, scanCode);
            }

            return(NativeMethods.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
        }
Example #7
0
        protected override void HookCallback(int code, UIntPtr wparam, IntPtr lparam)
        {
            if (KeyboardEvent == null)
            {
                return;
            }

            int            vkCode = 0;
            KeyboardEvents kEvent = (KeyboardEvents)wparam.ToUInt32();

            if (kEvent != KeyboardEvents.KeyDown &&
                kEvent != KeyboardEvents.KeyUp &&
                kEvent != KeyboardEvents.SystemKeyDown &&
                kEvent != KeyboardEvents.SystemKeyUp)
            {
                return;
            }

            GetKeyboardReading(wparam, lparam, ref vkCode);
            VirtualKeys vk = (VirtualKeys)vkCode;

            Keys key;

            if (keyMap.TryGetValue(vk, out key))
            {
                KeyboardEvent(kEvent, key);
            }
        }
        public void Input(KeyboardEvents kEvents, Keys currentKey)
        {
            if (visualStudioOnly && !NativeHelpers.ActiveApplTitle().Contains("Microsoft Visual Studio"))
            {
                return;
            }

            if (kEvents == KeyboardEvents.KeyDown && currentKey.IsComboKey())
            {
                keyStates[currentKey] = true;
                isSystemKeyDown = true;

            }
            else if (kEvents == KeyboardEvents.KeyUp && currentKey.IsComboKey())
            {
                keyStates[currentKey] = false;
                isSystemKeyDown = AreAllSystemKeysDown(keyStates);
            }

            if (kEvents == KeyboardEvents.KeyDown && (!currentKey.IsComboKey() && isSystemKeyDown) && !IsShiftOnly(keyStates))
            {
                ShortcutActivated(BuildKeyMessage(keyStates, currentKey));
            }
            else if ((kEvents == KeyboardEvents.KeyDown) && currentKey.IsSpecialSingleKey())
            {
                ShortcutActivated(BuildKeyMessage(keyStates, currentKey));
            }
            Debug.WriteLine("K={0} {1}", currentKey, kEvents);
        }
Example #9
0
        public TitleScene(GraphicsDevice graphicsDevice,
                          IContentProvider content,
                          IMouseEvents mouse,
                          IGameStateFactory gameStateFactory,
                          CImage img,
                          CSound snd,
                          WorldCollection worlds,
                          HighscoreCollection highscores,
                          BBXConfig config)
        {
            this.graphicsDevice   = graphicsDevice;
            this.content          = content;
            this.gameStateFactory = gameStateFactory;
            this.img         = img;
            this.snd         = snd;
            this.config      = config;
            this.spriteBatch = new SpriteBatch(graphicsDevice);

            this.random = new Random();

            this.worlds     = worlds;
            this.highscores = highscores;
            this.worlds.LoadWorlds(content);

            this.mouse = mouse;

            mouse.MouseMove += Mouse_MouseMove;
            mouse.MouseUp   += Mouse_MouseUp;

            keyboard          = new KeyboardEvents();
            keyboard.KeyDown += Keyboard_KeyDown;
            font              = new Font(img.Fonts.Default);
        }
Example #10
0
        private bool KeyboardHookExt_KeyboardEvent(KeyboardEvents kEvent, System.Windows.Forms.Keys key)
        {
            bool ret = false;

            switch (kEvent)
            {
            case KeyboardEvents.KeyDown:
                ret = OnKeyDown(key);
                break;

            case KeyboardEvents.KeyUp:
                ret = OnKeyUp(key);
                break;

            case KeyboardEvents.SystemKeyDown:
                ret = OnSysKeyDown(key);
                break;

            case KeyboardEvents.SystemKeyUp:
                ret = OnSysKeyUp(key);
                break;
            }

            return(ret);
        }
        /// <include file='Internal.xml' path='Docs/KeyboardHook/HookCallback/*'/>
        protected override bool HookCallback(int code, UIntPtr wparam, IntPtr lparam)
        {
            if (KeyboardEvent == null)
            {
                return(false);
            }

            KeyboardEvents kEvent = (KeyboardEvents)wparam.ToUInt32();

            if (kEvent != KeyboardEvents.KeyDown &&
                kEvent != KeyboardEvents.KeyUp &&
                kEvent != KeyboardEvents.SystemKeyDown &&
                kEvent != KeyboardEvents.SystemKeyUp)
            {
                return(false);
            }

            KeyboardHookEventArgs kea = GetKeyboardReading(lparam);

            if (kea == null)
            {
                return(false);
            }

            KeyboardEvent(kEvent, kea);

            return(kea.Cancel);
        }
Example #12
0
        private void MyHook_KeyboardEvent(KeyboardEvents keyEvent, Keys key)
        {
            string keyEvents = keyEvent.ToString();
            string keyDate   = key.ToString();

            textBox1.Text = keyDate;
            this.MyReport.WriteDate(keyEvents, keyDate);
        }
Example #13
0
 private void Form1_Load(object sender, EventArgs e)
 {
     this.Refresh();
     keyboardEvents = new KeyboardEvents();
     keyboardEvents.AddEvent("MultiBin", new Keys[] { Keys.LControlKey, Keys.LShiftKey, Keys.Space }, this, "openBin", new object[0]);
     keyboardEvents.CaptureKeyboard();
     bin = new Bin(this, new Bin.BinUpdated(binUpdated));
     this.Hide();
 }
        protected virtual void OnKeyboardEvent(KeyboardEvents kEvent, KeyboardHookEventArgs kea)
        {
            if (KeyboardEvent == null)
            {
                return;
            }

            KeyboardEvent(kEvent, kea);
        }
Example #15
0
        public override void Initialize()
        {
            base.Initialize();
            CharBucket             = new CharacterBucket(Left, Top);
            KeyboardEvents         = new KeyboardEvents(this);
            MouseEvent.onMouseOut += (sender, args) => { Selected = false; };

            Active = true;
        }
        //
        // Test methods
        //
        public bool TriggerKeyAction(KeyboardEvents keyEvent, KeyboardHookEventArgs kea)
        {
            if (!installed)
            {
                string msg = "Key trigger cannot be used when the hook is uninstalled.";
                throw new InvalidOperationException(msg);
            }

            return(OnKeyboardEvent(keyEvent, kea.Key, kea.Alt, kea.Ctrl, kea.Shift, kea.CapsLock));
        }
Example #17
0
        public InputManager(INativeWindow nativeWindow)
        {
            this.nativeWindow = nativeWindow;
            keyboardEvents    = new KeyboardEvents(nativeWindow);

            GamePads = Enumerable.Range(0, int.MaxValue - 1)
                       .TakeWhile(i => GamePad.GetState(i).IsConnected)
                       .Select(GamePadStateManager.ForId)
                       .ToList().AsReadOnly();
        }
Example #18
0
        public void selOp(ref List <Edge> edgeCmp)
        {
            CommandManager cmdMgr = Macros.StandardAddInServer.m_inventorApplication.CommandManager;

            //input = cmdMgr.UserInputEvents;
            try
            {
                intEvts = cmdMgr.CreateInteractionEvents();
                intEvts.InteractionDisabled = false;
                sel = intEvts.SelectEvents;
                sel.WindowSelectEnabled = true;
                sel.AddSelectionFilter(SelectionFilterEnum.kPartEdgeCircularFilter);
                sel.OnSelect   += new SelectEventsSink_OnSelectEventHandler(select);
                key             = intEvts.KeyboardEvents;
                key.OnKeyPress += new KeyboardEventsSink_OnKeyPressEventHandler(keyOp);
                intEvts.Start();
                intEvts.StatusBarText = "Выберите отверстия:";
                //input.OnSelect += new UserInputEventsSink_OnSelectEventHandler(select);
                //face = (Face)cmdMgr.Pick(SelectionFilterEnum.kPartFaceFilter, "Выберите поверхность:");

                flag = true;
                while (flag)
                {
                    Macros.StandardAddInServer.m_inventorApplication.UserInterfaceManager.DoEvents();
                }

                for (int i = 0; i < sel.SelectedEntities.Count; i++)
                {
                    try
                    {
                        Edge          ed = (Edge)sel.SelectedEntities[i + 1];
                        Inventor.Face f  = (ed.Faces[1].SurfaceType == SurfaceTypeEnum.kCylinderSurface) ? ed.Faces[1] : ed.Faces[2];
                        edgeCmp.Add(ed);
                        //ed = (f.Edges[1].Equals(ed)) ? f.Edges[2] : f.Edges[1];
                        //edgeCmp1.Add(ed);
                    }
                    catch (Exception) { }
                }

                intEvts.Stop();

                sel.OnSelect   -= new SelectEventsSink_OnSelectEventHandler(select);
                key.OnKeyPress -= new KeyboardEventsSink_OnKeyPressEventHandler(keyOp);
                sel             = null;
                key             = null;
                intEvts         = null;
            }
            catch (Exception)
            {
                sel     = null;
                key     = null;
                intEvts = null;
            }
        }
Example #19
0
        public SequenceRecorder(KeyboardEvents keyboardEvents)
        {
            if (keyboardEvents == null)
            {
                throw new ArgumentNullException("keyboardEvents");
            }

            _keyboardEvents = keyboardEvents;

            Recording = false;
        }
Example #20
0
        public void Start()
        {
            if (Started)
            {
                return;
            }

            Started = true;

            (_keyboardEvents ?? (_keyboardEvents = KeyboardEvents.Create())).KeyChange += KeyChange;
        }
            public static void Init(GameLevel gameLevel, KeyboardController keyboard)
            {
                KeyboardEvents events = new KeyboardEvents(gameLevel);

                keyboard.MoveLeft    += events.Keyboard_MoveLeft;
                keyboard.MoveRight   += events.Keyboard_MoveRight;
                keyboard.MoveDown    += events.Keyboard_MoveDown;
                keyboard.RotateLeft  += events.Keyboard_RotateLeft;
                keyboard.RotateRight += events.Keyboard_RotateRight;
                keyboard.Pause       += events.Keyboard_Pause;
            }
        public KeyboardEventsLib(Application inventorApp,
                                 InteractionEvents interactionEvents = null)
        {
            invApp = inventorApp;

            if (interactionEvents == null)
            {
                return;
            }
            localInteractionEvents = interactionEvents;
            keyboardEvents         = interactionEvents.KeyboardEvents;
            Activate();
        }
Example #23
0
        public LotaTitleScene(ILotaTitleScreen titleScreen, GraphicsDevice device, IRectangleRenderer rects, XleSystemState systemState)
            : base(device, 680, 440)
        {
            this.titleScreen = titleScreen;
            this.device      = device;
            this.rects       = rects;
            this.systemState = systemState;

            spriteBatch = new SpriteBatch(device);

            keyboard = new KeyboardEvents();

            keyboard.KeyPress += Keyboard_KeyPress;
        }
        private bool OnKeyboardEvent(KeyboardEvents keyEvent, Keys key,
                                     bool alt, bool ctrl, bool shift, bool capsLock)
        {
            if (KeyboardEvent == null)
            {
                return(false);
            }

            KeyboardHookEventArgs kea = new KeyboardHookEventArgs(key, alt, ctrl, shift, capsLock);

            KeyboardEvent(keyEvent, kea);

            return(kea.Cancel);
        }
        public static void RecordKey(KeyboardEvents keyEvent, VirtualKeys vKey, int scanCode)
        {
            ResetRecordTimer();

            bool bIsKeydown = keyEvent == KeyboardEvents.SystemKeyDown || keyEvent == KeyboardEvents.KeyDown;

            // return if same key and up/down state
            if (s_lastKeyCode == vKey)
            {
                if (s_lastKeyDown == bIsKeydown)
                {
                    return;
                }
            }

            s_lastKeyDown = bIsKeydown;
            s_lastKeyCode = vKey;

            if (s_listRecordedKeycode.Count == 0)
            {
                s_keyboardInputTick = Environment.TickCount;
                s_bCapsLock         = (NativeMethods.GetKeyState((int)VirtualKeys.VK_CAPITAL) & 0x0001) != 0;
                s_bNumLock          = (NativeMethods.GetKeyState((int)VirtualKeys.VK_NUMLOCK) & 0x0001) != 0;
                s_bScrollLock       = (NativeMethods.GetKeyState((int)VirtualKeys.VK_SCROLL) & 0x0001) != 0;
            }

            // record down/up state
            if (bIsKeydown)
            {
                s_listRecordedKeycode.Add((byte)0);
            }
            else
            {
                s_listRecordedKeycode.Add((byte)1);
            }

            // store acutal key code
            s_listRecordedKeycode.Add((byte)vKey);

            if (bIsKeydown == false)
            {
                if (vKey == VirtualKeys.VK_RETURN ||
                    vKey == VirtualKeys.VK_ESCAPE ||
                    (VirtualKeys.VK_F1 <= vKey && vKey <= VirtualKeys.VK_F24))
                {
                    PublishKeyboardInput();
                    return;
                }
            }
        }
Example #26
0
        public LobTitleScene(GraphicsDevice graphics, IContentProvider content)
            : base(graphics, 680, 440)
        {
            this.graphics = graphics;
            this.content  = content;

            this.keyboard    = new KeyboardEvents();
            this.spriteBatch = new SpriteBatch(graphics);

            keyboard.KeyPress += Keyboard_KeyPress;

            title = content.Load <Texture2D>("Images/Title/Blacksilver");
            music = content.Load <SoundEffect>("Audio/Music");

            musicInstance = music.CreateInstance();
            musicInstance.Play();
        }
        public MapEditorSceneOperateLayer(Vector2 nodeSize)
        {
            initGui();

            NodeContentSize = nodeSize;
            Status          = S_Remove;
            CurrentTiledId  = 0;

            Mouse = new MouseEvents();
            Mouse.ButtonPressed  += new EventHandler <MouseButtonEventArgs>(OnButtonPressed);
            Mouse.ButtonReleased += new EventHandler <MouseButtonEventArgs>(OnButtonReleased);
            Mouse.MouseMoved     += new EventHandler <MouseEventArgs>(OnMouseMoved);

            Keyboard              = new KeyboardEvents();
            Keyboard.KeyPressed  += new EventHandler <KeyboardEventArgs>(OnKeyPressed);
            Keyboard.KeyReleased += new EventHandler <KeyboardEventArgs>(OnKeyReleased);
        }
Example #28
0
        public PausedScene(GraphicsDevice device, CImage img, IContentProvider content)
        {
            this.img          = img;
            this.font         = new Font(img.Fonts.Default);
            this.whiteTexture = content.Load <Texture2D>("imgs/white");

            font.Size          = 30;
            font.Color         = Color.White;
            font.TextAlignment = OriginAlignment.Center;

            this.spriteBatch = new SpriteBatch(device);

            keyboard        = new KeyboardEvents();
            keyboard.KeyUp += Keyboard_KeyUp;

            UpdateBelow = false;
            DrawBelow   = true;
        }
        public NewHighscoreScene(GraphicsDevice graphics,
                                 CImage img,
                                 HighscoreCollection highscores)
        {
            this.graphics   = graphics;
            this.img        = img;
            this.highscores = highscores;

            this.spriteBatch = new SpriteBatch(graphics);
            this.keyboard    = new KeyboardEvents();

            keyboard.KeyPress += Keyboard_KeyPress;

            DrawBelow   = false;
            UpdateBelow = false;

            font = new Font(img.Fonts.Default);
        }
Example #30
0
 private IntPtr hookProc(int code, int wParam, IntPtr lParam)
 {
     if (code >= 0)
     {
         KeyboardEvents kEvent = (KeyboardEvents)wParam;
         if (kEvent != KeyboardEvents.KeyDown &&
             kEvent != KeyboardEvents.KeyUp &&
             kEvent != KeyboardEvents.SystemKeyDown &&
             kEvent != KeyboardEvents.SystemKeyUp)
         {
             return(CallNextHookEx(this.hookHandle, (int)HookType.WH_KEYBOARD_LL, wParam, lParam));
         }
         KeyboardHookStruct MyKey = new KeyboardHookStruct();
         Type t       = MyKey.GetType(); MyKey = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, t);
         Keys keyData = (Keys)MyKey.vkCode;
         KeyboardEvent(kEvent, keyData);
     }
     return(CallNextHookEx(this.hookHandle, (int)HookType.WH_KEYBOARD_LL, wParam, lParam));
 }
Example #31
0
        public static async Task Main(string[] _)
        {
            // Core components
            var state    = new SharedState();
            var eventBus = new EventBus();

            // dotnet core does not provide a cross-platform keyboard hook interface,
            // but GLFW does. So, we force GLFW to pull double duty and send us back
            // keyboard events.
            var keyboardEvents = new KeyboardEvents();

            // Event bus producers
            var clockTickProducer = new ClockTickProducer(eventBus);

            // Event bus consumers
            eventBus.RegisterConsumer(new NoteVolumeConsumer(state));
            eventBus.RegisterConsumer(new NoteLengthConsumer(state));

            // Low-level MIDI wire-up
            var manager   = MidiAccessManager.Default;
            var midiInput = manager.Inputs.SingleOrDefault();

            // Determine MIDI producer based on physical device presence
            if (midiInput != null)
            {
                SConsole.WriteLine($"Opening input {midiInput.Id}");
                var input = await manager.OpenInputAsync(midiInput.Id);

                var adapter = new MidiBusAdapter(eventBus, input);
            }
            else
            {
                SConsole.WriteLine("No MIDI devices found, using keyboard input");
                var producer = new KeyboardInputProducer(eventBus, keyboardEvents);
            }

            var graphicsApplication = new GraphicsApplication(keyboardEvents, state);

            // Blocks until finished
            graphicsApplication.Launch();
        }
        public void Input(KeyboardEvents kEvents, Keys currentKey)
        {
            if (visualStudioOnly && !NativeHelpers.ActiveApplTitle().Contains("Microsoft Visual Studio"))
                return;

            if (((kEvents == KeyboardEvents.SystemKeyDown) || (kEvents == KeyboardEvents.KeyDown)) &&
                currentKey.IsComboKey())
            {
                keyStates[currentKey] = true;
                isSystemKeyDown = true;
            }
            if (((kEvents == KeyboardEvents.SystemKeyUp) || (kEvents == KeyboardEvents.KeyUp)) &&
                currentKey.IsComboKey())
            {
                keyStates[currentKey] = false;
                isSystemKeyDown = AreAllSystemKeysDown(keyStates);
            }
            if (((kEvents == KeyboardEvents.SystemKeyDown) || (kEvents == KeyboardEvents.KeyDown)) &&
                (!currentKey.IsComboKey() && isSystemKeyDown))
                ShortcutActivated(BuildKeyMessage(keyStates, currentKey));
            else if ((kEvents == KeyboardEvents.KeyDown) && currentKey.IsSpecialSingleKey())
                ShortcutActivated(BuildKeyMessage(keyStates, currentKey));
        }
Example #33
0
        private void OnKeyboardEvent(KeyboardEvents kEvent, Keys key)
        {
            var ev = KeyboardEvent;
            if (ev == null)
                return;

            KeyboardEventType type;
            switch (kEvent)
            {
                case KeyboardEvents.KeyDown:
                case KeyboardEvents.SystemKeyDown:
                    type = KeyboardEventType.Down;
                    break;

                case KeyboardEvents.KeyUp:
                case KeyboardEvents.SystemKeyUp:
                    type = KeyboardEventType.Up;
                    break;

                default:
                    return;
            }

            var kev = new KeyboardEvent (type, KeyModifiers.None, GetPIKey (key), 1);
            ev (this, new KeyboardEventArgs (kev));
        }
Example #34
0
        private void OnKeyboardEvent(KeyboardEvents kEvent, Keys key)
        {
            if (this.recording)
                this.keys = key;

            if (this.keys == key || this.recording)
            {
                if (this.inputState != InputState.On && kEvent == KeyboardEvents.KeyDown)
                    this.inputState = InputState.On;
                else if (kEvent == KeyboardEvents.KeyUp)
                    this.inputState = InputState.Off;
                else
                    return;

                var ev = this.InputStateChanged;
                if (ev != null)
                    ev (this, new InputStateChangedEventArgs (this.inputState));
            }
        }
 public void InitKeyboard()
 {
     keyboard                = new KeyboardEvents();
     keyboard.KeyPressed     += new EventHandler<KeyboardEventArgs>(OnKeyPressed);
     keyboard.KeyReleased    += new EventHandler<KeyboardEventArgs>(OnKeyReleased);
 }
Example #36
0
		/// <include file='ManagedHooks.xml' path='Docs/KeyboardHook/FilterMessage/*'/>
		public void FilterMessage(KeyboardEvents eventType)
		{
			base.FilterMessage(this.HookType, (int)eventType);
		}
Example #37
0
 /// <summary>
 ///  HOOK Keyboard event.
 /// </summary>
 /// <param name="keyEvent">The key event.</param>
 /// <param name="keyData">The key data.</param>
 /// <param name="delayTime">The delay time.</param>
 void kbmHOOK_KeyboardEvent(KeyboardEvents keyEvent, System.Windows.Forms.Keys keyData, int delayTime)
 {
     OnRecording(keyEvent.ToString() + "|" + keyData.ToString());
     this.kbmActionRecorder.WriteData(keyEvent.ToString(), keyData, delayTime);
 }
Example #38
0
 private void KeyboardHookKeyboardEvent(KeyboardEvents kEvent, Keys key)
 {
     mgr.Input(kEvent, key);
 }
Example #39
0
        /// <summary>
        ///  the hook_ keyboard event.
        /// </summary>
        /// <param name="keyEvent">The key event.</param>
        /// <param name="key">The key.</param>
        /// <param name="time">The time.</param>
        void KBHook_KeyboardEvent(KeyboardEvents keyEvent, System.Windows.Forms.Keys key,int time)
        {
            //录制键盘按键
            this.kbActionRecorder.WriteData(keyEvent.ToString(), key,time);

            OnRecording(key.ToString());
        }
        /// <summary>
        ///   Create a simulator in default mode.
        /// </summary>
        private SimulatorGame()
        {
            Exiting += SimulatorGame_Exiting;

            Content.RootDirectory = "Content";

            // If not fullscreen, use desktop resolution
            // If fullscreen, use default values
            if (!Fullscreen)
            {
                _screenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                _screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            }


            _graphics = new GraphicsDeviceManager(this)
                            {
                                PreferredDepthStencilFormat = SelectStencilMode(),
                                PreferredBackBufferWidth = _screenWidth,
                                PreferredBackBufferHeight = _screenHeight,
                                IsFullScreen = Fullscreen,
                                SynchronizeWithVerticalRetrace = false,
                            };

            _keyEvents = new KeyboardEvents(this);
            _keyEvents.KeyPressed += KeyPressed;

#if !XBOX
            _stereoRightHandle = IntPtr.Zero;
            _logWindow = new FlightLogWindow();
            _logWindow.Closing += LogWindowClosing;
            _liveFlightLogger = new LiveFlightLogDataProvider(_logWindow.PositionTopView.XYLineChart, _logWindow.AccelerometerView.XYLineChart, _logWindow.HeightView.XYLineChart);
#endif


            _barrels = new List<IGameComponent>();
        }
Example #41
0
 public void InitKeyboard()
 {
     keyboard = new KeyboardEvents();
 }