public override void Tick() { mElapsedHardwareTicks++; if (mElapsedHardwareTicks >= mRate) { mElapsedHardwareTicks = 0; mElapsedTicks++; if (mMessage != 0) { AttachedCPU.FireInterrupt(mMessage); } } }
public void HandleKeyEvent() { if (Event.current.isKey) { UInt16 key = 0; switch (Event.current.keyCode) { case KeyCode.Backspace: key = 0x10; break; case KeyCode.Return: key = 0x11; break; case KeyCode.Insert: key = 0x12; break; case KeyCode.Delete: key = 0x13; break; case KeyCode.UpArrow: key = 0x80; break; case KeyCode.DownArrow: key = 0x81; break; case KeyCode.LeftArrow: key = 0x82; break; case KeyCode.RightArrow: key = 0x83; break; case KeyCode.LeftShift: case KeyCode.RightShift: key = 0x90; break; case KeyCode.LeftControl: case KeyCode.RightControl: case KeyCode.LeftCommand: case KeyCode.RightCommand: key = 0x91; break; default: if ((int)Event.current.keyCode >= 0x20 && (int)Event.current.keyCode < 0x80) { key = (UInt16)Event.current.keyCode; } break; } if (key != 0) { if (Event.current.type == EventType.KeyUp) { RTUtil.Log("Up: {0}", key); lock (mActiveKeys) { mActiveKeys.Remove(key); } } else if (Event.current.type == EventType.KeyDown) { RTUtil.Log("Down: {0}", key); lock (mBuffer) { mBuffer.Enqueue(key); } lock (mActiveKeys) { if (!mActiveKeys.Contains(key)) { mActiveKeys.Add(key); } } if (mMessage != 0) { AttachedCPU.FireInterrupt(mMessage); } } } Event.current.Use(); } }