XNA Input Event Generator Component
Hi!
As you must know, the input system in XNA GS is based on IF statements. This is simple but when your game/project grows, it turns the source chaotic and maybe for each frame you may need to test the same key/button several times in different objects.
So, we made a very useful component to solve this problem. Whis this you can separate input code from update code and only the classes that subscribe some type of events, will be notified.
This component supports three types of events:
- Button/Key Pressed
- Button/Key Released
- Button/Key On Hold - This hold has a default time of 1 second, you can change it.
GamePad, Keyboard and Mouse are supported.
Analog controllers, like thumbsticks and triggers have different types of events. For each new value, a new event is triggered. So when you move your thumbstick, several events are raised.
You can improve everything and extend this component, if you do it, send it to our email, please! ;)
EDIT:
New Version Released -> Change Log:
---
Version 1.2 - 05 July 2009
FIXED - GamePad negative values don't generate events
FIXED - XBOX 360 don't copile
ADDED - XBOX360 Solution
---
Version 1.1.2 - 04 April 2009
FIXED - NullPointerException
---
Version 1.1 - 03 April 2009
FIXED - Bug in detecting gamepad release buttons event
CHANGED - Now Key/Button Pressed event, is continuously raised while key/button is down.
---
As you must know, the input system in XNA GS is based on IF statements. This is simple but when your game/project grows, it turns the source chaotic and maybe for each frame you may need to test the same key/button several times in different objects.
So, we made a very useful component to solve this problem. Whis this you can separate input code from update code and only the classes that subscribe some type of events, will be notified.
This component supports three types of events:
- Button/Key Pressed
- Button/Key Released
- Button/Key On Hold - This hold has a default time of 1 second, you can change it.
GamePad, Keyboard and Mouse are supported.
Analog controllers, like thumbsticks and triggers have different types of events. For each new value, a new event is triggered. So when you move your thumbstick, several events are raised.
You can improve everything and extend this component, if you do it, send it to our email, please! ;)
EDIT:
New Version Released -> Change Log:
---
Version 1.2 - 05 July 2009
FIXED - GamePad negative values don't generate events
FIXED - XBOX 360 don't copile
ADDED - XBOX360 Solution
---
Version 1.1.2 - 04 April 2009
FIXED - NullPointerException
---
Version 1.1 - 03 April 2009
FIXED - Bug in detecting gamepad release buttons event
CHANGED - Now Key/Button Pressed event, is continuously raised while key/button is down.
---
3 comments:
Are you offering this example as open source by chance?
Yes, you're free to use and modify the code we posted. If you happen to improve something please send it to us! ;)
Emensuits is the new but top seller web site in terms of Suit supply.For example zoot suit and all kinds of suit.
Post a Comment