summaryrefslogtreecommitdiff
path: root/src/Noddybox.Emulation.Xna.Input/Keyboard
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2012-06-04 23:24:52 +0000
committerIan C <ianc@noddybox.co.uk>2012-06-04 23:24:52 +0000
commitd3444080c31f10871ad8e97ceb8517565f74285a (patch)
tree1378949c9ed0fbeb116cb8030bfcfbff6f79572f /src/Noddybox.Emulation.Xna.Input/Keyboard
parent643c13f3ebd3240aa58f83a35a66909fdd9545d9 (diff)
Added code to handle joystick, and completed demo program. Ready to be used.
Diffstat (limited to 'src/Noddybox.Emulation.Xna.Input/Keyboard')
-rw-r--r--src/Noddybox.Emulation.Xna.Input/Keyboard/KeyboardDriver.cs26
1 files changed, 24 insertions, 2 deletions
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,18 +153,40 @@ namespace Noddybox.Emulation.Xna.Input.Keyboard
#region Public members
/// <summary>
- /// Stops consuming inputs.
+ /// Stops consuming inputs and releases all keys.
/// </summary>
- public void StopKeyboardUpdates()
+ /// <param name="generateEvents">Generates events for cleared keys.</param>
+ 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});
+ }
+ }
+ }
}
}
/// <summary>
+ /// Stops consuming inputs and releases all keys. Generates events for released keys.
+ /// </summary>
+ public void StopKeyboardUpdates()
+ {
+ StopKeyboardUpdates(true);
+ }
+
+ /// <summary>
/// Starts consuming inputs.
/// </summary>
public void StartKeyboardUpdates()