Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: OIS and Activex  (Read 2474 times)

dude3d

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 3
    • View Profile
OIS and Activex
« on: October 27, 2008, 01:43:25 PM »

I am trying to embed Ogre into ActiveX so that Ogre can render scenes inside a browser. I used OIS as the input system for Ogre.

Embedding Ogre with OIS into ActiveX is easy and working very well. Ogre can receive and process mouse and keyboard input. But the problem with OIS is that it requires to acquire the mouse and the keyboard from the top tier window, i.e. the browser window when OIS is initialized. In another word, OIS takes over input from the browser window. While this behavior has no problem with stand alone application, it creates problems for embedded system. If Ogre is embedded inside a HTML pages, other objects, such as HTML URL links and input fields will never get focused and hence there is no way for a user to interact with the HTML page because the mouse cursor can not move out of the embedded Ogre window and the keyboard is also locked to the same Ogre window. Please see the following screen shot. The mouse cursor is trapped inside the red rectangle. The name filed can never get focused.



My question is:

Is there a way to make OIS release the mouse and keyboard when the mouse is rolled out of the embedded Ogre window (outside the red rectangle)?

Thanks a lot.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: OIS and Activex
« Reply #1 on: October 27, 2008, 05:31:30 PM »

You can put OIS directinput mode as NON EXCLUSIVE. Search the forums for the param list you need to send. however, it may be easier to use something like directly processing winproc messages for embedding.
Logged

dude3d

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 3
    • View Profile
Re: OIS and Activex
« Reply #2 on: October 28, 2008, 09:39:06 PM »

Thank you for the quick response. I used the following parameters to set up OIS.

Code: [Select]
pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));

Now the mouse cursor can move out of the embedded Ogre window.
Logged

dude3d

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 3
    • View Profile
Re: OIS and Activex
« Reply #3 on: November 11, 2008, 04:13:00 AM »

Quote
it may be easier to use something like directly processing winproc messages for embedding.

Hi, pjcast,

Can you please shed some light on how to do "directly processing winproc messages for embedding?" I am really new to Ogre and embedding. I googled Ogre Forum and OIS Forum for days but got no useful result.

Thanks a lot.

Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: OIS and Activex
« Reply #4 on: November 11, 2008, 06:11:25 AM »

Well, simply creating your own WinProc, and capturing the WM_MOUSE messages (or whatever they are called) - will allow you to handle any child control or top level control. How you enable the WinProc depends on how you created your window - you should have created it yourself (as opposed to letting Ogre create it), and simply provide the WinProc to it during creation. If you used a wrapper such as MFC, ATL, etc, you will need to google how to specific/overload the WinProc to handle those messages. But, it might be simpler than that, they might already expose an OnMouseMove function.
Logged

lali

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 1
    • View Profile
Re: OIS and Activex
« Reply #5 on: April 20, 2009, 11:20:25 AM »

dude3,

I tried what you have stated works (reply #2) but I get the following exception from OIS:

 Exception in OIS : Win32Keyboard::Win32Keyboard >> aquire error!at ..\src\win32\Win32KeyBoard.cpp:79

when calling :

mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, bufferedKeys ));

(same for mouse)

Any clues ?
Thanks.
Logged

faramir85

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 3
    • View Profile
Re: OIS and Activex
« Reply #6 on: September 15, 2009, 12:25:46 AM »

i have similar problem, everything is ok unless i create OIS::Mouse/Keyboard. i find out the OIS need high level window handle, i get handle like that:

Code: [Select]
IOleInPlaceActiveObjectImpl<CHelloWorldCtl>::GetWindow( &myHwnd )
is that correct?

this is my input init function:

Code: [Select]
void initInput(unsigned int windowHnd)
{
                OIS::ParamList paramList;
std::ostringstream ss;
ss << windowHnd;
paramList.insert(std::make_pair(std::string("WINDOW"), ss.str()));
#if defined(OIS_WIN32_PLATFORM)
paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
#elif defined(OIS_LINUX_PLATFORM)
paramList.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
paramList.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
paramList.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
#endif
_inputMgr = OIS::InputManager::createInputSystem(paramList);

try
{
_mouse = static_cast<OIS::Mouse*>(_inputMgr->createInputObject(OIS::OISMouse, true));

}
catch (const OIS::Exception &e)
        {
MessageBox(0, e.eText, "Error", MB_OK);
            throw Exception(42, e.eText, "Application::setupInputSystem");
        }
}
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: OIS and Activex
« Reply #7 on: September 15, 2009, 06:00:45 PM »

First, make sure the handle you pulled from GetWindow is in fact your parent window. Also, I'm not certain what error you're seeing. If it is a coop error, than either the handle is not top level, or something like this is going on: http://www.wreckedgames.com/forum/index.php/topic,1130.0.html
Logged

faramir85

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 3
    • View Profile
Re: OIS and Activex
« Reply #8 on: September 16, 2009, 01:51:44 AM »

yes, it's coop error, if i do not create any OIS object its all allright, its must be problem with top level handle. How can i check its top level handle or how can i get this handle?
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: OIS and Activex
« Reply #9 on: September 16, 2009, 07:00:19 AM »

You can use Spy++ to see what the Window handle should be.
Logged

faramir85

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 3
    • View Profile
Re: OIS and Activex
« Reply #10 on: September 17, 2009, 12:44:37 PM »

ok i find it, but when i pass top level hwnd to ogre it don't render anything to the IE window (blank page) but ois init is ok. I tried to pass 2 hwnd(top level hwnd and the hwnd that i get by GetWindow function) and then its looks ok but nothing happend when i use mouse/keyboard...

how you get hwnd?
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: OIS and Activex
« Reply #11 on: September 17, 2009, 06:44:58 PM »

I don't really have an answer for you... If you say the window handles each work for OIS and Ogre, but you cannot use both at the same time, I'm not really sure. You may not be able to use OIS in this scenario.
Logged