(My project is still active, last visited on 17 May 09)
Project Description
This set of input handlers for XNA 3.0 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 source code for further information. Most of it is well commented. There is also a sample project and a quick start guide which shows everything you need to get you started.
Current version is 1.0
New in this release:
- project has been upgraded to XNA 3.0
- you can now set repeat delay and repeat frequency of keyboard repeat events
- some exposed member variables that shouldnt have been exposed are now private. Others have been converted to properties and renamed.
Current issues:
- the code has been black box tested but no extensive unit testing done. There may be a few bugs
- there has been little performance testing as yet, however there are defintely no glaring memory leaks as reported by CLRProfiler
- no formal documentation, but source code is well commented