OIS BufferedInput problem

jmtan

14-01-2008 14:31:28

Hi, is anyone using buffered input for OIS in their projects? I saw that the tutorial for buffered input in the wiki is incomplete, does this mean that buffered input has known problems?


class GameListener(ogre.FrameListener, OIS.KeyListener):

def __init__(self, keyboard, window):
ogre.FrameListener.__init__(self)
OIS.KeyListener.__init__(self)
self.keyboard = keyboard
self.keyboard.setBuffered(True)
self.keyboard.setEventCallback(self)
self.renderWindow = window

def keyPressed(self, evt):
print evt
return True

def frameStarted(self, evt):
if self.renderWindow.isClosed():
return False

self.keyboard.capture()
return True


Using the code above, the application starts running, but when I press a key it suddenly gives me an error on "self.keyboard.capture() in frameStarted(), saying "Nonetype object is not callable".

Admittedly, I've not used OIS Bufferedinput in C++, so my usage might be wrong. Can someone shed some light here?

SiWi

14-01-2008 18:16:29

1. There aren´t any known issues with buffered input.
2. Your error means that keyboard is None. If there isn´t any more than this code it means that the keyboard paramter you pass when creating the GameListener is None.
3. I´m going to look into the tutorial and finish it and/or post some example here.

jmtan

15-01-2008 12:26:03

Hi, just to clear things up a little. I've been using the keyboard object for unbuffered input previously in that code segment, so I'm pretty sure it isn't null. I also tried "print self.keyboard" prior to self.keyboard.capture() (the crash point) and it gives me the proper name, OIS.Keyboard or something. Weird.

I think it might be my system (Gutsy) at fault, since I've been having a few troubles in other parts of python-ogre. Thanks for reading my code!

Zyzle

24-02-2008 21:13:15

I had a similar problem to this in my program. fixed it by adding an empty keyReleased method:


def keyReleased(self, evt):
pass



This fixed the problem.

p.s. not sure if this was the right thing to do or not, I'm still learning :oops:

Game_Ender

24-02-2008 21:19:09

I use buffered OIS input with no problems.

jmtan

25-02-2008 16:37:58

Zyzle: That solved my problem! Thank you so much.
Sorry everyone for my ignorance, I didn't know you had to override keyReleased() as well.

Zyzle

26-02-2008 13:41:48

Glad I could help :D