Now that we know how the FrameListener
works, let's add some input.
We need to include the
OIS
header file to useOIS:
#include "OIS\OIS.h"
Remove all functions from the
FrameListener
and add two private members to store theInputManager
and theKeyboard:
OIS::InputManager* _InputManager; OIS::Keyboard* _Keyboard;
The
FrameListener
needs a pointer to theRenderWindow
to initializeOIS
, so we need a constructor, which takes the window as a parameter:MyFrameListener(Ogre::RenderWindow* win) {
OIS
will be initialized using a list of parameters, we also need a window handle in string form for the parameter list; create the three needed variables to store the data:OIS::ParamList parameters; unsigned int windowHandle = 0; std::ostringstream windowHandleString;
Get the handle of the
RenderWindow
and convert it into a string:win->getCustomAttribute("WINDOW", &windowHandle); windowHandleString << windowHandle;
Add the string containing the window handle...