* fix forcefeedback. It works now, albeit it slow down the emulation...
* Add an option hack for ds3 usb drivers


git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4750 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut@gmail.com 2011-06-19 16:13:41 +00:00
parent d726be3364
commit f682a8337c
4 changed files with 50 additions and 28 deletions

View File

@ -399,7 +399,6 @@ void on_toggle_option(GtkToggleButton *togglebutton, gpointer user_data)
conf->options &= ~checkbox->mask; conf->options &= ~checkbox->mask;
} }
void joy_changed(GtkComboBox *box, gpointer user_data) void joy_changed(GtkComboBox *box, gpointer user_data)
{ {
int joyid = gtk_combo_box_get_active(box); int joyid = gtk_combo_box_get_active(box);
@ -490,7 +489,7 @@ button_positions b_pos[MAX_KEYS] =
}; };
// Warning position is important and must match the order of the PadOptions structure // Warning position is important and must match the order of the PadOptions structure
button_positions check_pos[7] = button_positions check_pos[8] =
{ {
{ "Enable force feedback", 40, 400}, { "Enable force feedback", 40, 400},
{ "Reverse Lx", 40, 304}, { "Reverse Lx", 40, 304},
@ -498,7 +497,8 @@ button_positions check_pos[7] =
{ "Reverse Rx", 368, 304}, { "Reverse Rx", 368, 304},
{ "Reverse Ry", 368, 328}, { "Reverse Ry", 368, 328},
{ "Use mouse for left analog joy", 40, 352}, { "Use mouse for left analog joy", 40, 352},
{ "Use mouse for right analog joy", 368,352}, { "Use mouse for right analog joy", 368, 352},
{ "Hack: Sixaxis/DS3 plugged in USB", 368, 400}
}; };
GtkWidget *create_notebook_page_dialog(int page, dialog_buttons btn[MAX_KEYS], dialog_checkbox checkbox[7]) GtkWidget *create_notebook_page_dialog(int page, dialog_buttons btn[MAX_KEYS], dialog_checkbox checkbox[7])
@ -567,7 +567,7 @@ GtkWidget *create_notebook_page_dialog(int page, dialog_buttons btn[MAX_KEYS], d
} }
u32 mask = 1 << (16*page); u32 mask = 1 << (16*page);
for(int i = 0; i < 7; i++) { for(int i = 0; i < 8; i++) {
checkbox[i].create(keys_static_area, check_pos[i].label, check_pos[i].x, check_pos[i].y, mask); checkbox[i].create(keys_static_area, check_pos[i].label, check_pos[i].x, check_pos[i].y, mask);
mask = mask << 1; mask = mask << 1;
} }

View File

@ -128,17 +128,17 @@ void JoystickInfo::InitHapticEffect()
haptic_effect_data[0].periodic.direction.dir[0] = 18000; // Force comes from south haptic_effect_data[0].periodic.direction.dir[0] = 18000; // Force comes from south
// periodic parameter // periodic parameter
haptic_effect_data[0].periodic.period = 1000; // 1000 ms haptic_effect_data[0].periodic.period = 200; // 200 ms
haptic_effect_data[0].periodic.magnitude = 2000; // 2000/32767 strength haptic_effect_data[0].periodic.magnitude = 2000; // 2000/32767 strength
// Replay // Replay
haptic_effect_data[0].periodic.length = 2000; // 2 seconds long haptic_effect_data[0].periodic.length = 1000; // 1 seconds long
haptic_effect_data[0].periodic.delay = 0; // start 0 second after the upload haptic_effect_data[0].periodic.delay = 0; // start 0 second after the upload
// enveloppe // enveloppe
haptic_effect_data[0].periodic.attack_length = 500;// Takes 0.5 second to get max strength haptic_effect_data[0].periodic.attack_length = 100;// Takes 0.1 second to get max strength
haptic_effect_data[0].periodic.attack_level = 0; // start at 0 haptic_effect_data[0].periodic.attack_level = 0; // start at 0
haptic_effect_data[0].periodic.fade_length = 500; // Takes 0.5 second to fade away haptic_effect_data[0].periodic.fade_length = 100; // Takes 0.1 second to fade away
haptic_effect_data[0].periodic.fade_level = 0; // finish at 0 haptic_effect_data[0].periodic.fade_level = 0; // finish at 0
/*******************************************************************/ /*******************************************************************/
@ -151,17 +151,17 @@ void JoystickInfo::InitHapticEffect()
haptic_effect_data[1].periodic.direction.dir[0] = 18000; // Force comes from south haptic_effect_data[1].periodic.direction.dir[0] = 18000; // Force comes from south
// periodic parameter // periodic parameter
haptic_effect_data[1].periodic.period = 1000; // 1000 ms haptic_effect_data[1].periodic.period = 200; // 200 ms
haptic_effect_data[1].periodic.magnitude = 2000; // 2000/32767 strength haptic_effect_data[1].periodic.magnitude = 2000; // 2000/32767 strength
// Replay // Replay
haptic_effect_data[1].periodic.length = 2000; // 2 seconds long haptic_effect_data[1].periodic.length = 1000; // 1 seconds long
haptic_effect_data[1].periodic.delay = 0; // start 0 second after the upload haptic_effect_data[1].periodic.delay = 0; // start 0 second after the upload
// enveloppe // enveloppe
haptic_effect_data[1].periodic.attack_length = 500;// Takes 0.5 second to get max strength haptic_effect_data[1].periodic.attack_length = 100;// Takes 0.1 second to get max strength
haptic_effect_data[1].periodic.attack_level = 0; // start at 0 haptic_effect_data[1].periodic.attack_level = 0; // start at 0
haptic_effect_data[1].periodic.fade_length = 500; // Takes 0.5 second to fade away haptic_effect_data[1].periodic.fade_length = 100; // Takes 0.1 second to fade away
haptic_effect_data[1].periodic.fade_level = 0; // finish at 0 haptic_effect_data[1].periodic.fade_level = 0; // finish at 0
/*******************************************************************/ /*******************************************************************/
@ -172,31 +172,26 @@ void JoystickInfo::InitHapticEffect()
#endif #endif
} }
void JoystickInfo::DoHapticEffect(int type, int pad, int force) void JoystickInfo::DoHapticEffect(int type, int pad, int force)
{ {
if (type > 1) return; if (type > 1) return;
if ( !(conf->options & (PADOPTION_FORCEFEEDBACK << 16 * pad)) ) return; if ( !(conf->options & (PADOPTION_FORCEFEEDBACK << 16 * pad)) ) return;
#if SDL_VERSION_ATLEAST(1,3,0) #if SDL_VERSION_ATLEAST(1,3,0)
// first search the joy associated to the pad int joyid = conf->get_joyid(pad);
vector<JoystickInfo*>::iterator itjoy = s_vjoysticks.begin(); if (!JoystickIdWithinBounds(joyid)) return;
while (itjoy != s_vjoysticks.end()) { JoystickInfo* pjoy = s_vjoysticks[joyid];
if ((*itjoy)->GetPAD() == pad) break;
itjoy++;
}
if (itjoy == s_vjoysticks.end()) return; if (pjoy->haptic == NULL) return;
if ((*itjoy)->haptic == NULL) return; if (pjoy->haptic_effect_id[type] < 0) return;
if ((*itjoy)->haptic_effect_id[type] < 0) return;
// FIXME: might need to multiply force // FIXME: might need to multiply force
(*itjoy)->haptic_effect_data[type].periodic.magnitude = force; // force/32767 strength pjoy->haptic_effect_data[type].periodic.magnitude = force; // force/32767 strength
// Upload the new effect // Upload the new effect
SDL_HapticUpdateEffect((*itjoy)->haptic, (*itjoy)->haptic_effect_id[type], &(*itjoy)->haptic_effect_data[type]); SDL_HapticUpdateEffect(pjoy->haptic, pjoy->haptic_effect_id[type], &pjoy->haptic_effect_data[type]);
// run the effect once // run the effect once
SDL_HapticRunEffect( (*itjoy)->haptic, (*itjoy)->haptic_effect_id[type], 1 ); SDL_HapticRunEffect( pjoy->haptic, pjoy->haptic_effect_id[type], 1 );
#endif #endif
} }
@ -238,6 +233,18 @@ bool JoystickInfo::Init(int id)
vbuttonstate.resize(numbuttons); vbuttonstate.resize(numbuttons);
vhatstate.resize(numhats); 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;
// Enable this hack is bluetooth too. It avoid to restart the onepad gui
numbuttons += 4;
}
#if SDL_VERSION_ATLEAST(1,3,0) #if SDL_VERSION_ATLEAST(1,3,0)
if ( haptic == NULL ) { if ( haptic == NULL ) {
if (!SDL_JoystickIsHaptic(joy)) { if (!SDL_JoystickIsHaptic(joy)) {
@ -300,8 +307,20 @@ bool JoystickInfo::PollAxes(u32 &pkey)
{ {
for (int i = 0; i < GetNumAxes(); ++i) for (int i = 0; i < GetNumAxes(); ++i)
{ {
int value = SDL_JoystickGetAxis(GetJoy(), i); // Sixaxis, dualshock3 hack
int old_value = GetAxisState(i); 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
if (i >= 8 && i <= 11 && (conf->options & PADOPTION_SIXAXIS_USB))
continue;
// Disable accelerometer
if ((i >= 4 && i <= 6))
continue;
}
s32 value = SDL_JoystickGetAxis(GetJoy(), i);
s32 old_value = GetAxisState(i);
if (value != old_value) if (value != old_value)
{ {

View File

@ -139,7 +139,9 @@ class JoystickInfo
{ {
return joy; return joy;
} }
int GetAxisFromKey(int pad, int index); int GetAxisFromKey(int pad, int index);
private: private:
string devname; // pretty device name string devname; // pretty device name
int _id; int _id;

View File

@ -70,7 +70,8 @@ enum PadOptions
PADOPTION_REVERSERX = 0x8, PADOPTION_REVERSERX = 0x8,
PADOPTION_REVERSERY = 0x10, PADOPTION_REVERSERY = 0x10,
PADOPTION_MOUSE_L = 0x20, PADOPTION_MOUSE_L = 0x20,
PADOPTION_MOUSE_R = 0x40 PADOPTION_MOUSE_R = 0x40,
PADOPTION_SIXAXIS_USB = 0x80
}; };
extern FILE *padLog; extern FILE *padLog;