What about buffered input?

Please make also event based input option for Mouse and Keyboard.
For example.
1.In Mouse and Keyboard, add EventDelegate like
Mouse.OnMouseEvent, Keyboard.OnKeyEvent

2.We then just do

Mouse.OnMouseEvent+=new MouseEventDelegate(game.OnMouseEvent);

3. OnMouseEvent should look like
OnMouseEvent(object sender,MouseState state,MouseEventArg args)
{
//MouseEventArg tells us what button was pressed,released, wheel moved or
//just x,y change

}

Thanks drEKO



Answer this question

What about buffered input?

  • Venkatroyal

    i understand what a "game loop" is...I am not beginner, I just need this as a OPTION, for more "GUI" oriented games. Gui system is also event driven in games as object oriented programming is and XNA should not be a exception. This addition won't affect performance of others
    , who doesn't need this. I just need function to get buffered input of mouse,keyboard...
    which is nothing new to old DirectX (DirectInput).Then, I can do everything, such as event based input... Similar thing is InputManager from someone on the forum, but buffered based input in DirectInput was/is better..








  • Mikael Håkansson

    I use EventBased input for handling typing. If a KeyDown event is fired I simply add it to the end of the text string. My Event Based Input Service (Ebi) handled KeyDowns and KeyUps for me automatically. To create a buffered input you would simply have to add an array of KeyDowns to be fired. I haven't run into a case where the application is too slow to register input though.

  • RainerK

    Is there any support for buffered input in XNA I've looked through the docs a bit, but haven't found anything. If there isn't, what's a common way to handle typing


  • BBesser

    In the property grid at the top you'll see a lightning bolt. Click that to switch to "event" view. You can then easily hook up events as you've suggested.

  • Sandy Place

     drEKO wrote:
    i understand what a "game loop" is...I am not beginner, I just need this as a OPTION, for more "GUI" oriented games.

    Well, if you are experienced - write your own, it wouldn't be hard!

    Perhaps you could write a component to do that  I would rather Microsoft supply us with the raw access to the machine, and we all build upon that in the way that suits us individually, even if that is just borrowing someone elses component.

    Andy.

     

    PS: Anyhow, this is the wrong place to be asking for enhancements. Look here.


  • Sam_res03

    Here's a first pass. It wound up far more complicated than I initially expected (and I haven't even looked at the keyboard stuff yet). It's also my first attempt at anything in C#, so I imagine there are better ways to do some of this stuff. I'd love to get some feedback, or better yet, take it, clean it up, and post a better version. I do wish Microsoft would set up a better distribution system.

    http://seattle.servegame.org/EventSystem.cs

    Drop it in your game's designer mode pane, then set the following properties (I haven't figured out how to make the comments show up in the properties window yet):

    • DispatchMode: You can either wait for XNA's Update to dispatch the events (OnUpdate), or have it spawn off a separate thread that dispatches the events asap (Immediate). If you're using Immediate, you need to remember these events are coming from a separate thread and all that entails (e.g. locking your game state, etc.).
    • UpdateMode: If using the OnUpdate DispatchMode, you'll likely just want to set this to None. EventSystem provides an UpdateEvent that can be dispatched along with the input events (so you don't have to worry about it coming from a separate thread). This doesn't buy you much if you're already dispatching via the main XNA thread. However, if you're using Immediate DispatchMode you'll want to set this to either Internal or External. Internal spawns off a separate thread that queues up an update event as specified (see UpdateMS). External queues up an update event each time the component's Update is called (which is controlled by the Game's properties (IsFixedTimeStep, etc.).
    • UpdateMS: The number of milliseconds between updates (when UpdateMode is set to Internal).

    I was hoping there was cool support for hooking up events via the properties pane, but I guess that's asking for too much. Instead, you'll have to hook up events in code as follows:

    private void OnAButtonOn(object sender, EventArgs e){ ... }

    eventSystem.controllers[0].AButtonOn += new EventHandler(OnAButtonOn);


  • NateF

    Is it just me, or would that flood the heap with garbage every time the mouse is moved Anyhow, I think this is confusing the event driven programming model from WinForms with the loop driven model that games use.

    drEKO, it might help you along if you understand what a game loop is and how it relates to input, game state update and rendering.

    Andy.


  • What about buffered input?