public void HandleInput(ExternalInputEvent e) { KeyEventArgs keyEvent = (KeyEventArgs)e.TheEvent; bool isUp = System.Convert.ToBoolean(e.Extra); if (base.CPU.PPI != null) { base.CPU.PPI.PutKeyData(keyEvent.KeyValue & 0xFF, isUp); } }
public void HandleInput(ExternalInputEvent e) { if (ReferenceEquals(e.Handler, null)) { return; } if (e.TheEvent is KeyEventArgs) { var theEvent = (KeyEventArgs)e.TheEvent; if (cadCounter > 0) { cadCounter--; return; } if (((int)(theEvent.Modifiers) & (int)Keys.Control) == (int)Keys.Control) { isCtrlDown = !System.Convert.ToBoolean(e.Extra); } else { isCtrlDown = false; } if (((int)(theEvent.Modifiers) & (int)Keys.Alt) == (int)Keys.Alt) { isAltDown = !System.Convert.ToBoolean(e.Extra); } else { isAltDown = false; } if (isCtrlDown && isAltDown && ((int)(theEvent.KeyCode) & (int)Keys.Insert) == (int)Keys.Insert) { cadCounter = 3; // Ignore the next three events, which will be the release of CTRL, ALT and DEL e.TheEvent = new KeyEventArgs(Keys.Delete); X8086.Notify("Sending CTRL+ALT+DEL", X8086.NotificationReasons.Info); } } if (pendingInput.Count == 0) { // Wake up the scheduler in case it is sleeping Notify(); // Kick the CPU simulation to make it yield mCPU.DoReschedule = true; } pendingInput.Add(e); }
public void HandleInput(ExternalInputEvent e) { MouseEventArgs m = (MouseEventArgs)e.TheEvent; Point p = new Point(m.X - MidPoint.X, m.Y - MidPoint.Y); //If p.X <> 0 Then If p.X > 0 Then p.X = 1 Else p.X = -1 //If p.Y <> 0 Then If p.Y > 0 Then p.Y = 1 Else p.Y = -1 p.X = (int)(Math.Ceiling((double)Math.Abs(p.X) / 5) * Math.Sign(p.X)); p.Y = (int)(Math.Ceiling((double)Math.Abs(p.Y) / 5) * Math.Sign(p.Y)); byte highbits = (byte)0; if (p.X < 0) { highbits = (byte)3; } if (p.Y < 0) { highbits = (byte)(highbits | 0xC); } byte btns = (byte)0; if (((int)(m.Button) & (int)MouseButtons.Left) == (int)MouseButtons.Left) { btns = (byte)(btns | 2); } if (((int)(m.Button) & (int)MouseButtons.Right) == (int)MouseButtons.Right) { btns = (byte)(btns | 1); } BufSerMouseData((byte)(0x40 | (btns << 4) | highbits)); BufSerMouseData((byte)(p.X & 0x3F)); BufSerMouseData((byte)(p.Y & 0x3F)); }
private void Run() { ArrayList cleanInputBuf = new ArrayList(); ArrayList inputBuf = new ArrayList(); Task tsk = null; ExternalInputEvent evt = default(ExternalInputEvent); while (true) { // Detect the end of the simulation run if (nextTime == STOPPING) { nextTime = pq.MinPriority(); break; } if (pendingInput.Count > 0) { // Fetch pending input events inputBuf = pendingInput; pendingInput = cleanInputBuf; } else if (nextTime <= mCurrentTime) { // Fetch the next pending task tsk = NextTask(); if (ReferenceEquals(tsk, null)) { continue; // This task was canceled, go round again } inputBuf.Clear(); } else { tsk = null; } if (inputBuf.Count > 0) { // Process pending input events for (int i = 0; i <= inputBuf.Count - 1; i++) { evt = (ExternalInputEvent)(inputBuf[i]); evt.TimeStamp = mCurrentTime; evt.Handler.HandleInput(evt); } inputBuf.Clear(); cleanInputBuf = inputBuf; } else if (tsk != null) { // Run the first pending task tsk.Start(); } else { // Run the CPU simulation for a bit (maxRunCycl) try { mCPU.RunEmulation(); } catch (Exception ex) { X8086.Notify("Shit happens at {0}:{1}: {2}", X8086.NotificationReasons.Fck, mCPU.Registers.CS.ToString("X4"), mCPU.Registers.IP.ToString("X4"), ex.Message); mCPU.RaiseException($"Scheduler Main Loop Error: {ex.Message}"); } if (mCPU.IsHalted) { SkipToNextEvent(); // The CPU is halted, skip immediately to the next event } } } }