when a button with an index of >=320 is pressed, its SDL_JOYBUTTONUP event is not handled properly due to a typo in linux/sdllink.c: ("256+64" instead of "256+128+64"). The patch fixes the wrong constant and also replaces all occurences of the constant in question (448) with a macro (BTNCOUNT).
Alternately, you could just fix the typo

Code: Select all
--- zsnes-1.420/src/linux/sdllink.c 2005-01-14 13:11:18.000000000 +0000
+++ zsnes-1.420.new/src/linux/sdllink.c 2006-07-20 20:35:00.973981134 +0000
@@ -89,11 +89,12 @@
extern BYTE GUIHQ4X[];
/* JOYSTICK AND KEYBOARD INPUT */
+#define BTNCOUNT (448)
SDL_Joystick *JoystickInput[5];
-unsigned int AxisOffset[5] = {256 + 128 + 64}; // per joystick offsets in
-unsigned int ButtonOffset[5] = {448}; // pressed. We have 128 + 64
-unsigned int HatOffset[5] = {448}; // bytes for all joysticks. We
-unsigned int BallOffset[5] = {448}; // can control all 5 players.
+unsigned int AxisOffset[5] = {BTNCOUNT}; // per joystick offsets in
+unsigned int ButtonOffset[5] = {BTNCOUNT}; // pressed. We have 128 + 64
+unsigned int HatOffset[5] = {BTNCOUNT}; // bytes for all joysticks. We
+unsigned int BallOffset[5] = {BTNCOUNT}; // can control all 5 players.
int shiftptr = 0;
int offset;
DWORD numlockptr;
@@ -263,7 +264,7 @@
case SDL_JOYHATMOTION: // POV hats act as direction pad
offset = HatOffset[event.jhat.which];
- if (offset >= (256 + 128 + 64)) break;
+ if (offset >= BTNCOUNT) break;
switch (event.jhat.value)
{
case SDL_HAT_CENTERED:
@@ -323,7 +324,7 @@
case SDL_JOYBALLMOTION:
offset = BallOffset[event.jball.which];
offset += event.jball.ball;
- if (offset >= (256 + 128 + 64)) break;
+ if (offset >= BTNCOUNT) break;
if (event.jball.xrel < -100)
{
pressed[offset] = 0;
@@ -349,7 +350,7 @@
case SDL_JOYAXISMOTION:
offset = AxisOffset[event.jaxis.which];
offset += event.jaxis.axis * 2;
- if (offset >= (256 + 128 + 64)) break;
+ if (offset >= BTNCOUNT) break;
// printf("DEBUG axis offset: %d\n", offset);
if (event.jaxis.value < -16384)
{
@@ -372,7 +373,7 @@
offset = ButtonOffset[event.jbutton.which];
offset += event.jbutton.button;
// printf("DEBUG button offset: %d\n", offset);
- if (offset >= (256 + 128 + 64)) break;
+ if (offset >= BTNCOUNT) break;
pressed[offset] = 1;
break;
@@ -380,7 +381,7 @@
offset = ButtonOffset[event.jbutton.which];
offset += event.jbutton.button;
// printf("DEBUG button offset: %d\n", offset);
- if (offset >= (256 + 64)) break;
+ if (offset >= BTNCOUNT) break;
pressed[offset] = 0;
break;
case SDL_QUIT:
@@ -642,7 +643,7 @@
// 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))
+ if ((BallOffset[0] + num_balls * 4) >= BTNCOUNT)
js_fail = 1;
}
else
@@ -652,7 +653,7 @@
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))
+ if ((BallOffset[i] + num_balls * 4) >= BTNCOUNT)
js_fail = 1;
}