def __init__(self, app, hnd): ois.KeyListener.__init__(self) ois.MouseListener.__init__(self) self.app = app self.input_mgr = ois.createPythonInputSystem(hnd) # Setup Unbuffered Keyboard and Buffered Mouse Input self.keyboard = \ self.input_mgr.createInputObjectKeyboard(ois.OISKeyboard,True) self.keyboard.setEventCallback(self)
def _setupInput(self): # ignore buffered input # FIXME: This should be fixed in C++ propbably import platform int64 = False for bit in platform.architecture(): if '64' in bit: int64 = True if int64: windowHnd = self.renderWindow.getCustomAttributeUnsignedLong("WINDOW") else: windowHnd = self.renderWindow.getCustomAttributeInt("WINDOW") # # Here is where we create the OIS input system using a helper function that takes python list of tuples # t= self._inputSystemParameters() params = [("WINDOW",str(windowHnd))] params.extend(t) self.InputManager = OIS.createPythonInputSystem( params ) # # an alternate way is to use a multimap which is exposed in ogre # # pl = ogre.SettingsMultiMap() # windowHndStr = str(windowHnd) # pl.insert("WINDOW", windowHndStr) # for v in self._inputSystemParameters(): # pl.insert(v[0],v[1]) # im = OIS.InputManager.createInputSystem( pl ) #Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse) self.Keyboard = self.InputManager.createInputObjectKeyboard( OIS.OISKeyboard, self.bufferedKeys ) self.Mouse = self.InputManager.createInputObjectMouse( OIS.OISMouse, self.bufferedMouse ) try: self.Joy = self.InputManager.createInputObjectJoyStick( OIS.OISJoyStick, self.bufferedJoy ) except: self.Joy = False # #Set initial mouse clipping size self.windowResized(self.renderWindow) #Register as a Window listener ogre.WindowEventUtilities.addWindowEventListener(self.renderWindow, self);