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

I'd like to be able to exit MAME, do the in game menu, pause & reset via my remote control. I think MAME is using DirectInput, because regular entries in the irremote.ini don't work. I've also tried writing some VBScript to call SendKeys, but I can't get that to consistantly work in every game either.

Please lemme know if you've gotten something to work 100%. If you've tried something that didn't work, let me know that too (save me some time).

Posted

With regards to SendKeys and DirectInput apps: One thing I found when adding state save and load support to my MCE remote, is that SendKeys DOES work with DirectInput, but they often "miss" codes because the SendKeys routines send back-to-back "key up" and "key down" scancodes too fast. It took me a while to figure out what was going on.

If you use the Win32 API "KeyboardEvent" call instead of SendKeys, you can send the key down code, wait a little bit, then send the key up code. It will then work reliably with DirectInput.

Posted
With regards to SendKeys and DirectInput apps:  One thing I found when adding state save and load support to my MCE remote, is that SendKeys DOES work with DirectInput, but they often "miss" codes because the SendKeys routines send back-to-back "key up" and "key down" scancodes too fast.  It took me a while to figure out what was going on.

If you use the Win32 API "KeyboardEvent" call instead of SendKeys, you can send the key down code, wait a little bit, then send the key up code.  It will then work reliably with DirectInput.

Thanks for the feedback. This makes perfect sense considering that the scripts (AutoIt or VBS) sometimes worked, sometimes didn't. I think I'll see if I can whip something up in VS.NET this weekend.

Posted

I'm attaching the source to my KeyMonitor program which has a full SendKeys implementation (from CodeGuru). It includes the necessary delay in the KeyUp along with some other fixes to the code posted there. Hope it helps. It monitors for Media Center remote keypresses, but they're generic Windows Extended Media keys, which may work with your remote too. If not you can probably add other sorts of hotkey support to it easily enough. The main loop of the program has all of the ugly "script-ish" logic in it.

KeyMonitor.zip

Posted

SendKeys.cpp works great! There seemed to be some bugs in the special keys lookup, but it had no problems sending input to MAME. As a bonus, I'm now able to fully automate ZSNES as well using the Hauppauge remote, something I always thought would be impossible. It seems to lag a bit in MAME, but thats probably because MAME is sucking the CPU from the IR application.

I'm attaching a program (and source) I wrote, called SimKey, which just simulates keystrokes you pass to it. Special commands are enclosed in square brackets, so you can pass arguments from irremote.ini

This is the irremote.ini I use for my Hauppauge remote to control MAME. It should work fine with all models, though you may want to change the layout.

[MAME]
MENU={run(C:\EMU\SimKey.exe "[TAB]")}
BACK={run(C:\EMU\SimKey.exe "[ESCAPE]")}
GRNPOWER={run(C:\EMU\SimKey.exe "[ESCAPE]")}
1={run(C:\EMU\SimKey.exe "1")}
2={run(C:\EMU\SimKey.exe "2")}
3={run(C:\EMU\SimKey.exe "3")}
4={run(C:\EMU\SimKey.exe "4")}
5={run(C:\EMU\SimKey.exe "5")}
6={run(C:\EMU\SimKey.exe "6")}
7={run(C:\EMU\SimKey.exe "7")}
8={run(C:\EMU\SimKey.exe "8")}
9={run(C:\EMU\SimKey.exe "9")}
0={run(C:\EMU\SimKey.exe "0")}
RED={run(C:\EMU\SimKey.exe "5")}
GREEN={run(C:\EMU\SimKey.exe "6")}
YELLOW={run(C:\EMU\SimKey.exe "7")}
BLUE={run(C:\EMU\SimKey.exe "8")}
CHNLUP={run(C:\EMU\SimKey.exe "[UP]")}
CHNLDOWN={run(C:\EMU\SimKey.exe "[DOWN]")}
VOLUP={run(C:\EMU\SimKey.exe "[RIGHT]")}
VOLDOWN={run(C:\EMU\SimKey.exe "[LEFT]")}
OK={run(C:\EMU\SimKey.exe "[ENTER]")}
PAUSE={run(C:\EMU\SimKey.exe "p")}
STOP={run(C:\EMU\SimKey.exe "[F3]")}

SimKey.zip

Posted

Heh, ZSnes is exactly what I used to debug and investigate the problem with the original SendKeys routines not working. It doesn't surprise me that you found more bugs - there were some pretty big ones in the original code. In any event, I'm glad it was useful to you!

-- Rob

Posted

Wow, this looks really promising. I have been wanting to pause/freeze/load my games with the remote for quite some time, but with limited success. I'll rework my irremote.ini sometime this week and give this a shot.

  • 2 weeks later...
  • 2 years later...
Posted

Sorry to dredge up this old post, but I am having problems getting keystrokes to MAME. I have tried SendKeys, SendInput, and keybd_event. Each of those works perfectly in windows apps like Notepad, but MAME does not respond at all. Any ideas? I must be missing something obvious. Any hints on getting MAME to programmatically accept a keystroke would be appreciated.

Posted
Sorry to dredge up this old post, but I am having problems getting keystrokes to MAME. I have tried SendKeys, SendInput, and keybd_event. Each of those works perfectly in windows apps like Notepad, but MAME does not respond at all. Any ideas? I must be missing something obvious. Any hints on getting MAME to programmatically accept a keystroke would be appreciated.

bring up mame...press tab....goto input settings..ui controls.. press enter...press key you want to use for that function.

Posted
Sorry to dredge up this old post, but I am having problems getting keystrokes to MAME. I have tried SendKeys, SendInput, and keybd_event. Each of those works perfectly in windows apps like Notepad, but MAME does not respond at all. Any ideas? I must be missing something obvious. Any hints on getting MAME to programmatically accept a keystroke would be appreciated.

bring up mame...press tab....goto input settings..ui controls.. press enter...press key you want to use for that function.

Posted

See if an older mame build works...eg 116

Mame has recently RE-works its input system to allow multilpe keyboards/inputdevices

I suspect the problem lies there...

Thank you so much for the clairification. It makes me helping so much easyer

Posted
See if an older mame build works...eg 116

Mame has recently RE-works its input system to allow multilpe keyboards/inputdevices

I suspect the problem lies there...

Thank you so much for the clairification. It makes me helping so much easyer

So far I've tried 0.62 and 0.114 with no luck. According to the Mamedevs, it sounds like I need to look into DirectInput/RawInput to accomplish this now. :(

Posted
So far I've tried 0.62 and 0.114 with no luck. According to the Mamedevs, it sounds like I need to look into DirectInput/RawInput to accomplish this now. :(

Have you tried Autohotkey??!?

I works very well I use it all the time to send and replace keystrokes.

  • 1 year later...
Posted
SendKeys.cpp works great!

I'm attaching a program (and source) I wrote, called SimKey, which just simulates keystrokes you pass to it. Special commands are enclosed in square brackets, so you can pass arguments from irremote.ini

This is the irremote.ini I use for my Hauppauge remote to control MAME. It should work fine with all models, though you may want to change the layout.

I'm using this with zSnes right now (will be working with other emulators soon). How would I do a two key combo? Like Alt-F4?

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