Welcome Guest! To enable all features please Login or Register.



Go to last post Go to first unread
Offline fool  
#1 Posted : Monday, May 7, 2012 11:45:24 AM(UTC)

Joined: 8/24/2011(UTC)
Posts: 34
Location: New Zealand

Thanks: 4 times
Commands are generally the way to go, but I also need access to the key ups and downs as they happen; pretty much the same as the equivalent Windows events, but we can abstract things and just work with InputButton keys after the various implementations do a translation. So for example, I added the following delegates to WindowsKeyboard:


public delegate void KeyDelegate(InputButton key);

public static KeyDelegate OnKeyDown;
public static KeyDelegate OnKeyUp;

You could use events but I think a single delegate should be sufficient. Then I wired them up to the WindowsKeyboard.Update implementation:


foreach (InputButton newKey in keysDown)
	// ...

	if (OnKeyDown != null)

// ...

foreach (InputButton keyNotPressedAnymore in keysUp)
	// ...

	if (OnKeyUp != null)

This seems to work well for my project, but ideally KeyDelegate, OnKeyDown and OnKeyUp are pushed into the BaseKeyboard class. Then each derived Keyboard implementation just needs to make sure it fires the delegates accordingly. What do you think?

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.028 seconds.