Max supported amount of buttons?

Gamepad acting up? Keyboard not responding properly? Can't get that other user to work? Read and post about it here.

Moderator: ZSNES Mods

Post Reply
tehnick
Hazed
Posts: 52
Joined: Wed Oct 06, 2004 1:41 am

Max supported amount of buttons?

Post by tehnick »

I have 2 controllers that are 16 buttons each + the dpad which accounts for another 4. That's about 40 buttons or so. For some reason when I configure my controllers under ZSNES, some identifiers are being used more then once which causes many problems with playing anything co-op. Say for example: I press right on 1P controller to move and then player 2's character would jump, because they are both set to the same one.

While playing an alternating 2P game this problem is not there because the 2nd player would obviously not respond while player 1 is playing.

I've tested this on CVS, 1.42 and 1.36

At first I assumed it was maybe the way it was configured with udev or whatever, so I tested it in jscalibrator and none of the buttons seem to be controlling anything it shouldn't be so I'm pretty sure this is a problem with ZSNES. I'm running the SDL linux version, btw.
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

If the two controllers happen to be the same, then that would probably be the issue. I'm not sure what can actually be done with this.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
spoon0042
Rookie
Posts: 46
Joined: Mon Jun 12, 2006 9:52 pm

Post by spoon0042 »

This probably isn't related to his problem, but there does seem to be a bug in sdllink.c that would cause two joysticks to overlap if the first has any trackballs; the number of balls should be multiplied by 4 in these lines:

Code: Select all

      AxisOffset[i] = BallOffset[i - 1] +
        SDL_JoystickNumBalls(JoystickInput[i - 1]);
This patch fixes that as well as cleans up the code a bit.

Code: Select all

--- sdllink.c.orig      2006-09-21 09:59:49.000000000 -0400
+++ sdllink.c   2006-09-26 23:11:52.000000000 -0400
@@ -761,7 +761,7 @@
 {
   int i, max_num_joysticks;
   int num_axes, num_buttons, num_hats, num_balls;
-  int js_fail = 0;
+  int next_offset = 256;
 
   for (i = 0; i < 5; i++)
     JoystickInput[i] = NULL;
@@ -792,35 +792,19 @@
     printf("  %i axis, %i buttons, %i hats, %i balls\n",
       num_axes, num_buttons, num_hats, num_balls);

-    if (js_fail)
+    if (next_offset >= 448)
     {
       printf("Warning: Joystick won't work.\n");
       continue;
     }
-    if (i == 0)
-    {
-      AxisOffset[0] = 256;    // After key data
-      ButtonOffset[0] = AxisOffset[0] + num_axes * 2;
-//      printf("ButtonOffset %d\n", ButtonOffset[0]);
-      HatOffset[0] = ButtonOffset[0] + num_buttons;
-//      printf("HatOffset %d\n", HatOffset[0]);
-      BallOffset[0] = HatOffset[0] + num_hats * 4;
-//      printf("BallOffset %d\n", BallOffset[0]);
-      if ((BallOffset[0] + num_balls * 4) >= (256 + 128 + 64))
-        js_fail = 1;
-    }
-    else
-    {
-      AxisOffset[i] = BallOffset[i - 1] +
-        SDL_JoystickNumBalls(JoystickInput[i - 1]);
-      ButtonOffset[i] = AxisOffset[i] + num_axes * 2;
-      HatOffset[i] = ButtonOffset[i] + num_buttons;
-      BallOffset[i] = HatOffset[i] + num_hats * 4;
-      if ((BallOffset[i] + num_balls * 4) >= (256 + 128 + 64))
-        js_fail = 1;
 
-    }
-    if (js_fail)
+    AxisOffset[i] = next_offset; 
+    ButtonOffset[i] = AxisOffset[i] + num_axes * 2;
+    HatOffset[i] = ButtonOffset[i] + num_buttons;
+    BallOffset[i] = HatOffset[i] + num_hats * 4;
+    next_offset = BallOffset[i] + num_balls * 4;
+
+    if (next_offset > (256 + 128 + 64))
     { 
       printf("Warning: Too many buttons, axes, hats and/or Balls!\n");
       printf("Warning: Joystick won't work fully.\n");
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

spoon0042 wrote:This probably isn't related to his problem, but there does seem to be a bug in sdllink.c that would cause two joysticks to overlap if the first has any trackballs; the number of balls should be multiplied by 4 in these lines:
Does anything similar occur in winlink.cpp? IIRC, there was a similar post that happened to a guy in the Windows port...
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
spoon0042
Rookie
Posts: 46
Joined: Mon Jun 12, 2006 9:52 pm

Post by spoon0042 »

No, it looks different. It looks like there's a fixed number of buttons for each joystick.
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

Ok. I just wondered. I'll see what others think of the patch first though. Thanks for looking at it.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

Ok, the code was committed and is in SVN.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
Post Reply