Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: No input focus in full-screen Ogre  (Read 1204 times)

pianoman

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 5
    • View Profile
No input focus in full-screen Ogre
« on: January 11, 2010, 06:29:28 PM »

Hello,

I'm having a problem with my Ogre/OIS/CEGUI app SOMETIMES not having the input focus from OIS. That is, no keyboard or mouse changes are received by the program when i move the mouse and press keys. It appears to happen in full-screen mode, but not in windowed mode. Apparently window focus is being lost somehow? I've tried to find a way that consistently reproduces the problem, but with no avail; sometimes it happens and sometimes it doesn't. I've had this problem for a long time now :(

The closest problem I found in the OIS forums was the same type of problem with Ogre/OIS on Mac OS X, with only a strange hack as a 'solution'.

Thanks in advance.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: No input focus in full-screen Ogre
« Reply #1 on: January 11, 2010, 07:02:09 PM »

Is this on Mac OSX? If so, I think you will need to read that strange hack/Ogre topic on the matter. I haven't had much time to try to duplicate this.
Logged

pianoman

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 5
    • View Profile
Re: No input focus in full-screen Ogre
« Reply #2 on: January 11, 2010, 07:06:00 PM »

No, I'm on Windows (Vista). Forgot to mention that.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: No input focus in full-screen Ogre
« Reply #3 on: January 14, 2010, 07:24:59 PM »

I wonder if you have some program in the back ground stealing focus... Are you running the standard Ogre loop or your own? If your own, make sure you are processing windows messages.
Logged

pianoman

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 5
    • View Profile
Re: No input focus in full-screen Ogre
« Reply #4 on: January 19, 2010, 08:39:11 PM »

It does seem like some other window is stealing focus. But even when I call Win32's SetFocus(hwnd) every frame, I still have the problem (but only sometimes as usual).

When it happens, the program starts out with no input available, then when you alt+tab out and back in, input is available; but input is never lost if it's there initially. It happens in full-screen mode about 1 out of 6 runs, and more often with lower resolutions. It's a very weird, nasty, evasive bug that I hope to squish with utter glee.

Since it happens at program startup, I examined differences between the Ogre demos (whose input always works) and my app, specifically the order of initialization with OIS. Still no long. Thus I continue my long and decreasingly hopeful search for this bug of mine.  :'(
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: No input focus in full-screen Ogre
« Reply #5 on: January 19, 2010, 08:59:33 PM »

* It may have to do with how you are creating your window.. Are you doing it yourself? Or letting OGRE set it up? OIS should try to re-grab input every frame during capture call if it receives an error stating it lost acquisition.
* You can try putting some logging (printf/cout's) to OIS Win32 capture calls to see if they are returning anything odd.
* Are you changing the flags sent to OIS for startup?
* You didn't state if you were running your own message loop or anything.
Logged

pianoman

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 5
    • View Profile
Re: No input focus in full-screen Ogre
« Reply #6 on: January 21, 2010, 05:20:43 PM »

Uhg, that's the 2nd time my post was lost because my "session timed out."

Thanks for your reply, pjcast.

*1. I'm letting Ogre create the window (via Root::initialize())
*2. I'll have to do my own build of OIS instead of using the prebuilt binaries, so that I can set breakpoints, or printfs, inside OIS. I'll do that next...
*3. Which "flags" are you referring to? I send the HWND from Ogre::RenderWindow::getCustomAttribute("WINDOW"...) to InputManager::createInputSystem(). Is that what you mean?
*4. I'm using Ogre's message loop. I for the most part followed the pattern of Ogre's ExampleApplication and ExampleFrameListener framework.

Now I'll do my own OIS build and debug...
Logged

pianoman

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 5
    • View Profile
Re: No input focus in full-screen Ogre
« Reply #7 on: January 23, 2010, 05:37:35 PM »

I debugged into OIS and found that when the problem occurs (no app response to input): DInput doesn't even have any input data for OIS. (Win32Mouse::capture(), entries always == 0 after the mMouse->GetDeviceData call) So it must be something external to OIS (and probably DInput), so I'll try not to bug OIS forums any further on this.

I would think lost window focus as I originally thought, but SetFocus(HWND) every frame doesn't help so I'm at a loss for now. ??? Since it only happens sometimes, there is timing involved, probably between separate processes or threads. If I ever figure it out I'll post the solution here in case someone else has the same problem.
« Last Edit: January 23, 2010, 05:39:07 PM by pianoman »
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: No input focus in full-screen Ogre
« Reply #8 on: January 25, 2010, 09:34:38 PM »

Hmm, I seem to remember somebody having a similar issue in the past. Though, my forum search didn't return any immediate results. I recall somebody was using some kind of tray, control panel item, or service that would periodically grab input. You could look in process explorer to see what processes are running, and/or what you have in your tray/control panel for non-standard items. Turning stuff off while testing might help.

Perhaps trying your app on other computers (XP, Vista, Windows 7) and see if it is only your system.

Anyway, you could try to reproduce this in a very simple Win32 window (ie minus DirectX/OpenGL/Ogre). Just make a similar styled window that Ogre uses to go full screen... And display keyboard/mouse events to a textbox.
Logged