// Should probably be called "try to process input" amirite // ☜(゚ヮ゚☜) (❁´◡`❁) ( •_•)>⌐■-■ public void ProcessInput() { Button lastButton = null; var input = Console.ReadKey(true); while (input.Key != ConsoleKey.Escape) { var button = _controls.ContainsKey(input.Key) ? _controls[input.Key] : null; if (button != null) { if (lastButton != button) { _listener?.OnButtonRelease(lastButton); } _listener?.OnButtonPress(button); var snapshot = button; new Thread(() => { Thread.Sleep(500); _listener?.OnButtonRelease(snapshot); }).Start(); // Yo dawn, I hear you like threads. lastButton = button; } input = Console.ReadKey(true); } }
private void WinFormsEmulatorSurface_KeyUp(object sender, KeyEventArgs e) { var button = _controls.ContainsKey(e.KeyCode) ? _controls[e.KeyCode] : null; if (button != null) { _listener?.OnButtonRelease(button); } }