This project is read-only.
Prototype By: Priyesh Dixit
Engineering By: Jason Hardman & Subhir Rao
DLL and Docs By: Jason Hardman


DWController is an override controller system in C# for Xna.
It collects input from the Mouse, Keyboard, XBox Analog Controls, and XBox Digital Controls.

Key/Function pairs are added in override constructor.
Key-press events call Functions when triggered, passing the key_value and a user supplied object[] array via EventArg.


Includes demo project


To use DWController, override the Controller class, use the controller.Add() function with the key you wish to assign, and function you want to call, and the timer-delay for the key input. This time delay repeat inputs (from holding a key down) giving your application a consistent input rate across multiple PC hardware configurations. The key-delay argument is specified in milliseconds. To disable it, just pass in 0.0f.

It’s simple. To connect a key to a function, use commands like:

Add(new KeyboardControl(Keys.W, MoveForward, 10));
Add(new KeyboardControl(Keys.A, MoveLeft, 10));
Add(new MouseControl(ControlType.Motion, Rotate, 0));
Add(new MouseControl(ControlType.LeftButton, Attack, 0));


  • Import the dll into your project…
  • Right-click References (in Project Explorer) and click Add…
  • Locate the DWControllers dll and select.

Remember to include:

using DarkWynter.Engine.Controllers;

Override The Controller Class

using DarkWynter.Engine.Controllers;

public class GameController : Controller

  public GameController(int player, PlayerIndex playerIndex)
  : base(player, playerIndex)

    // Add keyboard and mouse buttons
    // Pass in the key you want to use, the function you want to call, and the refresh rate of the key
    Add(new KeyboardControl(Keys.W, MoveForward, 10));
    Add(new MouseControl(ControlType.LeftButton,Attack,0));

  // Function called by controller to handle Move Forward event
  private void MoveForward(ControllerBoolEventArgs args)
    args.objectLibrary.humans[playerNumber].Translate(new Vector2(0, 10));

  // Function called by controller to handle Attack event
  private void Attack(ControllerBoolEventArgs args)


Instantiate in your main Game file…

  ControllerManager controllerManager;
  List<object> args = new List<object>();

  protected override void Initialize()

    // Create a List of Child Controllers
    List<Type> controllerTypes = new List<Type>();

    // Pass in Width and Height used by mouse.
    controllerManager = new ControllerManager(

    // Pass “this” as EventArgs to Conroller delegates functions



And Update…

protected override void Update(GameTime gameTime)
  // Checks if any controllers Added or Removed

  // Update Appropriate Controller
  if (gameMode == GameMode.Menu)
    // Update all MenuControllers
    List<Controller> controllers = controllerManager.GetControllers(typeof(MenuController));
    for (int i = 0; i < controllers.Count; i++)
      controllers[i].Update(ref args);
  if (gameMode == GameMode.Game)
    // Update all GameControllers
    List<Controller> controllers = controllerManager.GetControllers(typeof(GameController));
    for (int i = 0; i < controllers.Count; i++)
      controllers[i].Update(ref args);


Enjoy :-j

Last edited Mar 12, 2009 at 7:44 PM by flatline0, version 5