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: 4-way stick in software?  (Read 5239 times)

0 Members and 1 Guest are viewing this topic.

seaner

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 124
  • Last login:October 21, 2003, 02:10:16 pm
    • http://www.beerbot.ca/mame
4-way stick in software?
« on: March 21, 2003, 03:58:11 pm »
Has anyone considered turning an 8-way stick into a 4-way in software?  Has anyone tried it?  Success?  Miserable failure?
Since I designed my own keyboard encoder, this is obviously an option for me, rather than eating up panel space for dedicated 4-way sticks.

_Iz-

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 702
  • Last login:Yesterday at 08:55:13 pm
  • Time to coin up!
Re:4-way stick in software?
« Reply #1 on: March 21, 2003, 04:23:25 pm »
I saw a link posted to something that does exactly that. (It has another function also)

http://home.ptd.net/~ruover25/rotary/rotary.html

seaner

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 124
  • Last login:October 21, 2003, 02:10:16 pm
    • http://www.beerbot.ca/mame
Re:4-way stick in software?
« Reply #2 on: March 21, 2003, 04:30:37 pm »
excellent.. yes this does exaclty what I plan on doing.  While scanning the joystick inputs in 4-way mode, don't report any new movements if 2 adjacent switches are closed.  A simple toggle switch on the control panel labelled 4-way/8-way will do the trick!
This is the sort of feature that could even work its way into the mame codebase and apply the filtering at the pc end.

_Iz-

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 702
  • Last login:Yesterday at 08:55:13 pm
  • Time to coin up!
Re:4-way stick in software?
« Reply #3 on: March 21, 2003, 04:38:07 pm »
I thought there already was something like it in MAME. Sticky Keys? Steady Key? I remember discussion of it some time ago. I think it may not have been implemented very well...

seaner

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 124
  • Last login:October 21, 2003, 02:10:16 pm
    • http://www.beerbot.ca/mame
Re:4-way stick in software?
« Reply #4 on: March 21, 2003, 04:45:43 pm »
I've heard of this option, but I had a feeling it was just some debouncing code or other.  no matter, off to work on firmware tonight! can probably just have one switch to switch all joysticks to 4-way mode.. I can't think of any games that would use both 8- and 4-way sticks at the same time :)

_Iz-

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 702
  • Last login:Yesterday at 08:55:13 pm
  • Time to coin up!
Re:4-way stick in software?
« Reply #5 on: March 21, 2003, 05:08:53 pm »
In mame, search src\inptport.c for "sticky" to find out more info on the 4-way on 8-way stuff...

(steady key is the debounce option)
« Last Edit: March 21, 2003, 05:09:24 pm by _Iz- »

u_rebelscum

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3633
  • Last login:April 21, 2010, 03:06:26 pm
  • You rebel scum
    • Mame:Analog+
Re:4-way stick in software?
« Reply #6 on: March 21, 2003, 08:12:03 pm »
Mame currently does the first method for inputs compiled with the 4way flag, and the second way for the sticky option, IIRC.
Robin
Knowledge is Power

pragma

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 51
  • Last login:April 14, 2004, 04:04:49 pm
  • J-PAC, Taito cabinet, PC Monitor
Re:4-way stick in software?
« Reply #7 on: March 21, 2003, 08:30:18 pm »
Could you tell me more about the 4way flag and how to use it?

Thanks
Paul

seaner

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 124
  • Last login:October 21, 2003, 02:10:16 pm
    • http://www.beerbot.ca/mame
Re:4-way stick in software?
« Reply #8 on: March 22, 2003, 03:35:35 am »
Has anyone considered turning an 8-way stick into a 4-way in software?  Has anyone tried it?  Success?  Miserable failure?
Since I designed my own keyboard encoder, this is obviously an option for me, rather than eating up panel space for dedicated 4-way sticks.

If anyone cares to know.. a firmware solution works dandy.  I put a toggle switch on my panel.  Flipping it puts all of my sticks into 4-way mode.  It may not feel like a restricted 4-way stick, but no more pesky diagonals now on pacman, etc.

u_rebelscum

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3633
  • Last login:April 21, 2010, 03:06:26 pm
  • You rebel scum
    • Mame:Analog+
Re:4-way stick in software?
« Reply #9 on: March 22, 2003, 06:58:19 am »
Could you tell me more about the 4way flag and how to use it?

You have to put it in the driver source file and can't change it (except by recompiling again).

Example straight from pacman.c:
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_4WAY )

The biggest problem with it is with 8way sticks with huge diagonals.  You are pushing up, but not quite straight up, and accidentally move into the diagonal up-right.  Mame thinks, "oh, he's switching to right, so I'll just read this as right.  You can look at how mame handles the 4way flag in src/inptport.c, ScanJoysticks() function.  Pretty good documentation in the code on this, IMO.

Restricter plate is the best way it you have a choice, though.
Robin
Knowledge is Power

seaner

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 124
  • Last login:October 21, 2003, 02:10:16 pm
    • http://www.beerbot.ca/mame
Re:4-way stick in software?
« Reply #10 on: March 22, 2003, 05:06:12 pm »
They should consider ignoring the diagonals until the previous direction is released.  This is what I did in firmware and it works great.  Anyone who is registered on the mame board might want to suggest that.

RandyT

  • Trade Count: (+14)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7013
  • Last login:July 02, 2025, 02:40:30 pm
  • Friends don't let friends hack keyboards.
    • GroovyGameGear.com
Re:4-way stick in software?
« Reply #11 on: March 22, 2003, 05:41:11 pm »
They should consider ignoring the diagonals until the previous direction is released.  This is what I did in firmware and it works great.  Anyone who is registered on the mame board might want to suggest that.

Ignoring the diagonals is essentially what the "sticky" mode does.

If I remember correctly, if you are moving left and then go to a diagonal, it still reads that you are going left.  When you break the diagonal and hit "up", it then changes to up until the next clean direction change.

In my opinion, just ignoring the diagonals would really be bad (maybe not bad, but definitely not better) in any game other than Pac-Man because all movement would cease until you hit clean directions.  Basically, one evil traded for another.

The only way to do this right is through physical restriction.

RandyT

seaner

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 124
  • Last login:October 21, 2003, 02:10:16 pm
    • http://www.beerbot.ca/mame
Re:4-way stick in software?
« Reply #12 on: March 22, 2003, 08:35:32 pm »
In my opinion, just ignoring the diagonals would really be bad (maybe not bad, but definitely not better) in any game other than Pac-Man because all movement would cease until you hit clean directions.  Basically, one evil traded for another.

Perhaps I didn't phrase it well enough... see the following progression for what I did. (this may or may not be how mame does it in s/w)

stick           reported
------          ------------
east           east
northeast   east
north          north
northwest   north
west           west
....
it's just selective masking.  while any direction is asserted, its adjacent diagonals are masked until the initial direction is released.

_Iz-

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 702
  • Last login:Yesterday at 08:55:13 pm
  • Time to coin up!
Re:4-way stick in software?
« Reply #13 on: March 22, 2003, 10:29:08 pm »
From what I understand from reading the mame source code, mame does it exactly backwards to this. If you're going left and move into an upper left diagonal, mame drops the left and immediately gives you up instead. With an 8-way stick with huge diagonals this can be very annoying. (drives me crazy on mine).

RandyT

  • Trade Count: (+14)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7013
  • Last login:July 02, 2025, 02:40:30 pm
  • Friends don't let friends hack keyboards.
    • GroovyGameGear.com
Re:4-way stick in software?
« Reply #14 on: March 23, 2003, 12:49:26 am »
[
Perhaps I didn't phrase it well enough... see the following progression for what I did. (this may or may not be how mame does it in s/w)

stick           reported
------          ------------
east           east
northeast   east
north          north
northwest   north
west           west
....
it's just selective masking.  while any direction is asserted, its adjacent diagonals are masked until the initial direction is released.

You have just described the "old" sticky mode according to the latest source.  It should probably be noted that this mode was removed because it was driving people to recompile to get rid of it :).

It appears that this has been replaced with code that does what Iz described.

The big problem here is that no hardware or software can read minds (yet :) ).  No code is ever going to be able to know whether you meant to go up or just accidentally drifted off from left and made a diagonal.

Lots of folks have thought long and hard about how to do this in code (and even in hardware!), with little coming from the effort.  This is why Oscar has physical restrictors for sale :).

That doesn't mean that you have no chance of coming up with a solution no-one else has thought of, just that it's probably not too likely at this stage of the game.

RandyT

skirge66

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 181
  • Last login:June 03, 2003, 06:25:58 am
  • the stupid will normally punish themselves
Re:4-way stick in software?
« Reply #15 on: March 24, 2003, 06:11:01 am »
just curious, why electronicly? it seems that a cool way to go would be by using restrictor plates from oscar controls, it looks like you could tap 4 mounting holes around the 8 way stick and get yourself a 4way diaganal, straight 4way, and a 2 way restrictor (place it vertical or horizontal). it sounds like they can be removed and switched out if you do it right, please correct me if i'm wrong.
skirge66

Diplomacy is the art of saying "nice doggy" until you find a bigger rock to throw

Wade

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1639
  • Last login:June 02, 2025, 11:48:57 pm
  • 80's Child
    • Wade's Gameroom
Re:4-way stick in software?
« Reply #16 on: March 24, 2003, 02:17:22 pm »
You might also consider some of the switchable sticks from Ultimarc.  After using the ball top J-sticks in 4-way for a couple of days I'm pretty happy with them.

I noticed when watching the joysticks from underneath in 4-way mode, when going from one direction to another, the "click" of one microswitch opening is almost perfectly timed with the other switch closing.  Most of the time it sounds like one click, even when moving from one direction to another slowly.  This makes me think the restrictors on the bottom are working as they are supposed to.

We have been playing 4-way games almost exclusively and I haven't experienced any of the "stuck in a diagonal" stuff that some people mention.  Granted, it has only been a couple of days, but my initial concerns about the whole 4/8 way issue have been put to rest.

Wade

seaner

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 124
  • Last login:October 21, 2003, 02:10:16 pm
    • http://www.beerbot.ca/mame
Re:4-way stick in software?
« Reply #17 on: March 24, 2003, 09:34:42 pm »
Oh, I decided to do up a firmware solution because that costs me nothing but an hour of work, and it works perfectly for me.  I didn't want a solution that would require me to open up the control panel and fiddle around inside, unless a restrictor plate is something that goes on the outside of the panel.

u_rebelscum

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3633
  • Last login:April 21, 2010, 03:06:26 pm
  • You rebel scum
    • Mame:Analog+
Re:4-way stick in software?
« Reply #18 on: March 25, 2003, 02:12:57 am »
Perhaps I didn't phrase it well enough... see the following progression for what I did. (this may or may not be how mame does it in s/w)

stick           reported
------          ------------
east           east
northeast   east
north          north
northwest   north
west           west
....
it's just selective masking.  while any direction is asserted, its adjacent diagonals are masked until the initial direction is released.

You have just described the "old" sticky mode according to the latest source.

That's not sticky mode.  Mame sticky mode way was: if push N, mame keeps sending North until N is not pressed.  So, pressing N then NW or NE is still N, and W then NW is still W.

To set up inputs as mentioned above in mame, you have to remember to put the nots ("!" in ctrlr/ini files), and recompile the stick as 8way.

So you'd want a ctrlr/ini file with something like
P1_JOYSTICK_UP          "KEYCODE_UP ! KEYCODE_RIGHT"
P1_JOYSTICK_DOWN        "KEYCODE_DOWN ! KEYCODE_LEFT"
P1_JOYSTICK_LEFT        "KEYCODE_LEFT ! KEYCODE_UP"
P1_JOYSTICK_RIGHT       "KEYCODE_RIGHT ! KEYCODE_DOWN"

Notice the "!" instead of "|".
Robin
Knowledge is Power

skirge66

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 181
  • Last login:June 03, 2003, 06:25:58 am
  • the stupid will normally punish themselves
Re:4-way stick in software?
« Reply #19 on: March 25, 2003, 06:50:04 am »
Oh, I decided to do up a firmware solution because that costs me nothing but an hour of work, and it works perfectly for me.  I didn't want a solution that would require me to open up the control panel and fiddle around inside, unless a restrictor plate is something that goes on the outside of the panel.

unless i am wrong as i occasionaly am ::)...i beleive a restrictor plate can be installed external to the control panel... take a look at supercade, right below the bezel in his pic i beleive those are his 4way and dagonal restrictor plates that are removed.
skirge66

Diplomacy is the art of saying "nice doggy" until you find a bigger rock to throw

RandyT

  • Trade Count: (+14)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7013
  • Last login:July 02, 2025, 02:40:30 pm
  • Friends don't let friends hack keyboards.
    • GroovyGameGear.com
Re:4-way stick in software?
« Reply #20 on: March 25, 2003, 07:38:28 am »
Quote
That's not sticky mode.

So what exactly is the difference between:

"while any direction is asserted, its adjacent diagonals are masked until the initial direction is released."

and

"if push N, mame keeps sending North until N is not pressed.  So, pressing N then NW or NE is still N, and W then NW is still W."

 :)

RandyT

u_rebelscum

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3633
  • Last login:April 21, 2010, 03:06:26 pm
  • You rebel scum
    • Mame:Analog+
Re:4-way stick in software?
« Reply #21 on: March 25, 2003, 07:46:20 pm »
Quote
That's not sticky mode.

So what exactly is the difference between:

"while any direction is asserted, its adjacent diagonals are masked until the initial direction is released."

and

"if push N, mame keeps sending North until N is not pressed.  So, pressing N then NW or NE is still N, and W then NW is still W."

Ah, misunderstanding: His example he shows in the table doesn't match his summary.  I was going off the table, you were going off the summary.

His table is selective, sticky mode isn't.  A better summary sentence:
"While a direction is asserted, one of its adjacent diagonals is masked until the initial direction is released.  All directions masks are either clockwise or counter-clockwise from the direction."

But that's two sentences, and not as as summary. ;)

Robin
Knowledge is Power

RandyT

  • Trade Count: (+14)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7013
  • Last login:July 02, 2025, 02:40:30 pm
  • Friends don't let friends hack keyboards.
    • GroovyGameGear.com
Re:4-way stick in software?
« Reply #22 on: March 25, 2003, 08:12:32 pm »
Quote
That's not sticky mode.

So what exactly is the difference between:

"while any direction is asserted, its adjacent diagonals are masked until the initial direction is released."

and

"if push N, mame keeps sending North until N is not pressed.  So, pressing N then NW or NE is still N, and W then NW is still W."

Ah, misunderstanding: His example he shows in the table doesn't match his summary.  I was going off the table, you were going off the summary.

His table is selective, sticky mode isn't.  A better summary sentence:
"While a direction is asserted, one of its adjacent diagonals is masked until the initial direction is released.  All directions masks are either clockwise or counter-clockwise from the direction."

But that's two sentences, and not as as summary. ;)



Not trying to be nitpicky, but in seaner's defense, he called it out as a progression, not a table.  As a progression, it's pretty clear what he meant.

But no bigee :)

RandyT

u_rebelscum

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3633
  • Last login:April 21, 2010, 03:06:26 pm
  • You rebel scum
    • Mame:Analog+
Re:4-way stick in software?
« Reply #23 on: March 25, 2003, 10:23:44 pm »
Not trying to be nitpicky, but in seaner's defense, he called it out as a progression, not a table.  As a progression, it's pretty clear what he meant.

You right.  I thought it was a table for some reason.  :-[  
Maybe I thought that because I set up mame that way, and it works much better than either sticky keys or mame's current 4way; a little "twisted" (~23.5 degrees off vertical), but not too sensitive, not too slow. [hides head] ;)

Going to get me a restrictor plate for better play at some point, though.
Robin
Knowledge is Power

seaner

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 124
  • Last login:October 21, 2003, 02:10:16 pm
    • http://www.beerbot.ca/mame
Re:4-way stick in software?
« Reply #24 on: March 25, 2003, 11:16:54 pm »
hehe.. not to flog a dead horse here, but the implementation is more along the lines of:

- 4 bits per nibble to represent a joystick
- if any 2 bits are asserted, mask off the new inputs and replace the 2 bits with the previous 2 bit value from that position:

or:

if ((newinput & 0x3)==0x3)
  newinput = (newinput & 0x3) | (oldinput & 0x3);
... repeat for mask of 0x6, 0xc, 0x9
oldinput = newinput;

I'm curious why u_rebelscum is having a problem with the alignment from center though.. off by 23.5 degrees?  Is this due to the fact that the levers on the microswitches extend at a slight angle from vertical or horizontal?  I've noticed a similar problem.. I may solve it by just giving the ends of the metal springs a minor bend.  This of course isn't a 4-way/8-way problem, it's a problem in general I've noticed with at least one of my x-arcade sticks.

u_rebelscum

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3633
  • Last login:April 21, 2010, 03:06:26 pm
  • You rebel scum
    • Mame:Analog+
Re:4-way stick in software?
« Reply #25 on: March 26, 2003, 11:50:47 pm »
I'm curious why u_rebelscum is having a problem with the alignment from center though.. off by 23.5 degrees?

For 4way games I play, I recompiled them as 8way and mapped mame (with ctrlr/ini files) so:

stick
-------
game
sees
------------
upup
up/leftup
leftleft
down/leftleft
downdown
down/rightdown
rightright
up/rightright

Notice how each diagonal always translates to one and only one cardinal direction.  Assuming diagonal and cardinal directions are the same size and diagonal = 45 degrees off of a cardinal direction, the midpoint between a cardinal direction and its mapped diagonal its 22.5 degrees (mistyped as 23.5 earlier post).  Each direction has definite boundaries.

On my super joysticks it's no biggie, but on my competition joysticks I can feel the stant.  If I wanted to, I could have mounted the cardinal sticks at 45 degrees, map the diagonals as game up,down, left, right, and used mame's current 4way method to have a much better feel, but if I was to do that, I'd might as well go all the way and buy a true 4way stick.
Robin
Knowledge is Power