Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: Suggestion: public access to KeyBuffer  (Read 1542 times)

Bekas

  • Veteran
  • ***
  • Karma: +0/-0
  • Posts: 116
    • View Profile
Suggestion: public access to KeyBuffer
« on: May 03, 2006, 02:28:58 AM »

Public access to KeyBuffer would be useful for wrappers, especially for a .NET wrapper.

Getting into unmanaged context for calling the isKeyDown method is rather expensive (considering that this method is likely to be called multiple times at each frame), while accessing the KeyBuffer array directly (through a managed IsKeyDown method) will incur no performance penalty.

<edit> the method is isKeyDown of course, not isKeyCode </edit>
Logged

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/
Suggestion: public access to KeyBuffer
« Reply #1 on: May 03, 2006, 09:21:53 AM »

You can always alter a local copy for a .net wrapper.  Besides, doesn't .net already have a pretty nice DX interface for input?
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2653
    • View Profile
    • http://www.wreckedgames.com
Suggestion: public access to KeyBuffer
« Reply #2 on: May 03, 2006, 10:02:51 AM »

There is a WIP .Net wrapper (along with a python wrapper) in oisaddons module. I suggest you chekc it out.

It is already possible to get a copy of the keystate, but i admit, doing this every frame is more costly then isKeyDone.. Espcially with it being  virtual.

Perhaps, the keyboard buffer and testing will be moved up in to the Keyboard class next release. As, it is really just a simple array common to all the current implementations. But, being made public, that breaks the rules of encapsulations.. no reason why that member should be public. Plus, the preferred method in my oppinion is to use buffered input in all situations - so you never miss a key, and action mapping can work well.
Logged

Bekas

  • Veteran
  • ***
  • Karma: +0/-0
  • Posts: 116
    • View Profile
Suggestion: public access to KeyBuffer
« Reply #3 on: May 03, 2006, 12:38:39 PM »

Quote from: "pjcast"
But, being made public, that breaks the rules of encapsulations.. no reason why that member should be public.

Yeah, I understand, I wouldn't feel comfortable exposing internal members either.

Right now I want a quick solution for an example-framework-type input system, so I'll go with Axiom's input system. I did notice the .NET addon but, as I already mentioned, unbuffered input is expensive.

I may port OIS over to C++/CLI later on; it should be easy and straightforward (compared to trying to wrap the Ogre mammoth  :wink: )
Logged