public static Keyboard Create(KeyboardFlags flags) { return new CustomKeyboard(flags); }
public uint Read(ushort address, int size) { switch (address) { case 0x60: if (outputBuffer.Count == 0) return 0; byte ret = setCommandByte ? commandByte : outputBuffer.Dequeue(); if (outputBuffer.Count == 0) statusRegister &= ~KeyboardFlags.OutputBufferFull; setCommandByte = false; return ret; case 0x64: return (ushort) statusRegister; default: System.Diagnostics.Debugger.Break(); break; } return 0; }
internal static extern void keybd_event(byte bVk, byte bScan, KeyboardFlags dwFlags, int dwExtraInfo);
public KeyboardDevice() { statusRegister |= KeyboardFlags.UnLocked; outputBuffer = new Queue<byte>(); }
public void KeyUp(uint scancode) { outputBuffer.Enqueue((byte)(scancode + 0x80)); statusRegister |= KeyboardFlags.OutputBufferFull; OnIRQ(new EventArgs()); }
private void SetStatusCode(byte status) { statusRegister |= KeyboardFlags.OutputBufferFull; outputBuffer.Enqueue(status); }
private void ProcessCommand() { if (setCommandByte) { SetStatusCode(0xfa); setCommandByte = false; } else { switch (inputBuffer) { case 0x60: setCommandByte = true; break; case 0xa8: commandByte &= 0xDF; break; case 0xaa: statusRegister |= KeyboardFlags.SystemFlag; SetStatusCode(0x55); break; case 0xab: SetStatusCode(0x00); break; case 0xae: enabled = true; break; case 0xf5: SetStatusCode(0xfa); break; case 0xff: SetStatusCode(0xfa); SetStatusCode(0xaa); break; default: break; } } }
public void Write(ushort address, uint value, int size) { switch (address) { case 0x60: if (setCommandByte) commandByte = (byte)value; else inputBuffer = (byte)value; statusRegister &= ~KeyboardFlags.CommandFlag; ProcessCommand(); break; case 0x64: inputBuffer = (byte)value; statusRegister |= KeyboardFlags.CommandFlag; ProcessCommand(); break; default: break; } }
public void Reset() { statusRegister |= KeyboardFlags.UnLocked; outputBuffer.Clear(); }
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null) { if (!this.initialized) { this.initialized = true; this.InitializeComponent(); // TODO: add autosize property this.txtEditor.AutoSize = EditorAutoSizeOption.Disabled; // TODO: apply the height of the control. } UpdateLayout(propertyName, lblLabel, lblAssistive, frmContainer, bxvLine, imgLeadingIcon, imgTrailingIcon); switch (propertyName) { case nameof(base.TranslationX): base.OnPropertyChanged(propertyName); break; case nameof(this.Keyboard): this.txtEditor.Keyboard = this.Keyboard; break; case nameof(KeyboardFlags): if (KeyboardFlags != null) { try { string[] flagNames = ((string)KeyboardFlags).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); KeyboardFlags allFlags = 0; foreach (var flagName in flagNames) { KeyboardFlags flags = 0; Enum.TryParse <KeyboardFlags>(flagName.Trim(), out flags); if (flags != 0) { allFlags |= flags; } } txtEditor.Keyboard = Keyboard.Create(allFlags); } catch { throw new XamlParseException("The keyboard flags are invalid or have a wrong specification."); } } break; case nameof(this.MaxLength): this.txtEditor.MaxLength = this.MaxLength; break; case nameof(this.ClearIcon): if (!string.IsNullOrEmpty(this.ClearIcon)) { imgClearIcon.SetImage(ClearIcon); } SetClearIconIsVisible(); break; case nameof(CustomClearIcon): if (CustomClearIcon != null) { imgClearIcon.SetCustomImage(CustomClearIcon); } SetClearIconIsVisible(); break; case nameof(this.ClearIconIsVisible): SetClearIconIsVisible(); break; case nameof(this.TabIndex): if (this.TabIndex != 0) { this.txtEditor.TabIndex = this.TabIndex; this.TabIndex = 0; } break; case nameof(this.IsTabStop): this.txtEditor.IsTabStop = this.IsTabStop; break; } }