Skip to content

Commit

Permalink
Allow inversion of FFB direction #455
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Laurendeau committed May 22, 2017
1 parent da86066 commit 216865e
Show file tree
Hide file tree
Showing 29 changed files with 1,429 additions and 358 deletions.
106 changes: 106 additions & 0 deletions config/gimx-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ const long configFrame::ID_BUTTON16 = wxNewId();
const long configFrame::ID_BUTTON17 = wxNewId();
const long configFrame::ID_BUTTON18 = wxNewId();
const long configFrame::ID_PANEL7 = wxNewId();
const long configFrame::ID_STATICTEXT13 = wxNewId();
const long configFrame::ID_STATICTEXT20 = wxNewId();
const long configFrame::ID_STATICTEXT25 = wxNewId();
const long configFrame::ID_STATICTEXT49 = wxNewId();
const long configFrame::ID_BUTTON20 = wxNewId();
const long configFrame::ID_STATICLINE13 = wxNewId();
const long configFrame::ID_CHECKBOX2 = wxNewId();
const long configFrame::ID_STATICLINE15 = wxNewId();
const long configFrame::ID_BUTTON24 = wxNewId();
const long configFrame::ID_PANEL8 = wxNewId();
const long configFrame::ID_NOTEBOOK2 = wxNewId();
const long configFrame::ID_PANEL1 = wxNewId();
const long configFrame::ID_STATICTEXT38 = wxNewId();
Expand Down Expand Up @@ -557,6 +567,7 @@ configFrame::configFrame(wxString file,wxWindow* parent, wxWindowID id __attribu
wxFlexGridSizer* FlexGridSizer51;
wxFlexGridSizer* FlexGridSizer15;
wxStaticBoxSizer* StaticBoxSizer7;
wxFlexGridSizer* FlexGridSizer56;
wxFlexGridSizer* FlexGridSizer50;
wxStaticBoxSizer* StaticBoxSizer5;
wxFlexGridSizer* FlexGridSizer17;
Expand All @@ -575,6 +586,7 @@ configFrame::configFrame(wxString file,wxWindow* parent, wxWindowID id __attribu
wxFlexGridSizer* FlexGridSizer26;
wxFlexGridSizer* FlexGridSizer14;
wxStaticBoxSizer* StaticBoxSizer3;
wxFlexGridSizer* FlexGridSizer55;
wxFlexGridSizer* FlexGridSizer6;
wxFlexGridSizer* FlexGridSizer33;
wxFlexGridSizer* FlexGridSizer38;
Expand All @@ -586,19 +598,22 @@ configFrame::configFrame(wxString file,wxWindow* parent, wxWindowID id __attribu
wxStaticBoxSizer* StaticBoxSizer8;
wxFlexGridSizer* FlexGridSizer31;
wxFlexGridSizer* FlexGridSizer43;
wxFlexGridSizer* FlexGridSizer39;
wxStaticBoxSizer* StaticBoxSizer4;
wxStaticBoxSizer* StaticBoxSizer9;
wxStaticBoxSizer* StaticBoxSizer6;
wxFlexGridSizer* FlexGridSizer16;
wxFlexGridSizer* FlexGridSizer34;
wxFlexGridSizer* FlexGridSizer23;
wxFlexGridSizer* FlexGridSizer10;
wxStaticBoxSizer* StaticBoxSizer11;
wxFlexGridSizer* FlexGridSizer13;
wxMenuBar* MenuBar1;
wxMenuItem* MenuItemAbout;
wxFlexGridSizer* FlexGridSizer53;
wxFlexGridSizer* FlexGridSizer18;
wxFlexGridSizer* FlexGridSizer49;
wxFlexGridSizer* FlexGridSizer54;
wxFlexGridSizer* FlexGridSizer36;
wxFlexGridSizer* FlexGridSizer12;
wxMenuItem* MenuItemOpen;
Expand Down Expand Up @@ -895,10 +910,45 @@ configFrame::configFrame(wxString file,wxWindow* parent, wxWindowID id __attribu
PanelJoystickCorrections->SetSizer(FlexGridSizer10);
FlexGridSizer10->Fit(PanelJoystickCorrections);
FlexGridSizer10->SetSizeHints(PanelJoystickCorrections);
PanelForceFeedback = new wxPanel(Notebook2, ID_PANEL8, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL8"));
FlexGridSizer39 = new wxFlexGridSizer(2, 1, 0, 0);
FlexGridSizer54 = new wxFlexGridSizer(1, 6, 0, 0);
StaticBoxSizer11 = new wxStaticBoxSizer(wxHORIZONTAL, PanelForceFeedback, _("Joystick"));
FlexGridSizer55 = new wxFlexGridSizer(1, 4, 0, 0);
FFBTweaksType = new wxStaticText(PanelForceFeedback, ID_STATICTEXT13, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT13"));
FFBTweaksType->Hide();
FlexGridSizer55->Add(FFBTweaksType, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FFBTweaksName = new wxStaticText(PanelForceFeedback, ID_STATICTEXT20, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT20"));
FlexGridSizer55->Add(FFBTweaksName, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FFBTweaksId = new wxStaticText(PanelForceFeedback, ID_STATICTEXT25, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT25"));
FlexGridSizer55->Add(FFBTweaksId, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FFBTweaksAxis = new wxStaticText(PanelForceFeedback, ID_STATICTEXT49, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT49"));
FFBTweaksAxis->Hide();
FlexGridSizer55->Add(FFBTweaksAxis, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticBoxSizer11->Add(FlexGridSizer55, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer54->Add(StaticBoxSizer11, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
ForceFeedbackAutoDetect = new wxButton(PanelForceFeedback, ID_BUTTON20, _("Auto detect"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON20"));
FlexGridSizer54->Add(ForceFeedbackAutoDetect, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticLine13 = new wxStaticLine(PanelForceFeedback, ID_STATICLINE13, wxDefaultPosition, wxSize(-1,50), wxLI_VERTICAL, _T("ID_STATICLINE13"));
FlexGridSizer54->Add(StaticLine13, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer56 = new wxFlexGridSizer(1, 1, 0, 0);
FFBTweaksInvert = new wxCheckBox(PanelForceFeedback, ID_CHECKBOX2, _("Invert direction"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX2"));
FFBTweaksInvert->SetValue(false);
FlexGridSizer56->Add(FFBTweaksInvert, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer54->Add(FlexGridSizer56, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticLine15 = new wxStaticLine(PanelForceFeedback, ID_STATICLINE15, wxDefaultPosition, wxSize(-1,50), wxLI_VERTICAL, _T("ID_STATICLINE15"));
FlexGridSizer54->Add(StaticLine15, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
ButtonFFBTweaksDelete = new wxButton(PanelForceFeedback, ID_BUTTON24, _("Delete"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON24"));
FlexGridSizer54->Add(ButtonFFBTweaksDelete, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer39->Add(FlexGridSizer54, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
PanelForceFeedback->SetSizer(FlexGridSizer39);
FlexGridSizer39->Fit(PanelForceFeedback);
FlexGridSizer39->SetSizeHints(PanelForceFeedback);
Notebook2->AddPage(PanelTrigger, _("Profile trigger"), false);
Notebook2->AddPage(PanelMouseOptions, _("Mouse options"), false);
Notebook2->AddPage(PanelIntensity, _("Axis intensity"), false);
Notebook2->AddPage(PanelJoystickCorrections, _("Joystick corrections"), false);
Notebook2->AddPage(PanelForceFeedback, _("Force Feedback Tweaks"), false);
GridSizer3->Add(Notebook2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
PanelOverall->SetSizer(GridSizer3);
GridSizer3->Fit(PanelOverall);
Expand Down Expand Up @@ -1258,6 +1308,8 @@ configFrame::configFrame(wxString file,wxWindow* parent, wxWindowID id __attribu
Connect(ID_BUTTON16,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&configFrame::OnJoystickCorrectionsAddClick);
Connect(ID_BUTTON17,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&configFrame::OnJoystickCorrectionsRemoveClick);
Connect(ID_BUTTON18,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&configFrame::OnJoystickCorrectionsModifyClick);
Connect(ID_BUTTON20,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&configFrame::OnButtonForceFeedbackAutoDetect);
Connect(ID_BUTTON24,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&configFrame::OnButtonFFBTweaksDelete);
Connect(ID_CHOICE4,wxEVT_COMMAND_CHOICE_SELECTED,(wxObjectEventFunction)&configFrame::OnButtonTabEventTypeSelect);
Connect(ID_BUTTON8,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&configFrame::OnButtonTabAutoDetectClick);
Connect(ID_BUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&configFrame::OnButtonAddPanelButton);
Expand Down Expand Up @@ -2131,6 +2183,11 @@ void configFrame::save_current()
string(GridJoystickCorrections->GetCellValue(i, 5).mb_str(wxConvUTF8)),
string(GridJoystickCorrections->GetCellValue(i, 6).mb_str(wxConvUTF8))));
}
//Save FFB tweaks
configuration->GetForceFeedback()->GetJoystick()->SetType(reverseTranslate(string(FFBTweaksType->GetLabel().mb_str(wxConvUTF8))));
configuration->GetForceFeedback()->GetJoystick()->SetName(ffbTweaksTabDeviceName);
configuration->GetForceFeedback()->GetJoystick()->SetId(string(FFBTweaksId->GetLabel().mb_str(wxConvUTF8)));
configuration->GetForceFeedback()->setInversion(FFBTweaksInvert->GetValue() ? "yes" : "no");
//Save ControlMappers
buttonMappers = configuration->GetButtonMapperList();
buttonMappers->erase(buttonMappers->begin(), buttonMappers->end());
Expand Down Expand Up @@ -2341,6 +2398,19 @@ void configFrame::load_current()
GridJoystickCorrections->SetCellValue(0, 6, wxString(it->GetHighCoef().c_str(),wxConvUTF8));
}
GridJoystickCorrections->AutoSizeColumns();
//Load Force Feedback Tweaks
ForceFeedback * tweaks = configuration->GetForceFeedback();
FFBTweaksType->SetLabel(_CN(tweaks->GetJoystick()->GetType()));
ffbTweaksTabDeviceName = tweaks->GetJoystick()->GetName();
name = ffbTweaksTabDeviceName;
if(name.size() > 20)
{
name = name.substr(0,20);
name.append("...");
}
FFBTweaksName->SetLabel(wxString(name.c_str(),wxConvUTF8));
FFBTweaksId->SetLabel(wxString(tweaks->GetJoystick()->GetId().c_str(),wxConvUTF8));
FFBTweaksInvert->SetValue(tweaks->getInversion() == "yes");
//Load buttonMappers
clearGrid(GridPanelButton);
buttonMappers = configuration->GetButtonMapperList();
Expand Down Expand Up @@ -2444,6 +2514,7 @@ void configFrame::refresh_gui()
PanelTrigger->Layout();
PanelMouseOptions->Layout();
PanelJoystickCorrections->Layout();
PanelForceFeedback->Layout();
PanelIntensity->Layout();
PanelOverall->Layout();
PanelButton->Layout();
Expand Down Expand Up @@ -4335,3 +4406,38 @@ pair<Device, Event> configFrame::selectEvent()

return make_pair(Device(), Event());
}

void configFrame::OnButtonForceFeedbackAutoDetect(wxCommandEvent& event __attribute__((unused)))
{
if (evcatch->hasJoystick() == false)
{
wxMessageBox(_("No joystick found!"), _("Error"), wxICON_ERROR);
}

ForceFeedbackAutoDetect->Enable(false);

FFBTweaksType->SetLabel(wxT(""));

while(FFBTweaksType->GetLabel() != _("joystick"))
{
auto_detect(FFBTweaksType, &ffbTweaksTabDeviceName, FFBTweaksName, FFBTweaksId, _("axis"), FFBTweaksAxis);
}

ForceFeedbackAutoDetect->Enable(true);

refresh_gui();
}


void configFrame::OnButtonFFBTweaksDelete(wxCommandEvent& event __attribute__((unused)))
{
FFBTweaksType->SetLabel(wxEmptyString);
FFBTweaksName->SetLabel(wxEmptyString);
ffbTweaksTabDeviceName.clear();
FFBTweaksId->SetLabel(wxEmptyString);

FFBTweaksInvert->SetValue(false);

refresh_gui();
}

49 changes: 36 additions & 13 deletions config/gimx-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class configFrame: public wxFrame
void OnJoystickCorrectionsRemoveClick(wxCommandEvent& event);
void OnJoystickCorrectionsModifyClick(wxCommandEvent& event);
void OnJoystickCorrectionsAutoDetectClick(wxCommandEvent& event);
void OnButtonForceFeedbackAutoDetect(wxCommandEvent& event);
void OnButtonFFBTweaksDelete(wxCommandEvent& event);
//*)
void DeleteSelectedRows(wxGrid* grid);
void DeleteLinkedRows(wxGrid* grid, int row);
Expand Down Expand Up @@ -203,6 +205,16 @@ class configFrame: public wxFrame
static const long ID_BUTTON17;
static const long ID_BUTTON18;
static const long ID_PANEL7;
static const long ID_STATICTEXT13;
static const long ID_STATICTEXT20;
static const long ID_STATICTEXT25;
static const long ID_STATICTEXT49;
static const long ID_BUTTON20;
static const long ID_STATICLINE13;
static const long ID_CHECKBOX2;
static const long ID_STATICLINE15;
static const long ID_BUTTON24;
static const long ID_PANEL8;
static const long ID_NOTEBOOK2;
static const long ID_PANEL1;
static const long ID_STATICTEXT38;
Expand Down Expand Up @@ -315,15 +327,16 @@ class configFrame: public wxFrame
wxStaticText* StaticText13;
wxMenuItem* MenuConfiguration7;
wxChoice* ButtonTabEventType;
wxStaticText* JoystickCorrectionsName;
wxNotebook* Notebook2;
wxSpinCtrl* IntensitySteps;
wxPanel* PanelIntensity;
wxMenuItem* MenuItemCopyProfile;
wxStaticText* FFBTweaksName;
wxStaticText* IntensityDeviceId;
wxStatusBar* StatusBar1;
wxStaticText* AxisTabDeviceId;
wxGrid* GridPanelButton;
wxStaticText* JoystickCorrectionsType;
wxMenuItem* MenuItemG27Ps3;
wxStaticLine* StaticLine2;
wxTextCtrl* MouseOptionsFilter;
Expand All @@ -344,55 +357,57 @@ class configFrame: public wxFrame
wxStaticLine* StaticLine8;
wxMenuItem* MenuItemReplaceMouse;
wxChoice* IntensityDirection;
wxTextCtrl* JoystickCorrectionsLowValue;
wxStaticText* AxisTabDeviceType;
wxStaticLine* StaticLine5;
wxCheckBox* CheckBoxSwitchBack;
wxStaticLine* StaticLine10;
wxMenuItem* MenuItemG29Ps4;
wxMenuItem* MenuItemDfPs2;
wxMenuItem* MenuItemDfpPs2;
wxMenuItem* MenuItemGtfPs2;
wxStaticText* IntensityButtonId;
wxStaticLine* StaticLine13;
wxGrid* GridMouseOption;
wxTextCtrl* MouseOptionsBuffer;
wxStaticText* StaticText3;
wxTextCtrl* JoystickCorrectionsHighValue;
wxButton* ButtonTabAutoDetect;
wxTextCtrl* AxisTabDeadZone;
wxPanel* PanelOverall;
wxStaticText* StaticText2;
wxMenuItem* MenuConfiguration4;
wxStaticText* StaticText2;
wxStaticText* StaticTextThresholdPanelButton;
wxButton* IntensityAdd;
wxButton* ButtonAutoDetect;
wxStaticText* JoystickCorrectionsType;
wxMenuItem* MenuItemNew;
wxStaticText* ButtonTabDeviceId;
wxStaticText* ProfileTriggerDeviceName;
wxMenuItem* MenuConfiguration6;
wxButton* ButtonFFBTweaksDelete;
wxChoice* IntensityAxis;
wxMenuItem* MenuItem360;
wxButton* JoystickCorrectionAdd;
wxMenuItem* MenuConfiguration3;
wxStaticText* IntensityDeviceType;
wxButton* ButtonTabModify;
wxButton* AxisTabAutoDetect;
wxCheckBox* FFBTweaksInvert;
wxButton* IntensityModify;
wxChoice* AxisTabEventType;
wxStaticText* AxisTabDeviceName;
wxStaticText* ProfileTriggerButtonId;
wxMenuItem* MenuController6;
wxStaticText* ProfileTriggerDeviceType;
wxStaticText* JoystickCorrectionsAxis;
wxMenu* MenuConfiguration;
wxStaticLine* StaticLine7;
wxGrid* GridJoystickCorrections;
wxMenu* MenuEdit;
wxStaticText* FFBTweaksType;
wxPanel* PanelJoystickCorrections;
wxGrid* GridPanelAxis;
wxMenu* MenuFile;
wxPanel* PanelAxis;
wxStaticText* IntensityDeviceName;
wxStaticText* MouseOptionsName;
wxTextCtrl* JoystickCorrectionsLowValue;
wxMenuItem* MenuItemDS4;
wxButton* IntensityAutoDetect;
wxPanel* PanelButton;
Expand All @@ -409,19 +424,23 @@ class configFrame: public wxFrame
wxStaticText* AxisTabEventId;
wxMenuItem* MenuController3;
wxStaticText* StaticTextEmptyPanelAxis;
wxStaticText* FFBTweaksAxis;
wxStaticText* StaticTextDZPanelAxis;
wxMenuItem* MenuItem2;
wxChoice* ButtonTabButtonId;
wxStaticText* StaticText8;
wxMenuItem* MenuItemXOne;
wxSpinCtrl* IntensityDeadZone;
wxMenuItem* MenuItemDfpPs2;
wxStaticLine* StaticLine4;
wxMenuItem* MenuUpdate;
wxStaticText* JoystickCorrectionsId;
wxTextCtrl* JoystickCorrectionsHighCoef;
wxMenuItem* MenuConfiguration8;
wxMenuItem* MenuConfiguration2;
wxPanel* PanelForceFeedback;
wxButton* MouseOptionsRemove;
wxGrid* GridIntensity;
wxStaticText* JoystickCorrectionsId;
wxMenuItem* MenuItemReplaceMouseDPI;
wxStaticLine* StaticLine6;
wxPanel* PanelMouseOptions;
Expand All @@ -432,6 +451,7 @@ class configFrame: public wxFrame
wxButton* ButtonTabRemove;
wxMenuItem* MenuItemXbox;
wxMenuItem* MenuItemDS2;
wxButton* ForceFeedbackAutoDetect;
wxButton* ButtonTabAdd;
wxStaticText* StaticTextButtonPanelButton;
wxStaticLine* StaticLine3;
Expand All @@ -444,8 +464,10 @@ class configFrame: public wxFrame
wxMenuItem* MenuItemSave;
wxMenuItem* MenuItemReplaceKeyboard;
wxMenuItem* MenuItemSetMouseDPI;
wxMenuItem* MenuItemDfPs2;
wxButton* MouseOptionsModify;
wxStaticText* MouseOptionsButton;
wxTextCtrl* JoystickCorrectionsHighValue;
wxMenuItem* MenuItemDS3;
wxTextCtrl* ButtonTabThreshold;
wxStaticText* StaticText7;
Expand All @@ -454,29 +476,29 @@ class configFrame: public wxFrame
wxStaticText* StaticText11;
wxStaticText* StaticTextShapePanelAxis;
wxStaticText* MouseOptionsId;
wxMenuItem* MenuItemGtfPs2;
wxStaticText* StaticText12;
wxButton* JoystickCorrectionsAutoDetect;
wxStaticText* ButtonTabDeviceName;
wxStaticText* FFBTweaksId;
wxStaticLine* StaticLine9;
wxMenuItem* MenuItemWindowEvents;
wxStaticText* JoystickCorrectionsAxis;
wxMenuItem* MenuItemMultipleMiceAndKeyboards;
wxMenuItem* MenuController2;
wxButton* JoystickCorrectionModify;
wxStaticText* StaticTextAccelPanelAxis;
wxStaticLine* StaticLine14;
wxTextCtrl* JoystickCorrectionsLowCoef;
wxStaticText* StaticTextDelayPanelOverall;
wxNotebook* Notebook1;
wxStaticLine* StaticLine15;
wxStaticText* StaticTextSensPanelAxis;
wxMenuItem* MenuController7;
wxTextCtrl* JoystickCorrectionsHighCoef;
wxButton* ButtonDelete;
wxButton* MouseOptionsAdd;
wxMenuItem* MenuItemPasteController;
wxStaticText* ProfileTriggerDeviceId;
wxTextCtrl* JoystickCorrectionsLowCoef;
wxButton* JoystickCorrectionsAutoDetect;
wxMenu* MenuAdvanced;
wxStaticText* JoystickCorrectionsName;
wxComboBox* ButtonTabLabel;
wxMenuItem* MenuController1;
wxMenuItem* MenuItemCopyController;
Expand Down Expand Up @@ -506,6 +528,7 @@ class configFrame: public wxFrame
string mouseTabDeviceName;
string intensityTabDeviceName;
string joystickTabDeviceName;
string ffbTweaksTabDeviceName;

DECLARE_EVENT_TABLE()
};
Expand Down
Loading

0 comments on commit 216865e

Please sign in to comment.