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. Thank you for your support. Tom Speirs

Patreon

XPadder MAME mod


bkenobi

Recommended Posts

I was viewing the XPadder forums a while back and found a post where Jonathan (the author of the program) discussed how he modified the MAME source code to once again work with XPadder. This mod would make it possible to use AHK etc once again too. Here's what he wrote (I would link the post, but the forum is no longer available):

Converting MAME to handle Xpadder is very easy (if you know how to compile MAME - see the MAME site for technical info) so here's how I did it. Download the source files and edit src/osd/windows/input.c

Search for:

// initialize RawInput and DirectInput (RawInput first so we can fall back)

rawinput_init(machine);

dinput_init(machine);

win32_init(machine);

and remove the line: rawinput_init(machine);

That's it! Now MAME will always fallback to DirectInput (the original keyboard reading method). When you compile the new source it will throw up some errors of procedures or values that are not used. Just delete them from input.c and compile again. Do this a few times until the compilation manages to complete.

So the question is, is this a good idea or are there potential negative ramifications from disabling the raw input system? This is a really simple change and would allow for a lot of control to be given back to the user, but if it will screw things up in a big way then it's not worth it.

Comments?

  • Like 1
Link to comment
Share on other sites

I was viewing the XPadder forums a while back and found a post where Jonathan (the author of the program) discussed how he modified the MAME source code to once again work with XPadder. This mod would make it possible to use AHK etc once again too. Here's what he wrote (I would link the post, but the forum is no longer available):

So the question is, is this a good idea or are there potential negative ramifications from disabling the raw input system? This is a really simple change and would allow for a lot of control to be given back to the user, but if it will screw things up in a big way then it's not worth it.

Comments?

Very good find. I am sure some will find this usefull.

Link to comment
Share on other sites

I read the same thing a while ago but didn't realise it was such a simple change.

I was considering adding my Raw Input injection system into the XLaunch wrapper I'm working on but I've never thought people needed to send keys to Mame anymore. I mean in most cases you can just reconfigure keys in Mame's config. Is there really any usefulness to injecting keys into Mame? Is it for some special key remapping I haven't thought of or for things like dropping in credits and things like that?

Link to comment
Share on other sites

I think one thing would be to allow for more dynamic controls remapping. If you wanted to have controls set up a certain way for a set of games, it would be easy to put together a list and call xpadder with that config. I don't think it's as useful now that Tempest's control remapping script is available. It's a bit of work, but probably less work than putting a script together to change xpadder profiles.

I think the more useful thing is being able to send commands from other programs that aren't in raw format. For instance, I haven't tried it yet but it might make using WinGun with the most current version of MAME possible again. The guns track, but they don't fire. I suspect it's the raw system that might be partially to blame for this.

Anyway, just thought I would throw the info out there since it's been lost from the other forum.

Link to comment
Share on other sites

  • 5 weeks later...

EDIT : THIS DOES NOT WORK!

Its even easier than removing the new input system..

Just do this

// initialize RawInput and DirectInput (RawInput first so we can fall back)
rawinput_init(machine);
dinput_init(machine);
win32_init(machine);

To

// initialize RawInput and DirectInput (DirectInput first so we can fall back)
dinput_init(machine);
rawinput_init(machine);
win32_init(machine);

Now you dont have any ramifications with removing the other input system...

Boo Ya.. Now My AHK scripts can send keys to mame.

Woo Hoo

Link to comment
Share on other sites

Its even easier than removing the new input system..

Just do this

// initialize RawInput and DirectInput (RawInput first so we can fall back)
rawinput_init(machine);
dinput_init(machine);
win32_init(machine);

To

// initialize RawInput and DirectInput (DirectInput first so we can fall back)
dinput_init(machine);
rawinput_init(machine);
win32_init(machine);

Now you dont have any ramifications with removing the other input system...

Boo Ya.. Now My AHK scripts can send keys to mame.

Woo Hoo

Nice! Maybe someone can create a patch that will take care of it so you can apply it when compiling instead of manually editing the code?

Link to comment
Share on other sites

Nice catch!

So, the question is....what are the ramifications to doing this? What do you lose by turning off the raw input system. Or, what do you currently gain by having the raw input system? I still don't know what the advantage is, so I'm nervous about turning it off.

Link to comment
Share on other sites

Nice catch!

So, the question is....what are the ramifications to doing this? What do you lose by turning off the raw input system. Or, what do you currently gain by having the raw input system? I still don't know what the advantage is, so I'm nervous about turning it off.

My guess is multiple keyboard.. As AHK sends keys to it it cannot tell if AHK is sending the key or my keyboard is. Where as before it didnt accept it..

Link to comment
Share on other sites

  • 1 month later...

Just curious if anyone has worked on this any further. I'm stepping up to MAME 0.130 and thinking of incorporating this hack in as well. If it works, I'll be using my guns with modern versions of MAME! Just curious if there have been any drawbacks found (or if it really works)?

Link to comment
Share on other sites

I just looked at the code and I don't know why I didn't see that in the first place...it's on one of the first lines of code and documented pretty clearly that it will turn off the raw input system. :blink:

Thanks for the advice, I'm going to check this out now!

Link to comment
Share on other sites

I just wanted to post an update now that I've had a chance to play a few games. I applied the mod that HK's suggested above:

#define FORCE_DIRECTINPUT	1

This works GREAT! I have both guns working in MAME just fine! MAME also detects XPadder keys, so it should work with any other script as well. This should simplify things pretty nicely for me now as I won't have to keep an old copy of MAME and old roms specifically for gun games any more. AWESOME!

Now if I could just figure out how to update the MAME Analog+ code for the current version of MAME, I'd be down to a single version! B)

Link to comment
Share on other sites

  • 5 months later...

hey guys i need a little help here

i'm trying to have mame plus exit when two keys are pushed for 2 seconds or longer.

so i compiled mame plus 0.133 with this

// For testing purposes: force DirectInput
#define FORCE_DIRECTINPUT 1

my ahk script to exit that works for all emulator is this one:


; <COMPILER: v1.0.47.6>
#InstallKeybdHook
#SingleInstance force

QuitWaitTime:=0

#Persistent
SetTimer, WatchQuitCombo, 250
return



WatchQuitCombo:
if GetKeyState("5") AND GetKeyState("c")
{
SetTimer, ComboQuitDown, 100
SetTimer, WatchQuitCombo, Off
}
return

ComboQuitDown:
if GetKeyState("5") AND GetKeyState("c")
{
QuitWaitTime:=QuitWaitTime + 100
if QuitWaitTime >=2000
{
Send {Blind}{Escape}
QuitWaitTime:=0
SetTimer, WatchQuitCombo, 250
}
}
Else
{
QuitWaitTime:=0
SetTimer, WatchQuitCombo, 250
}
return

now i set mame to exit on the ESC Button but it's still not responding to this? DOes anybody know what is going wrong here?

Link to comment
Share on other sites

yeah i was using the same key combo before, but sometimes people were ending games by accident so a delay timer would be really nice!

HK, do you have any idea what could be the problem here?

Link to comment
Share on other sites

  • 2 years later...

Take a look in src\osd\windows\input.c and change

// For testing purposes: force DirectInput
#define FORCE_DIRECTINPUT 0

to

// For testing purposes: force DirectInput
#define FORCE_DIRECTINPUT 1

That should do it.

Big shout to HK for helping me before I even knew I needed it! This works great!! Too bad it's not a tick box in Mame Compiler 64, but I can do it this way too. :)

Link to comment
Share on other sites

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