Project Description
This set of input handlers for XNA 4 provides event-based handling of mouse and keyboard actions. Ideal for implementing graphical user interfaces and point and click games such as strategy games.

Trying to make a user interface or a game with a point-and-click interface? Then this set of event-driven input handlers is for you. It provides an extensive range of handlers for your input and mouse. All you have to do is provide an implementation for your handler then add your handler to the corresponding event inside the mouse or keyboard object. No more figuring out the myriad of situations that can happen with input; the events tell you exactly what was pressed and when, so you only have to handle it.

Following is the list of handlers. You inherit the interface for the handlers, provide the implementation, then create a new delegate for your handler and add the delegate into the mouse or keyboard handler's event object (this is shown in detail in the sample project).

Mouse handlers:

public void HandleMouseScrollWheelMove(MouseState m, int diff) { }
public void HandleMouseMoving(MouseState m) { }
public void HandleLeftMouseClick(MouseState m) { }
public void HandleLeftMouseDoubleClick(MouseState m) { }
public void HandleLeftMouseDown(MouseState m) { }
public void HandleLeftMouseUp(MouseState m) { }
public void HandleLeftMouseDragging(MouseState m, MouseState origin) { }
public void HandleLeftMouseDragDone(MouseState m, MouseState origin) { }
public void HandleRightMouseClick(MouseState m) { }
public void HandleRightMouseDoubleClick(MouseState m) { }
public void HandleRightMouseDown(MouseState m) { }
public void HandleRightMouseUp(MouseState m) { }
public void HandleRightMouseDragging(MouseState m, MouseState origin) { }
public void HandleRightMouseDragDone(MouseState m, MouseState origin) { }

Keyboard handlers:

public void HandleKBKeyDown(Keys[] klist, Keys focus, KBModifiers m) { }
public void HandleKBKeyLost(Keys[] klist, KBModifiers m) { }
public void HandleKBKeyRepeat(Keys repeatkey, KBModifiers m) { }
public void HandleKBKeysReleased() { }

Multiple handlers can be added into the mouse or keyboard event object, so multiple objects in your application can receive an event when it happens.

See the 'Documentation' section further information on how to use the input handlers in your code.

Current version is 1.1

New in latest release:

- project has been upgraded to XNA 4.
- You now call poll for keyboard and mouse without a game time parameter:
public void Poll(MouseState st)
public void Poll(KeyboardState st)

The handlers now keep track of time internally using System.Diagnostics.Stopwatch.

Last edited Oct 9, 2013 at 3:06 AM by DireAussie, version 27