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: MAME Joystick POV recognition  (Read 7413 times)

0 Members and 1 Guest are viewing this topic.

hoffy84

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 32
  • Last login:July 05, 2025, 12:38:04 pm
  • It's not just a project, It's an obsession....
MAME Joystick POV recognition
« on: February 12, 2013, 11:36:26 pm »
Hello all,

I have a toughy here: I recently updated my MAME version, from 131 to 148 in hopes to solve this issue, but it still persists....

I am have a Hagstrom KE-USB108 for an encoder. I chose this because I have a lot of joysticks/buttons. When I initially set it up, I used all of the keyboard assignments for inputs, but ended up running out of available keys, so I had to assign {SHIFT} + on a lot of them, and when we would test a 4-player simultaneous game, some players' controls would interfere with each other. So in efforts to eliminate that, I remapped the main 4 joystick/button zones to the KE-USB108's joystick inputs. The joystick portion of the KE-USB108 allows you to utilize (4) POV hats and 64 button assignments. So naturally, I used the 4 POV hats as my player 1 thru 4 joysticks, and 32 of the joystick buttons to do all my player 1 thru 4 CP buttons.

This solved my interference problem completely. The details are on the 8th post of this thread: http://forum.arcadecontrols.com/index.php/topic,113276.0.html

The problem I am having now is this:
When I go into MAME>(whatever game)>TAB>INPUT FOR THIS GAME and make my settings for the joysticks, everything works as expected; plays fine.
When I exit, and go back into that same game, MAME remembers all the key assignments (except for the joysticks: which are all configured thru KE-USB108 POV hats 1 - 4).
I noticed that when I re-assign everything in MAME's TAB menu, no matter what joystick I use, MAME see's them as "Joy 1 Hatswith U, Joy 1 Hatswitch D, etc....) YET THEY ALL WORK INDEPENDENTLY OF EACH OTHER.
In fact, When you go into Control Panel>Game Controllers and look at "KE-USB108 joystick" properties, and test the 4 joysticks, they register as one POV hat, but when the directional arrows appear when moving JS1, the arrows are black, JS2's arrows are red, JS3's arrows are blue, and JS4's arrows are green.
So I know that they are distinguishable in Windows, but it's just not holding in MAME.
And MAME see's them independently (somehow) and works great; I just can't get MAME to remember that they are there.
Anyone know if maybe I can manipulate some settings in the INI file to fix this, or is there a 3rd party app I could use to get MAME to remember which POV hat was used last?

Thanks!
 

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Yesterday at 08:08:03 pm
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: MAME Joystick POV recognition
« Reply #1 on: February 13, 2013, 05:47:56 am »
Ok let me see if I can help. 

In windows the whole mess shows up a single joystick correct?  If so that's the problem.  Hat switches are a pain in the butt.  Unlike analog sticks and buttons they are encoded in an odd way and require special programming to read.  For this reason, and the fact that I've NEVER seen a joystick with more than one hat switch on it, I seriously doubt that mame supports more than one. 

Your solution is real simple... use buttons for the joysticks. 

Also on a side note, unless I'm doing the math wrong you have too many buttons on your control panel.  Sure you might want up to 7 buttons for p1 and p2, but there isn't a single solitary 4-player game out there that uses more than 4 buttons, so p3 and 4 only need 4.  ;)

EssexMame

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 472
  • Last login:May 20, 2025, 09:13:39 am
  • Mame Weekender
Re: MAME Joystick POV recognition
« Reply #2 on: February 13, 2013, 06:38:23 am »
Dragon King,
Which games use 7 buttons for P1/P2?

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Yesterday at 08:08:03 pm
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: MAME Joystick POV recognition
« Reply #3 on: February 13, 2013, 06:42:51 am »
None, but a popular thing to do if you are a Neo-Geo fan is to add a 7th button to the lower-left of the first row since Neo-Geo games and a few other systems use a single row of 4 buttons. 

So a bottom row of 4 for the neogeo games and another top row of three so you still have your standard Street Fighter layout in tact.  Some people wire this extra, 7th button up seperately as it's also useful for Mortal Kombat II and 3, which had run button in a similar area. 

hoffy84

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 32
  • Last login:July 05, 2025, 12:38:04 pm
  • It's not just a project, It's an obsession....
Re: MAME Joystick POV recognition
« Reply #4 on: February 14, 2013, 11:36:55 pm »
Thank you for the help, guys.

I know I have a lot of buttons that are not neccessary for multi-play, but the reason I have the outter 2 joystick zones with 5 buttons is bc they can be used for MK games, and the inner 2 joystick zones can be used for SF type games. I know 8 buttons for those 2 zones is a little overkill, but I wanted them to also be doubled up for the few games that require multiple buttons like Defender or even N64 games. (I'm not just using my cab for MAME, so I had to keep console games in mind as well)

So in my original post, I mentioned that I have 64 joystick buttons that can be coded through my KE-USB108, but MAME only sees 1 thru 32. Those are all used up. 33-64: Mame doesn't recognize. I want to avoid assigning keyboard keys, bc that created problems the first time I tried. Plus, I just don't have enough regular keyboard keys to assign without getting into [SHIFT]+.

So Howard, I very much like the idea of being able to use the remaining JS buttons to trigger my joystick movements, and since POV hat is now out of the question...... Is there any way to get MAME to see JS buttons 33 - 64 ? I would like to think that there is an INI file somewhere in MAME where I can add these inputs that the Windows default Joystick settings show they ARE available and translate those to some kind of extra inputs in MAME's keymap settings...... Just not sure how one could make this work, or if I am even explaining this accurately.

Hope you don't think I am being stubborn, I just want to see if there is anything I can do outside of the norm. LOL! (Outside of the norm: SEVEN friggin JOYSTICKS!! WTH was I thinking.....???

EssexMame

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 472
  • Last login:May 20, 2025, 09:13:39 am
  • Mame Weekender
Re: MAME Joystick POV recognition
« Reply #5 on: February 15, 2013, 11:16:07 am »
It certainly looks outside of the norm :-) An impressive array of options!!

hoffy84

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 32
  • Last login:July 05, 2025, 12:38:04 pm
  • It's not just a project, It's an obsession....
Re: MAME Joystick POV recognition
« Reply #6 on: February 16, 2013, 02:24:15 pm »
It certainly looks outside of the norm :-) An impressive array of options!!

Yeah, the SOLE reason for having 2 opposing flight sticks was so I could play Vindicators 1 & 2. (Love those games!) I was worried about dead-zones, bc they are 8-way capable, and the original cab used 2-way tank sticks, but both games play awesome with these.

Gray_Area

  • -Banned-
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3363
  • Last login:June 23, 2013, 06:52:30 pm
  • -Banned-
Re: MAME Joystick POV recognition
« Reply #7 on: February 17, 2013, 03:02:12 pm »
You cut a table top in half, right?   Interesting overlapping design, though maybe cooler with both round ends on the same side. I'm betting you still have to many buttons. But what I'm most curious about is how did you mount the flight sticks?
-Banned-

nick3092

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 211
  • Last login:March 22, 2022, 03:57:28 pm
Re: MAME Joystick POV recognition
« Reply #8 on: February 18, 2013, 04:54:19 pm »
So in my original post, I mentioned that I have 64 joystick buttons that can be coded through my KE-USB108, but MAME only sees 1 thru 32. Those are all used up. 33-64: Mame doesn't recognize. I want to avoid assigning keyboard keys, bc that created problems the first time I tried. Plus, I just don't have enough regular keyboard keys to assign without getting into [SHIFT]+.

So Howard, I very much like the idea of being able to use the remaining JS buttons to trigger my joystick movements, and since POV hat is now out of the question...... Is there any way to get MAME to see JS buttons 33 - 64 ?

AFAIK, you are out of luck.  DirectX (specifically Direct Input) maxes out at 32 buttons per device.  So MAME will never see 33+ as native joystick devices.

Also, given your high number of buttons you are likely to run into this:  There is bug in the MAME input code (for Windows anyway, SDL behaves differently and works OK) where whatever you assign button 17 to will work fine during that session.  But then when you quit and MAME writes the cfg file, it double enumerates button 17 as 16.  It also causes the cfg file to miss number all buttons 17+.  For example, Button 2 in Windows is saved as Button 2 in the cfg file.  But with 17+, it starts saving them one number off.  So button 32 in Windows is saved as 31 in the cfg file.  MAME is compensating for it due to the bug.  But it breaks button 17, since it enumerates it with 16 and gets confused.

I have a possible patch into the dev team to make it enumerate all 32 buttons correctly.  But I don't know if it will be accepted or not.  If it does, expect anyone with an encoder that is seen as a joystick to be really confused when all buttons 17+ are acting incorrectly with their current cfg.  ;D

nick3092

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 211
  • Last login:March 22, 2022, 03:57:28 pm
Re: MAME Joystick POV recognition
« Reply #9 on: February 18, 2013, 05:26:15 pm »
In windows the whole mess shows up a single joystick correct?  If so that's the problem.  Hat switches are a pain in the butt.  Unlike analog sticks and buttons they are encoded in an odd way and require special programming to read.  For this reason, and the fact that I've NEVER seen a joystick with more than one hat switch on it, I seriously doubt that mame supports more than one. 

I've been diving into the input code in MAME as of late to work on the button 17 issue, and I can say MAME actually is defined for up to 4 POV/hats.  Not to say something isn't wrong in the code that reads/enumerates them though.  To Howard's point, if the hardware isn't common, then that part of the code probably hasn't been tested.

From src/emu/input.h:
Code: [Select]
// maximum number of axis/buttons/hats with ITEM_IDs for use by osd layer
const int INPUT_MAX_AXIS = 8;
const int INPUT_MAX_BUTTONS = 16;
const int INPUT_MAX_HATS = 4;
const int INPUT_MAX_ADD_SWITCH = 16;
const int INPUT_MAX_ADD_ABSOLUTE = 16;
const int INPUT_MAX_ADD_RELATIVE = 16;
...
// Hats
ITEM_ID_HAT1UP,
ITEM_ID_HAT1DOWN,
ITEM_ID_HAT1LEFT,
ITEM_ID_HAT1RIGHT,
ITEM_ID_HAT2UP,
ITEM_ID_HAT2DOWN,
ITEM_ID_HAT2LEFT,
ITEM_ID_HAT2RIGHT,
ITEM_ID_HAT3UP,
ITEM_ID_HAT3DOWN,
ITEM_ID_HAT3LEFT,
ITEM_ID_HAT3RIGHT,
ITEM_ID_HAT4UP,
ITEM_ID_HAT4DOWN,
ITEM_ID_HAT4LEFT,
ITEM_ID_HAT4RIGHT,

hoffy84

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 32
  • Last login:July 05, 2025, 12:38:04 pm
  • It's not just a project, It's an obsession....
Re: MAME Joystick POV recognition
« Reply #10 on: February 18, 2013, 06:37:52 pm »
Nick3092,

THANK YOU!! This is the kind of headway that I wanted to start making. I appreciate all the other suggestions, but this gets me closer to the inner workings and answers that I was looking for. The last few years, I have been concentrating on build, build, build and now that most everything is built, I am getting back into the software, and trying to tie everything together. I am glad you pointed me to the input.c file that proves that MAME is intended to see all 4 POVs, and it makes sense that the KEUSB108 is not extremely popular on home built arcade cabs, so the drivers for it are probably not tested with the MAMEdevs. I am not, and never was completely familiar with how MAME operates in great detail, so thank you so much for pointing this out.

The good news is that I recounted all my inputs (there are 80 total), and combined with the joystick buttons and available one-stroke keys I MIGHT be able to squeek by. Another concern that I started thinking about: Even if I was able to utilize all 4 POVs, would they be recognized by the other console emulators? I am able to save as many keymaps that I want to for the KEUSB108 , but I'd probably have to write some complicated AHK file to get it to load/unload to the hardware, everytime I changed systems in the front-end.

I did mention in another topic that MAME sees buttons 1-32 as buttons 0-31; At least that is what I ASSUMED, based on what I was seeing when I assigned the JS buttons using in-game TAB, but now that I read your post, I am completely wrong, and need to try and edit that.  So one more question if I may: If I simply omit JS button 17, will I still be able to use 18-32, and have everything work okay? I understand the problem starts at 17 like you said, but if 17 were left out of the equasion, would I still be able to use the rest normally, or would they get messed up (double enumerated), too? I guess I could try and see what happens,,,,

Can you keep me in the loop, when and if you find out if the MAMEdevs approved your patch? I would say that is an extremely important problem that you found, and YES it WILL effect many JS button users, if it is fixed!!

Thank you again for shedding the light on this!!! I thought I was crazy..... :cheers:



nick3092

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 211
  • Last login:March 22, 2022, 03:57:28 pm
Re: MAME Joystick POV recognition
« Reply #11 on: February 18, 2013, 07:29:31 pm »
I am glad you pointed me to the input.c file that proves that MAME is intended to see all 4 POVs, and it makes sense that the KEUSB108 is not extremely popular on home built arcade cabs, so the drivers for it are probably not tested with the MAMEdevs. I am not, and never was completely familiar with how MAME operates in great detail, so thank you so much for pointing this out.

Keep in miond the file I pointed out is not the one that reads in the OS specific interface and enumerates.  That is just the core input header file.  For Windows, you need to look at src/osd/windows/input.c to troubleshoot the POV issue.

I did mention in another topic that MAME sees buttons 1-32 as buttons 0-31; At least that is what I ASSUMED, based on what I was seeing when I assigned the JS buttons using in-game TAB, but now that I read your post, I am completely wrong, and need to try and edit that.  So one more question if I may: If I simply omit JS button 17, will I still be able to use 18-32, and have everything work okay? I understand the problem starts at 17 like you said, but if 17 were left out of the equasion, would I still be able to use the rest normally, or would they get messed up (double enumerated), too? I guess I could try and see what happens,,,,

Can you keep me in the loop, when and if you find out if the MAMEdevs approved your patch? I would say that is an extremely important problem that you found, and YES it WILL effect many JS button users, if it is fixed!!

Thank you again for shedding the light on this!!! I thought I was crazy..... :cheers:

Windows control panel and the MAME cfg files enumerate buttons starting at 1.  The OSD/UI/menu inside MAME starts at 0.  So:

Button 3 in Windows CPL = JOYCODE_#_BUTTON3 in cfg file = JOY # BUTTON 2 in MAME OSD/menu

With the current bug in windows input handling for 17+ you will see:

Button 20 in Windows CPL = JOYCODE_#_BUTTON19 in cfg file = JOY # BUTTON 19 in MAME OSD/menu

You can use 18 - 32 fine with the current bug in MAME, just not 17.  There is a workaround to use 17, but it's annoying.  You have to re-map it every time you launch MAME/MESS.  I just submitted the patch this weekend, so I'm sure they are still reviewing it internally.  Obviously you'll only have an issue if you update your MAME version from one with the bug.  A lot of people tend to not update their MAME version very often (if ever).  I'll certainly pass along if I hear they approve it.

hoffy84

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 32
  • Last login:July 05, 2025, 12:38:04 pm
  • It's not just a project, It's an obsession....
Re: MAME Joystick POV recognition
« Reply #12 on: February 19, 2013, 09:52:44 am »
Hey Gray_Area,

Didn't want to get too far off topic, but to answer your questions...

You cut a table top in half, right?

No, didn't euse a table top; I used the end of a 4x8 ft birch plywood sheet, built a router jig, and cut using a pivot point to get the desired curve. See pictures below...

But what I'm most curious about is how did you mount the flight sticks?

Funny you should ask that! I found these flight sticks on Paradise Arcade, and was skeptical about buying them. My entire cab is made from birch plywood, and there are no visible screws. Everything is fastened from within because I am staining the entire thing. (Wanted to stay away from graphics and decals, bc I want it to look like a piece of furniture, just my preference) So the same was true for the control panel: with the exception of the bolt heard that you can see that help hold the plexi down, all my controls were mounted from the bottom. The flight sticks were the last things ordered. Before I ordered them, I emailed PA to verify these could be mounted from the bottom.  This is what they said: "You can mount this above or below....if you mount below you just need to be sure the hole is large enough for ease of movement." So I went ahead and ordered, but when I got them, I just could not see how they could be bottom mounted. I tried on a test piece of wood, and did everything I could to get them bottom-mounted, but just would not work. I even beveled the hole to try and get more movement, but to no avail. I would have had to route the square down to leave about 2/16" of top-wood to barely get them in, and at that point, you compromise the integrity of the wood. These FS's were obviosly made for metal panels or top-mount only, so I was a little miffed about that. I was reluctant to top mount them. I did not document very well, but you'll see in the pics below that I had to sink the mounting plate by routing the wood, and then to conceal them, I had to make a trip to the local craft store, and buy some decorative, textured black paper and cut them in circles to go over the top-mount mess. It was a compromise, but I am happy with the results...


Gray_Area

  • -Banned-
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3363
  • Last login:June 23, 2013, 06:52:30 pm
  • -Banned-
Re: MAME Joystick POV recognition
« Reply #13 on: February 19, 2013, 11:46:49 am »
Ohhhhh. You counter-sunk them. I hadn't really thought of that. I was contemplating making a metal or plastic insert, but that would require counter-sinking as well.

I thought a jig for that great a curve would have to be huge, but now I can see it was only a few/several feet.

Thanks.
-Banned-

hoffy84

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 32
  • Last login:July 05, 2025, 12:38:04 pm
  • It's not just a project, It's an obsession....
Re: MAME Joystick POV recognition
« Reply #14 on: February 19, 2013, 01:27:45 pm »
Yeah, It was hard to find some cheap flight sticks anywhere. The good anologue ones are like $175, but I wouldn't be playing many games that require them. SO for $20 bucks a pop, these were the best I could do. Not complaining though; they serve their purpose for what I need.

Initially I thought the same for the jig, but it really just depends on where you set the pivot point. It took like 2 hours to make the jig, just to make one cut! I still have the jig sitting in my garage for that one day that I may use it again. LOL!