I ran into the same problem and fixed it by removing a dualshock 3 hack in the onepad implementation. I don't believe the hack is needed any more as it prevents buttons with ids greater than 7 from being used. The linux 3.8.1 kernel assigns the following ids to the following buttons and axes when plugged in via usb.
Code:
Axes:
0 LeftStick LeftRight
1 LeftStick UpDown
2 RightStick LeftRight
3 RightStick UpDown
8 Dpad Up
9 Dpad Right
10 Dpad Down
11 Dpad Left? (this axis didn't work with jstest)
12 L2
13 R2
14 L1
15 R1
16 Triangle
17 Circle
18 X
19 Square
Buttons:
0 Select
1 L3
2 R3
3 Select
4 Dpad Up
5 Dpad Right
6 Dpad Down
7 Dpad Left
8 L2
9 R2
10 L1
11 R1
12 Triangle
13 Circle
14 X
15 Square
16 PS
I used the following patch to fix the problem:
Code:
--- plugins/onepad/joystick.original 2015-07-21 16:35:59.919844680 -0500
+++ plugins/onepad/joystick.cpp 2015-07-21 16:36:15.435844135 -0500
@@ -212,19 +212,6 @@
vbuttonstate.resize(numbuttons);
vhatstate.resize(numhats);
- // Sixaxis, dualshock3 hack
- // Most buttons are actually axes due to analog pressure support. Only the first 4 buttons
- // are digital (select, start, l3, r3). To avoid conflict just forget the others.
- // Keep the 4 hat buttons too (usb driver). (left pressure does not work with recent kernel). Moreover the pressure
- // work sometime on half axis neg others time in fulll axis. So better keep them as button for the moment
- u32 found_hack = devname.find(string("PLAYSTATION(R)3"));
- if (found_hack != string::npos) {
- numbuttons = 4; // (select, start, l3, r3)
- // Enable this hack in bluetooth too. It avoid to restart the onepad gui
- numbuttons += 4; // the 4 hat buttons
- }
-
#if SDL_MAJOR_VERSION >= 2
if ( haptic == NULL ) {
if (!SDL_JoystickIsHaptic(joy)) {
I also had a problem with my left stick left and right not working. You didn't mention this problem but I tracked it down to an issue with sdl, which exists in 1.2 and 2.0. I'll be submitting this patch to the sdl project as well, but this may help anyone doing a google search in the meantime.
Code:
--- src/joystick/linux/SDL_sysjoystick.original 2015-07-21 16:28:02.939861444 -0500
+++ src/joystick/linux/SDL_sysjoystick.c 2015-07-21 16:26:43.162864247 -0500
@@ -826,6 +826,7 @@
return(-1);
}
SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
+ SDL_memset(joystick->hwdata->abs_map, ABS_MAX, sizeof(*joystick->hwdata->abs_map)*ABS_MAX);
joystick->hwdata->fd = fd;
/* Set the joystick to non-blocking read mode */
@@ -1120,15 +1121,17 @@
events[i].value);
break;
default:
- events[i].value = EV_AxisCorrect(joystick, code, events[i].value);
+ if (joystick->hwdata->abs_map[code] != ABS_MAX ) {
+ events[i].value = EV_AxisCorrect(joystick, code, events[i].value);
#ifndef NO_LOGICAL_JOYSTICKS
- if (!LogicalJoystickAxis(joystick,
- joystick->hwdata->abs_map[code],
- events[i].value))
+ if (!LogicalJoystickAxis(joystick,
+ joystick->hwdata->abs_map[code],
+ events[i].value))
#endif
- SDL_PrivateJoystickAxis(joystick,
- joystick->hwdata->abs_map[code],
- events[i].value);
+ SDL_PrivateJoystickAxis(joystick,
+ joystick->hwdata->abs_map[code],
+ events[i].value);
+ }
break;
}
break;
Edit:
It occurs to me after reading the removed comment in the onepad patch, that this is perhaps not the best way to solve the problem as you would not get the pressure value this way. I will take a second look and see if I can get the axis for the pressure buttons working. Perhaps its another sdl bug.
Edit2:
Further research shows that linux's evdev reports only 4 axes to sdl, two for each stick. Since the games I'm interested in don't use the pressure feature of the dualshock, i don't have the desire to trace through the evdev code to find out why the axes for the buttons aren't reported. My original patch stands; maybe it can be toggled with a check box like the current dpad hack.