コード例 #1
0
ファイル: InputState.cs プロジェクト: Crwth/UltimaXNA
 protected override void OnKeyDown(EventArgsKeyboard e)
 {
     // handle the initial key down
     if (e.Data_PreviousState == 0)
     {
         addEvent(new InputEventKB(KeyboardEvent.Down, e));
     }
     // handle the key presses. Possibly multiple per keydown message.
     for (int i = 0; i < e.Data_RepeatCount; i++)
     {
         addEvent(new InputEventKB(KeyboardEvent.Press, e));
     }
 }
コード例 #2
0
ファイル: InputState.cs プロジェクト: Crwth/UltimaXNA
 protected override void OnKeyUp(EventArgsKeyboard e)
 {
     addEvent(new InputEventKB(KeyboardEvent.Up, e));
 }
コード例 #3
0
ファイル: InputState.cs プロジェクト: Crwth/UltimaXNA
        protected override void OnChar(EventArgsKeyboard e)
        {
            // Control key sends a strange wm_char message ...
            if (e.Control && !e.Alt)
                return;

            InputEventKB pressEvent = getLastKeyPressEvent();
            if (pressEvent == null)
                throw new Exception("No corresponding KeyPress event for this WM_CHAR message. Please report this error to [email protected]");
            else
            {
                pressEvent.OverrideKeyChar(e.KeyCode);
                if (ClientVars.DebugVars.Flag_LogKeyboardChars)
                {
                    Diagnostics.Logger.Debug("Char: " + pressEvent.KeyChar);
                }
            }
        }
コード例 #4
0
ファイル: InputEventKB.cs プロジェクト: Crwth/UltimaXNA
 public InputEventKB(KeyboardEvent eventType, EventArgsKeyboard args)
     : base(args)
 {
     _eventType = eventType;
 }
コード例 #5
0
ファイル: WndProc.cs プロジェクト: Crwth/UltimaXNA
        /// <summary>
        /// Reads the supplied message and executes any Keyboard events required.
        /// </summary>
        /// <param name="message">The Message to parse</param>
        /// <returns>A Boolean value indicating wether the Key events were handled or not</returns>
        private void WmKeyEvent(ref Message message)
        {
            // HandleKeyBindings();
            // KeyPressEventArgs keyPressEventArgs = null;
            EventArgsKeyboard EventArgsKeyboard = null;

            if ((message.Id == NativeConstants.WM_CHAR) || (message.Id == NativeConstants.WM_SYSCHAR))
            {
                // Is this extra information necessary?
                // wm_(sys)char: http://msdn.microsoft.com/en-us/library/ms646276(VS.85).aspx

                EventArgsKeyboard = new EventArgsKeyboard(
                    (WinKeys)(int)(long)message.WParam,
                    (int)(long)message.LParam,
                    getModifierKeys()
                    );
                IntPtr zero = (IntPtr)0;// (char)((ushort)((long)message.WParam));
                OnChar(EventArgsKeyboard);
            }
            else
            {
                // wm_(sys)keydown: http://msdn.microsoft.com/en-us/library/ms912654.aspx
                // wm_(sys)keyup: http://msdn.microsoft.com/en-us/library/ms646281(VS.85).aspx
                EventArgsKeyboard = new EventArgsKeyboard(
                    (WinKeys)(int)(long)message.WParam,
                    (int)(long)message.LParam,
                    getModifierKeys()
                    );

                if ((message.Id == NativeConstants.WM_KEYDOWN) || (message.Id == NativeConstants.WM_SYSKEYDOWN))
                {
                    OnKeyDown(EventArgsKeyboard);
                }
                else if ((message.Id == NativeConstants.WM_KEYUP) || (message.Id == NativeConstants.WM_SYSKEYUP))
                {
                    OnKeyUp(EventArgsKeyboard);
                }
            }
        }
コード例 #6
0
ファイル: WndProc.cs プロジェクト: Crwth/UltimaXNA
 /// <summary>
 /// Raises the KeyUp event. Override this method to add code to handle when a key is released
 /// </summary>
 /// <param name="e">KeyboardPressEventArgs for the KeyUp event</param>
 protected virtual void OnKeyUp(EventArgsKeyboard e)
 {
 }
コード例 #7
0
ファイル: WndProc.cs プロジェクト: Crwth/UltimaXNA
 /// <summary>
 /// Raises the OnChar event. Override this method to add code to handle when a WM_CHAR message is received
 /// </summary>
 /// <param name="e">EventArgsKeyboard for the OnChar event</param>
 protected virtual void OnChar(EventArgsKeyboard e)
 {
 }