onepad: add an option to workaround DS3 issue with SDL2

I don't understand the magic but sometimes pad buttons are detected as buttons
sometimes as axis. Create an option so people can test both and hopefully find a working solution

Note: you need to restart the plugin to take the option into account
Note2: fix dual pad init too

Related issue #938 and #414
This commit is contained in:
Gregory Hainaut 2015-11-21 18:24:49 +01:00
parent a2887d1536
commit 80bdbb5f24
4 changed files with 29 additions and 22 deletions

View File

@ -475,7 +475,7 @@ button_positions b_pos[MAX_KEYS] =
};
// Warning position is important and must match the order of the PadOptions structure
#define CHECK_NBR 8
#define CHECK_NBR 9
button_positions check_pos[CHECK_NBR] =
{
{ "Enable force feedback", 40, 400},
@ -485,7 +485,8 @@ button_positions check_pos[CHECK_NBR] =
{ "Reverse Ry", 368, 328},
{ "Use mouse for left analog joy", 40, 352},
{ "Use mouse for right analog joy", 368, 352},
{ "Hack: Sixaxis/DS3 plugged in USB", 368, 400}
{ "Hack: Sixaxis/DS3 plugged in USB", 368, 400},
{ "Hack: Sixaxis/DS3 pressure", 368, 424}
};
GtkWidget *create_notebook_page_dialog(int page, dialog_buttons btn[MAX_KEYS], dialog_checkbox checkbox[CHECK_NBR])

View File

@ -203,7 +203,10 @@ bool JoystickInfo::Init(int id)
// 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 && numaxes > 4) {
// FIXME: people need to restart the plugin to take the option into account.
bool hack_enabled = (conf->pad_options[0].sixaxis_pressure) || (conf->pad_options[1].sixaxis_pressure);
if (found_hack != string::npos && numaxes > 4 && hack_enabled) {
fprintf(stderr, "ONEPAD HACK IS enabled");
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
@ -276,10 +279,11 @@ bool JoystickInfo::PollButtons(u32 &pkey)
bool JoystickInfo::PollAxes(u32 &pkey)
{
u32 found_hack = devname.find(string("PLAYSTATION(R)3"));
for (int i = 0; i < GetNumAxes(); ++i)
{
// Sixaxis, dualshock3 hack
u32 found_hack = devname.find(string("PLAYSTATION(R)3"));
if (found_hack != string::npos) {
// The analog mode of the hat button is quite erratic. Values can be in half- axis
// or full axis... So better keep them as button for the moment -- gregory

View File

@ -61,15 +61,16 @@ class PADconf
public:
union {
struct {
u32 forcefeedback :1;
u32 reverse_lx :1;
u32 reverse_ly :1;
u32 reverse_rx :1;
u32 reverse_ry :1;
u32 mouse_l :1;
u32 mouse_r :1;
u32 sixaxis_usb :1;
u32 _free : 8; // The 8 remaining bits are unused, do what you wish with them ;)
u16 forcefeedback :1;
u16 reverse_lx :1;
u16 reverse_ly :1;
u16 reverse_rx :1;
u16 reverse_ry :1;
u16 mouse_l :1;
u16 mouse_r :1;
u16 sixaxis_usb :1;
u16 sixaxis_pressure :1;
u16 _free : 7; // The 8 remaining bits are unused, do what you wish with them ;)
} pad_options[2]; // One for each pads
u32 packed_options; // Only first 8 bits of each 16 bits series are really used, rest is padding
};

View File

@ -62,14 +62,15 @@ using namespace std;
enum PadOptions
{
PADOPTION_FORCEFEEDBACK = 0x1,
PADOPTION_REVERSELX = 0x2,
PADOPTION_REVERSELY = 0x4,
PADOPTION_REVERSERX = 0x8,
PADOPTION_REVERSERY = 0x10,
PADOPTION_MOUSE_L = 0x20,
PADOPTION_MOUSE_R = 0x40,
PADOPTION_SIXAXIS_USB = 0x80
PADOPTION_FORCEFEEDBACK = 0x1,
PADOPTION_REVERSELX = 0x2,
PADOPTION_REVERSELY = 0x4,
PADOPTION_REVERSERX = 0x8,
PADOPTION_REVERSERY = 0x10,
PADOPTION_MOUSE_L = 0x20,
PADOPTION_MOUSE_R = 0x40,
PADOPTION_SIXAXIS_USB = 0x80,
PADOPTION_SIXAXIS_PRESSURE = 0x100
};
extern FILE *padLog;