Jump to content

All my products and services are free. All my costs are met by donations I receive from my users. If you enjoy using any of my products, please donate to support me. My bare hosting costs are currently not met so please consider donating by either clicking this text or the Patreon link on the right.

Patreon

Recommended Posts

Posted

Hi Tom, I'm working on a little program that shows the CP during Mame, then I realise how easy this would be to put into GameEx. Since you already monitor DirectInput keypresses in the background, I was thinking you could grab the ROM name from the Mame process and display the CP.

I would expect the GameEx method to work like this.

- You launch Mame from GameEx

- The usual background process you have runs in the background monitoring DirectInput keypress.

- User presses 'p' (pause) key or some other assigned key

- GameEx enumerates windows searching for "MAME:" in the titlebar. If it finds it, it extracts the ROM name from between the square brackets and minimises Mame. Actually this step may not be necessary since you could pass on the ROM name to the background process including cloneof name after the user selects it from the list.

- GameEx displays it's standard CP display using control.ini and the ROM name extracted from the titlebar (or sent from the FE)

- User presses 'p' again which closes the CP viewer, maximises Mame again

Here is a link to my new topic which contains some source using a global keyboard hook.

http://forum.arcadecontrols.com/index.php?topic=48395.0

EDIT: Fixed link

Posted
Hi Tom, I'm working on a little program that shows the CP during Mame, then I realise how easy this would be to put into GameEx. Since you already monitor DirectInput keypresses in the background, I was thinking you could grab the ROM name from the Mame process and display the CP.

I would expect the GameEx method to work like this.

- You launch Mame from GameEx

- The usual background process you have runs in the background monitoring DirectInput keypress.

- User presses 'p' (pause) key or some other assigned key

- GameEx enumerates windows searching for "MAME:" in the titlebar. If it finds it, it extracts the ROM name from between the square brackets and minimises Mame. Actually this step may not be necessary since you could pass on the ROM name to the background process including cloneof name after the user selects it from the list.

- GameEx displays it's standard CP display using control.ini and the ROM name extracted from the titlebar (or sent from the FE)

- User presses 'p' again which closes the CP viewer, maximises Mame again

Here is a link to my new topic which contains some source using a global keyboard hook.

http://forum.arcadecontrols.com/index.php?topic=48395.0

EDIT: Fixed link

Great idea Headkaze. I had a go at implementing this yesterday and had some success. I've got GameEx displaying the control panel for the selected game after pressing a key when MAME is running. Only thing I have not managed to do yet, is get focus back to MAME. Any ideas or code how to do that HeadKaze?

Posted

Great to hear you've nearly got this feature in there!

Try some of these methods..

// Launch the CP Viewer

// Minimise Mame and hide the window
CloseWindow(hWndMame); // Minimise
ShowWindow(hWndMame, SW_HIDE); // Hide window

// Bring CP Viewer to front and top of z-order
SetForegroundWindow(hWndCP);
BringWindowToTop(hWndCP);

// Wait for user to exit CP Viewer

// Close CP Viewer

// Show Mame again
ShowWindow(hWndMame, SW_SHOWMAXIMIZED); // Show Maximised
SetForegroundWindow(hWndMame); // Set foreground
BringWindowToTop(hWndMame); // Top of z-order

Posted

I was thinking that perhaps you don't have a handle to the Mame window. In this case, I do a search for "MAME:" in the titlebar using EnumWindows(). The following code does this.

BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
   char titlebar[1024] = "";
   int length = GetWindowTextLength(hWnd);
   GetWindowText(hWnd, titlebar, length + 1);

   if (strncmp(titlebar, "MAME:", 5) == 0)
   {
       hWndMame = hWnd;
       return(FALSE);
   }
   return(TRUE);
}

BOOL GetMamehWnd()
{
   BOOL brc;
   brc = EnumWindows( EnumWindowsProc, 0);

   if(brc) return false;

   // hWndMame now has the handle to the Mame window
   // You can now use the API functions in my previous post
   // to bring the Mame window back to focus
}

Posted
I was thinking that perhaps you don't have a handle to the Mame window. In this case, I do a search for "MAME:" in the titlebar using EnumWindows(). The following code does this.

Yep, that was it, seems to be looking good, might even see this released Today B)

Posted
You da man :)

Only concern, is that you need a keyboard attached to do this.

Not sure what sort of key combo to use for cab and remotes, if any. Thought I'd use '9' for remote.

Thoughts anyone?

Posted

Have no idea. What do remote users use to pause Mame? Can they pause Mame? You could just make the actual key code an option in GameEx settings I guess and let the user decide.

Posted
Hows it going with this Tom? Love to see this idea in action! :)

Should be out Today. It seems to be working perfectly now after a fair bit of work. I just need to make the key programmable and that's it. It has to be a key not used by MAME because of the way I capture input, so P won't work, but anything else not used does.

Posted

Are you sure 'p' won't work.. because thats the only key I could use anyway. Bummer. Well.. in my experiments with pressing 'p'.. then capturing that input, I would minimise Mame and bring up another window.. when I presses 'p' again and closed it, it would show Mame again but in the unpaused state exactly where I left it paused. Perhaps you could have it use 'p', then bring up your CP viewer, then when you hit another key, show Mame. If you have to press 'p' again, then ignore it in your keypress monitoring process so 'p' will unpause mame. Dunno, I will just be really spewing if you have to assign a key that Mame dosn't use because that would mean I couldn't use it from my control panel! Please give it another try! :)

Posted

headkaze: Can't you just use a combination of keys?

Example: When pressing both start buttons, the controls for the game comes up.

If Tom's controller app can't be configured for combinations, perhaps you could remap some MAME function (as MAME supports combinations) and use this "freed" button to launch the controller app?

Emph

Posted
headkaze: Can't you just use a combination of keys?

Example: When pressing both start buttons, the controls for the game comes up.

If Tom's controller app can't be configured for combinations, perhaps you could remap some MAME function (as MAME supports combinations) and use this "freed" button to launch the controller app?

Emph

Yes that would work. My code does pause and resume MAME, so if you say MAP the P key in MAME itself to something else, then GameEx could succsesfully monitor the P Key. GameEx can monitor keys used by MAME but you have to hold the key down, as MAME captures the key while GameEx is sleeping (CPU Sleep).

Would that work for you??

Posted

Hmmm now I'm thinking a global hook is better in this circumstance.. when you do a global hook you don't need to Sleep().. CoinDrop works that way... it always processes key input with no sleeping and it dosn't drag CPU.. Perhaps I can modify the global key hook for this? Let me know Tom and I'll be more than happy to do that.

Does Mame still monitor key input when you minimise it? In my experience it dosn't.. look at my API code before and try that.. minimised I don't think Mame registers key input.. but thats just a guess.. my experiments comfirm this although I'm using a global key hook so I don't sleep.

Posted
Hmmm now I'm thinking a global hook is better in this circumstance.. when you do a global hook you don't need to Sleep().. CoinDrop works that way... it always processes key input with no sleeping and it dosn't drag CPU.. Perhaps I can modify the global key hook for this? Let me know Tom and I'll be more than happy to do that.

I'm not going to change the way it works any time soon as generally it all works pretty well, and GameEx still needs to sleep during its loop as it does other stuff too. Any simple source code would be helpful for future use though, especially if in c# or vb.net

Thanks.

Tom.

Posted

You say it works well, ok I grant you that, but it should work using any key... if sleeping is causing a problem then your code is flawed simple as that. I am willing to design a DLL that takes away the guess work and makes this work in all circumstance with any key... I believe a way that impliments this feature properlly.. I can access Mame's input and output mechinism and I believe I know how to do this properly.. Lets not say "oh ok, we can't allow this feature because Mame uses these keys so it don't work."... is sounds slack to me, there are better ways to do this.. and it shouldn't be limited... i dont want this feature if it cant use a standard Mame key like pause... no ... ok, if thats the way, lets find a better way to do this.. please, otherwise the feature is useless to me, and i dont want that....

Posted
You say it works well, ok I grant you that, but it should work using any key... if sleeping is causing a problem then your code is flawed simple as that. I am willing to design a DLL that takes away the guess work and makes this work in all circumstance with any key... I believe a way that impliments this feature properlly.. I can access Mame's input and output mechinism and I believe I know how to do this properly.. Lets not say "oh ok, we can't allow this feature because Mame uses these keys so it don't work."... is sounds slack to me, there are better ways to do this.. and it shouldn't be limited... i dont want this feature if it cant use a standard Mame key like pause... no ... ok, if thats the way, lets find a better way to do this.. please, otherwise the feature is useless to me, and i dont want that....

To be more acurate its not a problem with any key, just the pause key, as I cant control the pause and resume correctly, because MAME captures the key at least once first. What I was saying is I am not ready to implement a hook at this particular moment in time, but later does not mean never, it's just not no.1 priority for me right now. Nothing to do with slack at all. Does the project seem like it suffers from slack, only the most updated front end of all time! I'll likely implement a custom control combination to do this, so it will work for all cab users. I for one dont have a button assigned to P on my cab as far as I know. I also really don't understand how it is useless to you. Please explain that in more detail?

Posted

Sorry Tom, I was pissed when I wrote that. It made sense to me at the time, but now I read it again and it seems pretty pushy and arrogant.

What I was trying to say, was that hooking seemed to work well for me with the pause key because it would pause Mame, minimise then when I restored the window it would be unpaused at the exact moment it was paused. It just seemed to work well IMHO. But I understand your reluctance to use hooks, they can be messy and cause crashes, so go with the way you think best. And sorry about my previous post, I really shouldn't visit forums when I'm smashed.

Posted
Sorry Tom, I was pissed when I wrote that. It made sense to me at the time, but now I read it again and it seems pretty pushy and arrogant.

What I was trying to say, was that hooking seemed to work well for me with the pause key because it would pause Mame, minimise then when I restored the window it would be unpaused at the exact moment it was paused. It just seemed to work well IMHO. But I understand your reluctance to use hooks, they can be messy and cause crashes, so go with the way you think best. And sorry about my previous post, I really shouldn't visit forums when I'm smashed.

No worries mate ;)

Guest
This topic is now closed to further replies.
×
×
  • Create New...