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

Script to configure emulators according to joypad connected


Recommended Posts

Posted

Hi =)

New to the GameEx community, love this wonderful program but there is ONE THING I can't manage to do.

I explain :

Often, I make party with friends, sometimes we're 3, sometimes we're 5, sometimes we're up to ten, and I also got 10 joypads (of all kinds, some with analog sticks, some without, some arcade controls...).

Then we often play games like Bomberman, Super Smash Bros, or other funny multiplayer games, with different systems (MAME, SNES, N64, Saturn, Playstation...).

But every time it's a f***in pain to remap all the controls in every emu, especially when we shift between 10 different games or more during the night.

So, is there a way for GameEx to :

- Detect which pads are connected, according for instance to their USB names (ex. : P220, Thrustmaster...)

- Detect what is their order (Joystick 1 is P220 n°1, Joystick 2 is XBOX Pad, Joystick 3 is P220 n°2 etc..)

- Map them accordingly in the different emulators at the launch of the games

(for instance "button A" in P220 is control number 7 and A in Thrustmaster is control number 4...)

So that I will be able to plug and unplug them in the order I want, in the USB ports I want, and play directly the games I want without having to conf the emulators every time...

Thanks a lot!

Posted

GameEx cannot do this. You should check out 3rd party programs like XPadder as they can do this very nicely. I haven't checked the status lately, so I don't know if there is a freeware version available any more (at one point the dev had some issues that forced him to pull the program back entirely, but I think the last free version was reposted).

http://www.xpadder.com/

EDIT: looks like the dev is currently selling XPadder for $9.99. For what it does, it's a nice product and worth the money. I wish he had a demo of some kind so people could see that.

Posted

I use a Logitech Dual Action keypad and have no problems using their software with GameEx and MAME or any of the emus I have tinkered with to date (and it is free).

Posted

Hi doom_Oo7, and welcome to the GameEx forums!

To be honest I’ve never used the controller mapping utility in GameEx so I’m afraid I can’t speak specifically to your questions regarding the native controller functionality in GameEx. (Update: If bkenobi says it can't be done, then there's no way to accomplish this using the integrated tools). I’ve always used Xpadder for these purposes and it works fantastic. I suggest Xpadder specifically here for its ability to load and swap out controller profiles via the command line (I’m not sure if there are other controller mapping utils that offer this functionality). I do something similar to what you describe using a combination of Xpadder and an AutoHotKey script, but it may not be strictly applicable to your question.

If you wish to swap out controller profiles on a per emulator basis, all you need to do is create a batch file specifying the proper Xpadder controller profile(s) to run when the emulator starts, and enter it as a 'run before' option for the emulator in question (under Advanced Emulator Config). If you wish to swap out Xpadder profiles based on what game is being loaded, that's where a script becomes necessary. As I mentioned, I have a script that does something similar to this, but it's not tailored specifically for these purposes (it would require rather extensive modification). In this scenario you would need to pass the [ROM] variable into the script from GameEx so that the script would in turn load the proper controller profile(s).

To address your requirements:

- Detect which pads are connected, according for instance to their USB names (ex. : P220, Thrustmaster...)

- Detect what is their order (Joystick 1 is P220 n°1, Joystick 2 is XBOX Pad, Joystick 3 is P220 n°2 etc..)

Xpadder seems to handle this very well, although I can’t elaborate on how or why. I think the free version handles this just as well as the paid version, but I’ve been using the paid version for a while now so I’m not sure (totally worth the $9.99 by the way). For me it’s always been one of those things that ‘just works’

- Map them accordingly in the different emulators at the launch of the games

(for instance "button A" in P220 is control number 7 and A in Thrustmaster is control number 4...)

On a per emulator basis, you should be good to go with just a batch file referencing your Xpadder controller profile(s). On a per game basis, you'll need a script. Under either circumstance you would need to create any of the necessary Xpadder profiles for all of the controllers you wish to map (and potentially on a per game basis if I understand you correctly).

(Edit: I realized I was (potentially) trying to make this too complicated - a bad habit of mine :blink: . Simplified my suggestions)

Posted

Hi doom_Oo7 !

To acomplish what you want I can only see one solution.

You have to try Eventghost.

http://www.eventghost.org/

This software manages all the sorts of events in a Windows system.

In my setup I use it to for example disable the IR Remote when in GameEx, and when in Xbmc disable my joysticks.

This software can detect hardware plug-in in your system by specific id.

So, you can assign a event everytime that you plug an specific joystick.

It's a tiny but very very powerfull and valuable piece of software.

I think you can get what you want from it.

If you need help, PM me!

Posted

'Kay guys, first thanks for the many replies, it's nice to see an helpful forum =)

Just bought & installed XPadder (Think it's worth the deal for 9.99$ - roughly 7 euros)

So I configured my different pads, I even had to take / modify photos which weren't in the db, gonna post'em in the afternoon. (France here ^^)

Still, I don't understand what to do now (I'm at the point when for each controller I've "found" every button and every stick and so on, but didn't assign any key to anyone of them).

So, for instance what must I do if :

- If I connect any of my pads to my computer and for instance I launch snes9x, I would like to be able to play without having to configure it

- The same if I connect 2, 3, .... , 5 pads (10 in saturn emulator =p bomberman mayhem \o/).

The main solution that came across my head (but sounds quite irrealistic) is to :

- Map for each controller, a profile for each emulator

- Inside this emulator, 8 sets, one for every "position"; it's not very understandable here so I'll do it with an example:

For instance, let's simplify by saying I've got three gamepads, two of type A (for instance xbox pad) and one of type B (for instance logitech lambda gamepad), and I use snes9x and project64.

There would be 4 profiles :

=> type A pad - snes

=> type A pad - project64

=> type B pad - snes

=> type B pad - project64

And inside every single of these profiles, there would be 3 "sets" :

set 1 if pad is plugged-in as the first => (pad/keyb format :)

Up / A

Left / Z

Down /E

Right / R

A / T

B / Y

X / U

Y / I

L / O

R / P

Start / ^

Select / $

set 2 if pad is plugged-in as the second =>

Up / Q

Left / S

Down / D

Right / F

A / G

B / H

X / J

Y / L

L / M

R / %

Start / µ

Select / ¨

set 3 if pad is plugged-in as the third

(a third row of letters)

And in snes9x Joystick 1 would be conf'ed with A Z E R T Y U I O P ^ $ keys, Joystick 2 with Q S D F G H J K L M % $, and so on up to joystick 5

but then two problems :

- makes a fair amount of presets to do (10 gamepads, roguly 8/9 often used emulators makes roughly 500 sets to do -_______-

- how will xpadder load the correct set into the profile?

-' got a 101 keys keyboard, and with so many windows restricted keys, I'm afraid I wont be able to conf' em all...

So what must i do?did i mistake? please :D

Thnks a lot everybody =)

Posted

- how will xpadder load the correct set into the profile?

Using Eventghost!

It works like this :

1- The System Receive an Event (In your case, SNES joystick connect)

2- Whenever this event happens, You can assign an action (In your case, whenever that a Snes Joystick is connected, Eventghost calls Xppader with your Snes profile)

You can assign MULTIPLE action, so in that case you can :

1- Set Xppader to the correct controler mapping.

2- Set the emulator config to point to these mappings

3- Launch GameEx.

Posted

Hmm yeah but you'll have to explain me how to configure it.. read the help and it's more about the IR / remote TV control than the game controlling thing xD

and I still have to make many many profiles =( Q

Also, won't the "letters" disturb gameex?

Posted

Briefly, you need to set up XPadder and the joysticks so they work how you want them in whatever software you want them to work in. So, get the joystick detected in XPadder and build a layout that makes sense to you (perhaps just put the controller image in there with the buttons in the right spots). Then, figure out what keyboard buttons to what in your application (snes9x for instance...you've already done this). Finally, in XPadder, push the button you want to send a keyboard command and select the key you want sent. Save that config and you should be able to play with your joystick right away.

The second step is calling that config when the game is launched (you could call it when the gamepad is plugged in, but that could be problematic in GameEx). I'd make a batch file to load whatever configs you need loaded to play a certain emulator. Then, put that batch file in the launch before of your emulator.

Eventghost looks awesome, but I don't know that it's necessary in this case. Your call though...

Posted

Hmm alright to begin I made profiles for three of my gamepads, in the SNES optic (5 players max, so 5 profiles max). Making 15 different profiles was VERY boring -__-

At last in those 3 different gamepads it makes me a total of 5 gamepad because I own some twice.

In fact, I don't think I will be able to go to more than 5-6 players because I already do use every single key of my keyboard, except things like del, ver. num, caps lock, esc, enter, space, alt gr...

Also I had to be careful when mapping because Xpadder bugs with azerty keyboards ='( so remapped everything three times xD

Still, I finally tried some games and it worked fine.

So for now one great thing would be to use eventghost to make xpadder load profiles in a correct order...

Posted

"The second step is calling that config when the game is launched (you could call it when the gamepad is plugged in, but that could be problematic in GameEx). I'd make a batch file to load whatever configs you need loaded to play a certain emulator. Then, put that batch file in the launch before of your emulator."

Hehe, the problem is that the config won't be the same according to the gamepads I plug in... And if I plug two gamepads it must load a different config for each, same if I plug three gamepads... Hard times ^^

A perfect thing would be :

-Event manager detects the different gamepads, and assign them a number between 1 and n, n being the number of gamepads (starts to look like math course here \o/).

It writes in a file something like : (with numbers being the order the gamepads were plugged and A,B,C being the gamepad "types" (for real) (e.g. xbox pad, PS2 pad, saitek pad, logitech pad..)

1 A

2 B

3 A

4 C

5 B

then in a batch file or little C program, I launch :

Xpadder "profiles/A/1.xpadderprofile" "profiles/B/2.xpadderprofile" "profiles/A/3.xpadderprofile" "profiles/C/4.xpadderprofile" "profiles/B/5.xpadderprofile" %1%

Where %1% would be the commandline passed by gameex, for instance "snes9x.exe [rompath]/[romfile]"

Still, this way assumes that Xpadder has the same order than eventghost for the gamepads, else it ruins everything xD

Posted

vsilvalopes : I'm trying to conf Eventghost to make it do what i want (and I'm pretty sure it's possible) but when i drag the System.DeviceAttached events generated by the plugging of one of my gamepads, they seem to loose their unique identifier.

i.e when for instance I connect gamepad A, it generates a System.DeviceAttached event with the usb identifier of gamepad A.

so i drag the event to my macro.

When i plug it out and in again it activates the macro : it's okay.

But when I plug gamepad B (or a mouse, or a webcam, or anything here) it activates the macro too! halp! =p

EDIT : found the problem, I had to right-click and make copy instead of drag-and-drop...!

EDIT 2 : in fact it doesn't work anymore with this method : the macro doesn't trigger at all. Also, when studying the code given (for instance :

System.DeviceAttached [u'\\\\?\\USB#VID_044F&PID_B315#5&8b6c0fc&0&1#{a5dcbf10-6530-11d2-901f-00c04fb951ed}']

I came to the conclusion that there's absolutely no way using this code to differentiates two gamepads of the same kind (e.g. two XBOX controllers)

=>

VID_044F&PID_B315 are the Vendor ID and Device ID (brand and gamepad, for instance microsoft & XBOX controller)

5&8b6c0fc&0&1 is the USB port

{a5dcbf10-6530-11d2-901f-00c04fb951ed} is another identifier for the device.

So what would be needed is to :

-> start a counter

-> wait for device to be plugged in

-> when a device is plugged, grab its PID, increment $counter, and in the commandline add "profiles/$PID/$counter.xpadderprofile".

It would be far easier to store with an array or a list, might be doable in python...

Also, need to add support for the emulator... In fact, I think there will be a single program that gameex will launch and it will give the emulator name in argument, and the script will do the rest...

"And then, the feature appeared in Gameex 11.62"

Posted

Shit guy 'been learning python all the afternoon in conjonction with eventghost, it's quite powerful =p

In fact I'll be able to do something very dynamic : I will be able to add / remove gamepads during the game, replace gamepads with other if ppl want other gamepads... great! thanks everyone!

Posted

Alright it's a matter of minutes =) the only thing that pisses me off is that Xpadder has a defined order for gamepads, which can't be dynamically changed xD so this order has to be taken in account >.<

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