From 60b52b009c2f74cea7d5ffb0ad62cbbc55c41729 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 27 May 2012 22:18:17 +0000 Subject: Updated keyboard to chain itself to InputManager. --- src/Noddybox.Emulation.Xna.Input/InputManager.cs | 102 +++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/Noddybox.Emulation.Xna.Input/InputManager.cs (limited to 'src/Noddybox.Emulation.Xna.Input/InputManager.cs') diff --git a/src/Noddybox.Emulation.Xna.Input/InputManager.cs b/src/Noddybox.Emulation.Xna.Input/InputManager.cs new file mode 100644 index 0000000..8b0adde --- /dev/null +++ b/src/Noddybox.Emulation.Xna.Input/InputManager.cs @@ -0,0 +1,102 @@ +// This file is part of the Noddybox.Emulation C# suite. +// +// Noddybox.Emulation is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Noddybox.Emulation is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Noddybox.Emulation. If not, see . +// +// Copyright (c) 2012 Ian Cowburn +// +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Noddybox.Emulation.Keyboard.Schema; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input.Touch; + +namespace Noddybox.Emulation.Xna.Input +{ + /// + /// Provides a common source for getting to the inputs. + /// + public class InputManager + { + #region Event arguments + + /// + /// Event data when the screen is touched. + /// + public class TouchLocationEventArgs : EventArgs + { + /// + /// Whether the event has been consumed by one of the subscribers. + /// + public bool Handled {get; set;} + /// + /// The touch. + /// + public TouchLocation Location {get; set;} + } + + #endregion + + #region Public members + + /// + /// Reads the toch screen and passes the events on. + /// + public void Update() + { + MulticastDelegate d = TouchEvent as MulticastDelegate; + + if (d != null) + { + foreach (TouchLocation t in TouchPanel.GetState()) + { + TouchLocationEventArgs args = new TouchLocationEventArgs() + { + Location = t, + Handled = false + }; + + foreach (var f in d.GetInvocationList()) + { + if (!args.Handled) + { + f.DynamicInvoke(this, args); + } + } + } + } + } + + #endregion + + #region Events + + public EventHandler TouchEvent; + + #endregion + + #region Constructors + + /// + /// Constructor. + /// + public InputManager() + { + } + + #endregion + } +} -- cgit v1.2.3