Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: How does windows recognise a controller? (emulation rig query)  (Read 879 times)

0 Members and 1 Guest are viewing this topic.

Chris BEANS

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 31
  • Last login:April 01, 2013, 01:10:50 pm
How does windows recognise a controller? (emulation rig query)
« on: January 15, 2011, 07:25:45 am »
This isn't a problem I'm having yet, just something I need to clarify while I'm in the planning stage.....

Not sure if the full explanation below is required, but I suppose too much information is better than too little!!


I'm building a rig that will essentially be a mame/emulation machine.
It'll boot directly into a frontend for the various emulators. The frontend and all emulators will be controlled directly by an arcade style USB joystick and buttons, no need for a keyboard and mouse.

However, there will be two individual arcade style joysticks and they won't both be plugged in at all times.

In addition, there will be occasions that I will come out of the frontend and into the windows environment (via a wireless keyboard and mouse) to use iTunes, play the odd PC game or even to use other emulators that don't suit the arcade style controls, and in that case I'd be plugging in a more suitable USB controller.


Now... both USB joysticks will use identical PCB's.
I know that with both plugged in, windows will identify one as controller 1 and the other as controller 2, and that when it does I can configure the controls for the frontend and emulators accordingly (for navigation and separate 1 & 2 player controls). That's great for when the rig is used exclusively with the frontend and the joysticks are permanently plugged in, but, the query I have is that if I've unplugged the arcade controllers, used a USB gamepad on a PC game and then switched off the rig.... When I restart the rig and plug the arcade controllers back in, how do I ensure that the PC sees the arcade controllers as the correct controller 1 & 2 respectively?
Do I simply ensure that no other USB devices are plugged in and plug the joysticks back into the same USB ports they were in before? Does it make a difference in what order they're plugged in?
Are there any other conflicts likely to occur that I haven't even thought of yet??

If you've bothered to read all of the above, thanks loads, you'd be saving me a massive headache if you can help!! :)

mgb

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3500
  • Last login:August 03, 2025, 07:25:14 pm
  • North East, US
Re: How does windows recognise a controller? (emulation rig query)
« Reply #1 on: January 15, 2011, 10:01:50 am »
What are you planning on using for the controls exactly? Will you be using an Ipac or Keywiz, or something or a Usb stick like the Ultra 360?
Why can't both controllers stay plugged in at the same time?
With some devices, you assign the ID number. Like if you order multiple spinners from Groovy Game Gear, one would be assigned ID 1, the other would be ID 2.

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: How does windows recognise a controller? (emulation rig query)
« Reply #2 on: January 15, 2011, 10:24:28 am »
Sounds like you have +exactly+ my problem.

The issue is how MAME maps joysticks. Mice (or anything that looks like a mouse, like a spinner), etc can be problematic too if you plan on plugging/unplugging them.

Essentially, mame uses DirectInput to enumerate the USB devices, When it does so, Windows always enumerates those devices in order of their VENDOR ID, from what I can tell.

This means that if you have3 joysticks plugged in, they'll enumerate as 1,2,3 in order of their VENDORID (which is basically a random hex number). If you then start mame, and map sticks to inputs, fine.

BUT

If you then plug up another stick, depending on it's VENDORID, it might go AFTER the sticks already in the system, between them, or before them.

If the latter two cases, if you then start mame again, you'll find that some or all of the sticks that were mapped correctly are STILL mapped to the same device numbers, but the actual devices have shifted in the enumeration, so they're mapped wrong.

MGB is right about being able to assign Joystick IDS, and that does work (there's a great program out called JOYIDS.exe that allows you to easily do that). When you set ID's to joysticks, windows will make a pretty good attempt at preserving the joystickID for a given device, even when you unplug and then plug it back in.

Great!

Except mame doesn't appear to use JoystickID's. It +ONLY+ looks at the order of the sticks in the system. (If I'm wrong on this, please someone correct me cause I've searched all over the source and the web for any hint that mame might handle the stick via their ID with no luck).

Bottom line, if you plan on being able to plug and unplug devices from a cab, and you want to use mame, you may or may not be screwed UNLESS you get really lucky and the devices you're going to unplug sort toward the end of the list (IE they've got a higher VENDORID that the devices already in the cab).

I'm actually working on a utility to help mitigate this issue, if you're interested.

The idea is to essentially run +in front+ of mame, look at the devices in the system and change the mame controller mappings to match those devices +right before+ mame runs.

The biggest problem with that approach, unfortunately is that mame completely rewrites the CFG files in the CFG folder, throwing away any +non-mame+ aware settings in those files. No idea why they do it that way, but there it is.

If you're interested, in helping out with the testing or giving me some feedback on it, let me know. I'm planning on releasing it to the community once I'm finished with it, but it's gotta be bulletproof. I don't want to have it fouling up anyone's controller files beyond use!
« Last Edit: January 15, 2011, 10:26:30 am by drventure »

Chris BEANS

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 31
  • Last login:April 01, 2013, 01:10:50 pm
Re: How does windows recognise a controller? (emulation rig query)
« Reply #3 on: January 16, 2011, 07:14:16 am »
Hmmmmm.

It's not ideal, but I've given it loads of thought and I think I'm going to go for a dual boot system. Straight into the front end on one, Itunes and the odd PC game on the other.

Not ideal, but not the end of the world.

Anyone know If I can have each windows install on a seperate HD, or if I have to have a partitioned HD to dual boot?



As for testing your utility drventure, I'd be more than happy :)
I could only test it from the point of view of a clueless end user, but as probably the majority of people that use it will be in the same category I guess it makes sense to have one as a tester!!
If I can make any useful suggestions or help you iron out any bugs I'd be very happy to help :)

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: How does windows recognise a controller? (emulation rig query)
« Reply #4 on: January 16, 2011, 11:04:01 am »
Great. No idea when I'll have a testable version yet. In coding on it yesterday, I came to another realization that I think should make it a whole lot more seamless (I'm gunning for a solution that's basically just copy it over, set up a command line in your front end and your done. Whether that's possible or not remains to be seen).

I'll let you know

Thanks!