Menu

Alt-tab cursor not working

2018-06-11
2018-06-14
  • Vincent Sylvester

    Lionhead Studio The Movies running in windowed mode loses the cursor input on alt-tab task switch. I tried the Tweaks DisableAltTab and MouseMoveByEvent, Hook dinput, Cursor Clipper ON.

    I cannot seem to get the cursor to fetch again when switching back to the game, I think the game uses a non-standard input method because the cursor is also much faster than on the rest of the computer.

     
  • gho

    gho - 2018-06-11

    That sounds interesting (and trouble-making too, as input methods almost always are).
    I'll need some time to replicate the testbed, but I'm on it ...

     
  • Vincent Sylvester

    If I can provide any additional information or logs please let me know :)

     
  • gho

    gho - 2018-06-11

    Uhm ... the good news is that the game demo (approx 500 MB) suffers the very same problems, it's some bandwidth and HD space saved. The bad news is that the game is really odd, but with Peter Moulineux I may add this is no surprise.

     
  • gho

    gho - 2018-06-11

    There's an interesting log:

    SetCooperativeLevel(I): did=44a605c(Mouse) hwnd=0 flags=5(DISCL_EXCLUSIVE+FOREGROUND)
    SetCooperativeLevel(I) ERROR: err=80070006(unknown)
    

    Under these circumstances, DxWnd would replace the 0 window handle by the game window handle and also the flags would be set to DISCL_NONEXCLUSIVE | DISCL_FOREGROUND, but despite this strangely SetCooperativeLevel returns an error code, 80070006 should mean a bad window handle.
    I think we have to eliminate this error condition ....

    update

    Likely, a good guess: adding some log traces, here is what happens:

    SetCooperativeLevel(I): did=12f16a4(Mouse) hwnd=0 flags=5(DISCL_EXCLUSIVE+FOREGROUND)
    SetCooperativeLevel(I): replace hwnd=0->0
    SetCooperativeLevel(I): replace flags=DISCL_NONEXCLUSIVE | DISCL_FOREGROUND
    SetCooperativeLevel(I) ERROR: err=80070006(unknown)
    

    DxWnd tries to remap the 0 window handle to the main window handle, but this is not defined yet (still 0!) so the cooperative level can't be set.

    update

    I think I got the problem: the game sets a directinput8 cooperative level BEFORE creating the game window, so DxWnd can't properly initialize the directinput8 session as required for a window mode. It should be necessary some sort of delayed operation, DxWnd should try the SetCooperativeLevel operation again as soon as the window is built ....

     

    Last edit: gho 2018-06-11
  • Vincent Sylvester

    That seems consistent with what I experience. I have tried messing around with the window and found that because minimizing and maximizing causes the window contents to not render, once I force the task switch it goes to it's original resolution and into the corner of my screen, then suddenly the mouse starts working again as soon as I interrupt the the process to restore the contents of the window.

    Certainly an odd game this, it will not, no matter what, run at higher resolutions, just ends up scaling itself along the max-height. I can't seem to find any config file either so it must be saving all that to registry. Not the most future-proof game design and it's not that old a game.

    Anyways thanks for spending this much effort on this, I really appreciate it! Hopefully this will also benefit other games with similar issues :)

     
  • gho

    gho - 2018-06-12

    This game is a real pain.
    With some tricks I managed to perform the initialization SetCooperativeLevel processing later when the window is built. In effect, the logs show that the mouse input is recovered (re - acquired) and succesfully read, but the game video is blocked and shows no progress of any sort.
    It looks as if the game was programmed to detect a focus lost event and reacts very badly at it.
    Fortunately, there are not so many "other games with similar issues" around!
    I desperately need some good idea.

     
  • Vincent Sylvester

    I wonder if there would be a way to surpress the focus loss and effectively "double" the cursor so that while moving around elsewhere it would still keep moving the cursor in the game. Of course that would be a bit annoying since you could accidentally click stuff, but at least it would not brick the game. Could always test to see if during that time the clicks would be surpressed to remove any potential clicking on stuff too.

    It generally behaves incredibly badly to focus loss or tampering of any kind. I been trying all morning to figure out how I could force resolution since there is no UI scaling, but it is almost like it is hardcoded to just not account for any of it, almost like a console port or something.

    Other than trying a different window mode to trick it into thinking it is still running fullscreen, which seems to react to focus loss and regain properly I don't really know what else to fiddle with. I even tried another app to force windowed, but I never got that to render the game at all. Most stubborn game I have come across heh

     
  • gho

    gho - 2018-06-12

    To avoid all this trouble, it is necessary that the game never knows it's been left apart, in the main window message loop it is necessary to bypass the WM_ACTIVATE / WM_NCACTIVATE window messages when the parameter tells the window is OFF.
    Using this trick, combined with some useful DirectInputDevice session recovery, the game is working almost properly, the only drawback the fact that it will never pause itself and will always believe to be top front.
    Now I have to recover all damages I made in my experimental code and make sure that when the focus is assigned to other windows the cursor will be detached and made visible again, but we're getting closer ....

    uhm, no, false track, this behavior is identical to "Do not notify on task switch".... mumble ....
    The difference is made also by the "Compat. / Win insulation" flag: this flag returns the current window as currently active window (using the system call GetForegroundWindow), no matter if that is true or not. Apparently, the game (or maybe dinput8) is using this way to detect when to detach the mouse and show the cursor.

     

    Last edit: gho 2018-06-12
  • gho

    gho - 2018-06-14

    I'm getting closer ....

    update
    I got it.
    You can't get everything, the game is very picky and doesn't like to lose control, so I had to set the "Do not notify on task switch" and "Compact / Win insulation" to let it believe it never loses focus.
    This way, the game window never gets minimized, but the official DxWnd builds can't manage some tricky situations, so I had to patch the source code here and there, the final result being something that works as a proof of concept, but I will never release it before polishing it up carefully!
    So, enjoy the attached beta release with included export file: I'm not sure you could use it on any other game or that "The Movies" will keep working after changing some other flag, but it should demonstrate that we can manage this situation.
    A polished official release will follow.
    P.s. I'm about to leave to 1 week of vacation, so expect no further news for a while!

     

    Last edit: gho 2018-06-14
  • gho

    gho - 2018-06-14

    This was a surprise! After so many attempts and patches, I started again from the blank sheet of last official release with the intent to apply each single necessary patch to get the game working, but I discovered that the old release was perfectly able to manage the game if fed with the proper configuration!
    So, this is good news: non need to mess with your DxWnd release or wait a next one, you should be able to run the game by simply using the attached export file.
    It was tested with v2.04.79 and the game demo, but I hope that the demo and the full game are not too different and, updating window coordinates, game path and title, this configuration should meet your needs.
    Just remember that the configuration prevents the game to know that it lost focus, so if you're going to alt-tab to other programs, life on the game will continue ...
    Please, let me know how it works (and possibly post here the exported file for the full game).

     

    Last edit: gho 2018-06-14
  • Vincent Sylvester

    This is great news! Yes indeed it does appear that when going back to the game it does regain mouse control just fine. Just getting out is a bit weird. It wants a window right ontop of it to click on to fully release the cursor, but then stays within the designated window of the game (I have multiple screens) so I can only interact with windows that are right ontop of the game. The workaround for that seems to be ctrl-alt-del, which fully releases the cursor and I can interact with other windows on other screens(technically all one desktop in surround). This is not real issue though, because afterwards returning to the game still works properly!

    Thank you so much for the effort, I never expected to even get a response, certainly not one with this much effort behind it. Thank you!

     
    • gho

      gho - 2018-06-14

      Oh, this is weird again.
      I guarantee that on my Win7 and the game demo the trick works better, when you press Alt-Tab the original cursor clipper area is cleared at once. The behavior you are noticing corresponds pretty much to an earlier test, but it seemed to work now. It would interesting to know whether that depends on which one of these:

      • using the demo vs. full game
      • the different OS (maybe Wint vs. Win10)
      • a different configuration

      So, if you touched no flags from my last exported file, you could help me by downloading the game demo (it is 285 MB that you can easily find on FilePlanet or other sites, not too a heavy download on an ADSL connection) and testing whether it behaves in the same way as the full game or better.

      P.s. do NOT use the experimental release I sent you in the rar archive! If you replaced the dxwnd.dll file, restore the official release.

      update

      Or, since I have a suspect on the possible cause of this problem (that is the DxWnd clipper ON flag!), you may try this new experimental release that simply suppresses the forcing of the cursor clipper region when the target is not the foreground window.
      In any case, no worry: when I'll be back from my vacation I'll test the full game too.

       

      Last edit: gho 2018-06-14
  • Vincent Sylvester

    I just tested that dll and it indeed now performs like any other window; I can alt-tab no problem, the cursor shows and when I click the game again it fetches the cursor, it does not appear behind the game or can be moved outside. Just as it should be. I am really grateful for all the work you have put into this for me, the game is one of my all-time favorites and being able to play it again properly and even show it to the world(kinda planning on a video series about why I think it deserves a sequel) is great. Thank you so much and have a great vacation!

     

Log in to post a comment.