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: Multiple Keyboards in MAME  (Read 11342 times)

0 Members and 1 Guest are viewing this topic.

markronz

  • We traced the call, and it came from....INSIDE YOUR ARCADE MACHINE!
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 821
  • Last login:April 12, 2019, 12:03:08 am
  • Game on!
Multiple Keyboards in MAME
« on: December 08, 2011, 09:57:42 am »
Hey guys-
   I remember that there is a setting in Mame for "Multiple Keyboards".   I think it's just multiplekeyboard in the mame.ini file.   Well, I turned this option on, once upon a time, and I have no idea why I did it.   From what I can tell, all it does, is let know that there are multiple keyboards and it assigns each keyboard a number.  So when I set my keys for games in MAME it will say something like KEYCODE_2_A instead of just KEYCODE_A.    Now, I am currently working with a four player arcade machine, however, each button is assigned to a different unique key.  So there is not really a KEYCODE_1_A and a KEYCODE_2_A.   There's only one button, as a whole, assigned to A.    Anyway, I was just wondering if there were any benefits to having this multiple keyboards option enabled besides this numbering?  Anything I am missing?   From my point of view, I am getting no benefit from having it on.  For the life of me, I just can't figure out why I turned it on in the first place!

The reason I am asking is because I recently switched around how my USB's were plugged in, and MAME has renumbered my keyboards.  So none of my configurations work any more, as Keyboard 1 is now Keyboard 2 in mame.   I'm sure I can fix this, if I wanted to, but it just got me questioning as a whole, the multiple keyboards thing, and if it's really necessary for me to have that option on at all.

So any help would be appreciated!

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: Multiple Keyboards in MAME
« Reply #1 on: December 08, 2011, 11:40:20 am »
Yeah, mame is kind of weird about the way it deals with multiple devices, but it's not entirely mame's fault.

the real issue is that Windows, when it sees multiple devices of the same type connected (this is USB devices, btw, I'm not talking about other stuff right now), it does two things.

1) it stashed the device info in essentially an array of devices and that array is always kept filled. That means that if you plug device a in and then b, a will be in slot 1 and b in slot 2. If you then unplug them and plug them in b first, b will now be in slot 1 and a in slot 2.
2) For many devices, windows does log a unique ID for the device. however, from what I can tell, MAME doesn't use it. Mame bases everything on those "slot" numbers I mention above.

This is particularly problematic for keyboards and mice, because in both cases, +usually+ all mice are treated by MAME as if they're a single mouse. Same with Keyboards.

HOWEVER, if you have a mouse and several trackballs connected (trackballs look like mice to windows and mame), then if you DON'T enable the multiplemice option, mame will treat all the mice/trackballs as a single mouse.

If you enable it, then you get numbering similar to what you're seeing for the keyboard devices.

If you DON'T want the keyboard devices considered independently, just turn off that multiplekeyboard option, then run through all your CFG files and replace KEYBOARD_1_ with KEYBOARD_
Same with KEYBOARD_2_, etc

So you'll end up with just KEYBOARD_A, KEYBOARD_B etc.

Alternatively, (and with a bit more work), you might use my ControllerRemap utility (see my sig) to automatically remap controllers dynamically each time you start mame.

I use it in particular because often when I connect or disconnect my drum or guitar controllers, doing so shifts around trackballs, or joysticks. ControllerRemap uses the uniqueID that's available to specifically rewrite mame config files to point to whatever slot the applicable controller is now "in".

It's still a bit of a pain, but once you get it going, it's pretty seamless.

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9270
  • Last login:July 14, 2025, 01:30:54 pm
  • ...
Re: Multiple Keyboards in MAME
« Reply #2 on: December 08, 2011, 12:17:37 pm »
I have it enabled on my driving cab for tweaking and maintenance.

The Key-Wiz that my buttons are hooked up to is Keyboard 1.
I use a wireless USB keyboard (keyboard 2) when I want to access service menus, display FPS, tweak things in the MAME in-game menu, etc.
I don't want those things accessible without using keyboard 2.

The Key-Wiz is hooked up to the PS2 input on the mobo.  
Windows has never re-ordered them.
« Last Edit: December 08, 2011, 12:19:54 pm by BadMouth »

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: Multiple Keyboards in MAME
« Reply #3 on: December 08, 2011, 12:28:12 pm »
From my experiments with it, devices other than USB are handled differently by windows. I also never saw the mouse or keyboard connected to the PS2 ports change in position. So if that's an option, definitely go for!

But if you've got lots of actual USB devices that you regularly plug and unplug, you'll almost certainly have issues at some point.

There are some utilities to let you remap devices, but they generally are manual and wouldn't work particularly well in a cab.

markronz

  • We traced the call, and it came from....INSIDE YOUR ARCADE MACHINE!
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 821
  • Last login:April 12, 2019, 12:03:08 am
  • Game on!
Re: Multiple Keyboards in MAME
« Reply #4 on: December 08, 2011, 12:35:42 pm »
Thanks for the responses you two.   This was very informative for some other projects that I will be working on.  However, for this one, I will not be unplugging devices at all.  And my USB's will always stay in the same ports.  And since none of the key assignments conflict with each other, there's no reason for me to have multiple keyboards enabled then, is my understanding.   So to simplify things for this project, I think I will just disable that option.

Thanks!

FALSE

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 217
  • Last login:February 25, 2024, 08:13:59 pm
Re: Multiple Keyboards in MAME
« Reply #5 on: December 08, 2011, 11:39:27 pm »
Just out of curiosity, why would you want multiple keyboards in mame????

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: Multiple Keyboards in MAME
« Reply #6 on: December 09, 2011, 07:47:35 am »
As a guess, if you wanted to use a keyboard encoder to drive joysticks and buttons, but then ALSO be able to use a normal keyboard to control certain games (for instance Mahjong, although, I can't think of any good reason to play any of those Mahjong games  :)

Bottom line, the +need+ is probably pretty unlikely.