Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: Creating InputManager fails  (Read 892 times)

big_o

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 3
    • View Profile
Creating InputManager fails
« on: March 10, 2007, 01:37:27 PM »

I'm making some progress porting my game to eihort, but switching input systems is causing some stress.

Here is what I have now:
Code: [Select]

InputManager::InputManager(Ogre::RenderWindow* window)
{
OIS::ParamList pl;
pl.insert(OIS::ParamList::value_type("WINDOW", window->getName()));

    //////Fails here/////
inputManager = OIS::InputManager::createInputSystem( pl );
    //////Fails here/////
mouse = static_cast<OIS::Mouse*>(inputManager->createInputObject( OIS::OISMouse, true ));
keyboard = static_cast<OIS::Keyboard*>(inputManager->createInputObject( OIS::OISKeyboard, true));

const OIS::MouseState &ms = mouse->getMouseState();
ms.width = window->getWidth();
ms.height = window->getHeight();
}

My input handling class was named Inputmanager before I started porting and haven't yet had a chance to change it.

I have checked the window's name and it does in fact exist.

I create it here:
Code: [Select]

bool GameManager::configure(void)
{
    if (!mRoot->showConfigDialog())                                                                           // show config dialog.
    {
        return false;
    }

    mRenderWindow = mRoot->initialise(true);                                                         // initialise and create a default rendering window

    mInputManager = new InputManager(mRenderWindow);
    mInputManager->getMouse()->setEventCallback(this);
    mInputManager->getKeyboard()->setEventCallback(this);
    WindowEventUtilities::addWindowEventListener(mRenderWindow, this);

    ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    return true;
}


Don't know if this would make a difference, but my GameManager class is derived from FrameListener, WindowsEventListener, and the OIS mouse and key listeners.

The code is a mix of basic tutorial 5 and the practical application code so I may have mixed something up.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Creating InputManager fails
« Reply #1 on: March 10, 2007, 01:41:44 PM »

You need to be passing in the Window handle, not the window name ;)

You can get that from Ogre using the
size_t handle;
mWindow->getCustomAttribute("WINDOW", &handle);
iirc. You can look at the Eihort Ogre demos.

HTH
Logged

big_o

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 3
    • View Profile
Creating InputManager fails
« Reply #2 on: March 10, 2007, 03:57:20 PM »

That fixed the problem! :)

I'm getting an error on shut down, and a there are a few more sneaking around, but I can track them down myself.

I noticed in the demos that they were using a hwnd instead of the windows name, but I didn't think much of it.  I probably should have looked a little deeper. :oops:
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Creating InputManager fails
« Reply #3 on: March 10, 2007, 08:26:02 PM »

If you have any errors from OIS shutdown, feel free to post them here.

A couple things to note about OIS shutdown. In OIS 1.0 and below, you should always track and destroy the objects you created with OIS (by calling destroyInputObject(object)). And then free the inputmanager by calling destroyInputSystem( ). Now, in OIS 1.1 and above, as long as you call destroyInputSystem( ), it will free any unfreed devices for you :)
Logged

big_o

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 3
    • View Profile
Creating InputManager fails
« Reply #4 on: March 11, 2007, 11:53:56 AM »

The practical application tutorial has the OIS input devices being deleted, not being destroyed with the destroyInputobject method.

I changed the code to use that method and all was well.
Logged