From d3444080c31f10871ad8e97ceb8517565f74285a Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 4 Jun 2012 23:24:52 +0000 Subject: Added code to handle joystick, and completed demo program. Ready to be used. --- .../Keyboard/KeyboardDriver.cs | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/Noddybox.Emulation.Xna.Input/Keyboard/KeyboardDriver.cs') diff --git a/src/Noddybox.Emulation.Xna.Input/Keyboard/KeyboardDriver.cs b/src/Noddybox.Emulation.Xna.Input/Keyboard/KeyboardDriver.cs index 4fa265a..6379dd8 100644 --- a/src/Noddybox.Emulation.Xna.Input/Keyboard/KeyboardDriver.cs +++ b/src/Noddybox.Emulation.Xna.Input/Keyboard/KeyboardDriver.cs @@ -153,17 +153,39 @@ namespace Noddybox.Emulation.Xna.Input.Keyboard #region Public members /// - /// Stops consuming inputs. + /// Stops consuming inputs and releases all keys. /// - public void StopKeyboardUpdates() + /// Generates events for cleared keys. + public void StopKeyboardUpdates(bool generateEvents) { if (subscribed) { manager.TouchEvent -= TouchScreenHandler; subscribed = false; + + foreach (KeyState key in keymapState) + { + if (key.IsPressed) + { + key.IsPressed = false; + + if (generateEvents && KeyEvent != null) + { + KeyEvent(this, new KeyPressEventArgs() {Key = key.Symbol, Pressed = key.IsPressed}); + } + } + } } } + /// + /// Stops consuming inputs and releases all keys. Generates events for released keys. + /// + public void StopKeyboardUpdates() + { + StopKeyboardUpdates(true); + } + /// /// Starts consuming inputs. /// -- cgit v1.2.3