Build Your Own Arcade Controls Forum

Front End Support => MaLa Frontend => Topic started by: SGT on October 23, 2009, 11:37:13 pm

Title: Another fix if you are losing focus when starting emulator from a batch file.
Post by: SGT on October 23, 2009, 11:37:13 pm
I have been having a problem that others have reported where after playing a game in Mame or other emulators you have to click with a mouse before the keys/buttons start working in Mala.  Of course Mala is losing the focus.  Some have written scripts to simulate a mouse click and TheShanMan wrote a nice focuslogger plugin that has helped many.

Unfortunately the plugin could not help my problem.  The log would show that Mala had lost the focus and that nothing else had the focus.  It would then report a failed attempt to give Mala the focus.  I thought it may have something to do with the fact that I launch Mame from a batch file.

Launching Mame from a batch file like this results in the problem:
Code: [Select]
mame %1
It is fixed when I use this instead:
Code: [Select]
start /B mame.exe %1
Hopefully this will help others with the same problem.
Title: Re: Another fix if you are losing focus when starting emulator from a batch file.
Post by: loadman on October 24, 2009, 08:30:41 pm
Ahh,  ;D

So the diff is you are launching in the background ehh?

Very Unix like.

If this is a global solution than should I put in the code that all emu's launch this way?  :dunno
Title: Re: Another fix if you are losing focus when starting emulator from a batch file
Post by: SGT on October 25, 2009, 10:42:24 pm
If this is a global solution than should I put in the code that all emu's launch this way?  :dunno

Possibly.  I haven't used Mala to launch mame.exe for a long time since I use the batch file method of combining emulators into one game list.   Just for testing, I changed my executable in Mala from mame.cmd to mame.exe just to see if Mala lost focus with my build.  Indeed it did lose focus after exiting a mame game every time.

I went back to using mame.cmd with the contents of "start /B mame.exe" and no longer had the loss of focus problem within Mala.  It is very repeatable so if you wanted to compile a test Mala.exe  which consists of launching mame.exe in a similar fashion then I can test and tell you if the focus issue goes away.  Just let me know. 

I'm sure it would be great if the need to use scripts to simulate a mouse click could be eliminated.
Title: Re: Another fix if you are losing focus when starting emulator from a batch file.
Post by: loadman on November 14, 2009, 08:34:27 pm
Bugger.

The main issue is I have never had the focus issue, I believe that it exists but hard to fix something I can't see.

If someone can give me a certain recipe that would help
Title: Re: Another fix if you are losing focus when starting emulator from a batch file.
Post by: SGT on November 15, 2009, 05:54:44 pm
Loadman,

I am 99.9999% sure that the loss of focus after playing a game is caused by the option to Reorder Layout after Game Quit.  Perhaps you could look at that subroutine and determine how the Mala window is not regaining the focus.  It is not that something is stealing, it's that nothing has the focus.

I am going to start a new thread on this so you are sure to see it since this specific thread implies  a batch file connection.
Title: Re: Another fix if you are losing focus when starting emulator from a batch file.
Post by: csa3d on November 16, 2009, 12:08:03 am
I've not been able to have any keyboard encoder which uses an .exe to switch keycodes (for various different emulator configs) ever work properly inside Mala and still retain proper focus.  Wonder if this batch file fix instead of calling the encoder .exe directly will do it.  I'll give it a try for sure.  Thanks for the heads up!

-csa
Title: Re: Another fix if you are losing focus when starting emulator from a batch file.
Post by: loadman on November 21, 2009, 04:31:42 pm
I've not been able to have any keyboard encoder which uses an .exe to switch keycodes (for various different emulator configs) ever work properly inside Mala and still retain proper focus.  Wonder if this batch file fix instead of calling the encoder .exe directly will do it.  I'll give it a try for sure.  Thanks for the heads up!

-csa

That would be good to know.