From 9590137cd27d7f1ee3996cb535894d2aeac2ff15 Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:16:19 -0500 Subject: [PATCH 01/16] "Treat warnings as errors causes issues with newer GCC versions it would seem. Disable to compile. --- .gitignore | 4 ++++ Makedefs | 12 ++++++------ core/test/curses/Makefile | 2 +- core/test/haptic/Makefile | 4 ++-- shared/Makedefs | 12 ++++++------ 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 37183b78..82038178 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,7 @@ fpsconfig/gimx-fpsconfig core/gimx core/test/haptic/ff_lg_test loader/gimx-loader +/.vs +/setup +/setup_720 +/setup_640 diff --git a/Makedefs b/Makedefs index 7e8147d3..83f5e887 100644 --- a/Makedefs +++ b/Makedefs @@ -7,16 +7,16 @@ LD = $(CXX) ifneq ($(DEBUG),1) -CFLAGS += -Wall -Wextra -Werror -O3 -CXXFLAGS += -Wall -Wextra -Werror -O3 +CFLAGS += -Wall -Wextra -O3 +CXXFLAGS += -Wall -Wextra -O3 else ifneq ($(OS),Windows_NT) -CFLAGS += -Wall -Wextra -Werror -O0 -g -fsanitize=address -fno-omit-frame-pointer -CXXFLAGS += -Wall -Wextra -Werror -O0 -g -fsanitize=address -fno-omit-frame-pointer +CFLAGS += -Wall -Wextra -O0 -g -fsanitize=address -fno-omit-frame-pointer +CXXFLAGS += -Wall -Wextra -O0 -g -fsanitize=address -fno-omit-frame-pointer LDFLAGS += -fsanitize=address else -CFLAGS += -Wall -Wextra -Werror -O0 -g -fno-omit-frame-pointer -CXXFLAGS += -Wall -Wextra -Werror -O0 -g -fno-omit-frame-pointer +CFLAGS += -Wall -Wextra -O0 -g -fno-omit-frame-pointer +CXXFLAGS += -Wall -Wextra -O0 -g -fno-omit-frame-pointer endif endif diff --git a/core/test/curses/Makefile b/core/test/curses/Makefile index 21ada0a5..9f885302 100644 --- a/core/test/curses/Makefile +++ b/core/test/curses/Makefile @@ -6,7 +6,7 @@ else OUT=gimx.exe endif -CFLAGS = -Wall -Wextra -Werror -g -O0 +CFLAGS = -Wall -Wextra -g -O0 CPPFLAGS = -DSDL_MAIN_HANDLED -I../../../shared -I../.. -I/mingw64/include/SDL2 LDFLAGS = -L../../../shared/gimxcontroller -L../../../shared/gimxtime diff --git a/core/test/haptic/Makefile b/core/test/haptic/Makefile index bbce563b..ac55688d 100644 --- a/core/test/haptic/Makefile +++ b/core/test/haptic/Makefile @@ -2,8 +2,8 @@ OUT = ff_lg_test OBJS = ../../haptic/common/ff_lg.o ../../haptic/haptic_tweaks.o BINS = ff_lg_test -CFLAGS = -I../../ -I../../../shared -I../../../shared -Wall -Wextra -Werror -g -O0 -CXXFLAGS = -Wall -Wextra -Werror -g -O0 +CFLAGS = -I../../ -I../../../shared -I../../../shared -Wall -Wextra -g -O0 +CXXFLAGS = -Wall -Wextra -g -O0 ifeq ($(OS),Windows_NT) CPPFLAGS += $(shell sdl2-config --cflags) diff --git a/shared/Makedefs b/shared/Makedefs index e7007593..3af36f9c 100755 --- a/shared/Makedefs +++ b/shared/Makedefs @@ -5,15 +5,15 @@ libdir = $(exec_prefix)/lib endif ifneq ($(DEBUG),1) -CFLAGS += -Wall -Wextra -Werror -O3 -CXXFLAGS += -Wall -Wextra -Werror -O3 +CFLAGS += -Wall -Wextra -O3 +CXXFLAGS += -Wall -Wextra -O3 else ifneq ($(OS),Windows_NT) -CFLAGS += -Wall -Wextra -Werror -O0 -g -fsanitize=address -fno-omit-frame-pointer -CXXFLAGS += -Wall -Wextra -Werror -O0 -g -fsanitize=address -fno-omit-frame-pointer +CFLAGS += -Wall -Wextra -O0 -g -fsanitize=address -fno-omit-frame-pointer +CXXFLAGS += -Wall -Wextra -O0 -g -fsanitize=address -fno-omit-frame-pointer else -CFLAGS += -Wall -Wextra -Werror -O0 -g -fno-omit-frame-pointer -CXXFLAGS += -Wall -Wextra -Werror -O0 -g -fno-omit-frame-pointer +CFLAGS += -Wall -Wextra -O0 -g -fno-omit-frame-pointer +CXXFLAGS += -Wall -Wextra -O0 -g -fno-omit-frame-pointer endif endif From f02a12edb268368e1324da76948a74963de11215 Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:19:02 -0500 Subject: [PATCH 02/16] Extend FFB Tweaks page to include section for wheel rotation settings. --- config/wxsmith/configframe.wxs | 133 ++++++++++++++++++++++++++++++++- 1 file changed, 129 insertions(+), 4 deletions(-) diff --git a/config/wxsmith/configframe.wxs b/config/wxsmith/configframe.wxs index 7fc83cc9..0ffb8d2b 100644 --- a/config/wxsmith/configframe.wxs +++ b/config/wxsmith/configframe.wxs @@ -982,7 +982,7 @@ 2 - 6 + 8 1 @@ -1162,9 +1162,17 @@ - - - + + 1 + + + + + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 5 @@ -1175,6 +1183,123 @@ 5 + + + 6 + 1 + + + + + + 4 + 1 + + + + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + + + + + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + + + + + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + + + + + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + + + wxALL|wxEXPAND + 5 + + + + + + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + + + + 1,50 + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + + + + 1 + 2 + + + + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + + + + 900 + 55,-1 + [200..900] + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + + + + 1,50 + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + + + + + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 5 + + + + wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL + 5 + + From d6ea2588b109afde35b8e171885de978686890b3 Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:21:20 -0500 Subject: [PATCH 03/16] Update CodeBlocks project file to make buildable with minGW32 toolchain. Notice: Project should be prebuilt using build.sh first to provide DLLs. --- config/config.cbp | 344 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 317 insertions(+), 27 deletions(-) diff --git a/config/config.cbp b/config/config.cbp index 07d50d5b..cc32cc77 100644 --- a/config/config.cbp +++ b/config/config.cbp @@ -3,31 +3,56 @@ From 8fd00a7c7021e27aa15c114a18a368f625bc0bab Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:22:43 -0500 Subject: [PATCH 04/16] Logic updates behind loading and saving new wheel rotation prop. --- config/gimx-config.cpp | 118 +++++++++++++++++++++++++++++++++++++++-- config/gimx-config.h | 25 ++++++++- 2 files changed, 138 insertions(+), 5 deletions(-) diff --git a/config/gimx-config.cpp b/config/gimx-config.cpp index 952cc7f6..cf5a1d7c 100644 --- a/config/gimx-config.cpp +++ b/config/gimx-config.cpp @@ -133,6 +133,16 @@ const long configFrame::ID_TEXTCTRL15 = wxNewId(); const long configFrame::ID_TEXTCTRL17 = wxNewId(); const long configFrame::ID_STATICLINE15 = wxNewId(); const long configFrame::ID_BUTTON24 = wxNewId(); +const long configFrame::ID_STATICTEXT56 = wxNewId(); +const long configFrame::ID_STATICTEXT57 = wxNewId(); +const long configFrame::ID_STATICTEXT58 = wxNewId(); +const long configFrame::ID_STATICTEXT59 = wxNewId(); +const long configFrame::ID_BUTTON26 = wxNewId(); +const long configFrame::ID_STATICLINE17 = wxNewId(); +const long configFrame::ID_STATICTEXT60 = wxNewId(); +const long configFrame::ID_TEXTCTRL19 = wxNewId(); +const long configFrame::ID_STATICLINE18 = wxNewId(); +const long configFrame::ID_BUTTON27 = wxNewId(); const long configFrame::ID_PANEL8 = wxNewId(); const long configFrame::ID_NOTEBOOK2 = wxNewId(); const long configFrame::ID_PANEL1 = wxNewId(); @@ -608,7 +618,7 @@ static bool ToDouble(const wxString & from, double * to, const wxString & decima * \param parent the parent window * \param id the parent window id */ -configFrame::configFrame(wxString file,wxWindow* parent, wxWindowID id __attribute__((unused))) +configFrame::configFrame(wxString file, wxWindow* parent, wxWindowID id __attribute__((unused))) { locale = new wxLocale(wxLANGUAGE_DEFAULT); #ifdef WIN32 @@ -671,7 +681,11 @@ configFrame::configFrame(wxString file,wxWindow* parent, wxWindowID id __attribu wxFlexGridSizer* FlexGridSizer54; wxFlexGridSizer* FlexGridSizer55; wxFlexGridSizer* FlexGridSizer56; + wxFlexGridSizer* FlexGridSizer58; + wxFlexGridSizer* FlexGridSizer59; wxFlexGridSizer* FlexGridSizer5; + wxFlexGridSizer* FlexGridSizer60; + wxFlexGridSizer* FlexGridSizer61; wxFlexGridSizer* FlexGridSizer6; wxFlexGridSizer* FlexGridSizer7; wxFlexGridSizer* FlexGridSizer8; @@ -686,6 +700,7 @@ configFrame::configFrame(wxString file,wxWindow* parent, wxWindowID id __attribu wxStaticBoxSizer* StaticBoxSizer10; wxStaticBoxSizer* StaticBoxSizer11; wxStaticBoxSizer* StaticBoxSizer12; + wxStaticBoxSizer* StaticBoxSizer13; wxStaticBoxSizer* StaticBoxSizer1; wxStaticBoxSizer* StaticBoxSizer2; wxStaticBoxSizer* StaticBoxSizer3; @@ -979,7 +994,7 @@ configFrame::configFrame(wxString file,wxWindow* parent, wxWindowID id __attribu 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); + FlexGridSizer54 = new wxFlexGridSizer(1, 8, 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")); @@ -1027,9 +1042,40 @@ configFrame::configFrame(wxString file,wxWindow* parent, wxWindowID id __attribu 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); + FlexGridSizer58 = new wxFlexGridSizer(0, 1, 0, 0); + ButtonFFBTweaksDelete = new wxButton(PanelForceFeedback, ID_BUTTON24, _("Delete FFB"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON24")); + FlexGridSizer58->Add(ButtonFFBTweaksDelete, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + FlexGridSizer54->Add(FlexGridSizer58, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer39->Add(FlexGridSizer54, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + FlexGridSizer59 = new wxFlexGridSizer(1, 6, 0, 0); + StaticBoxSizer13 = new wxStaticBoxSizer(wxHORIZONTAL, PanelForceFeedback, _("Joystick")); + FlexGridSizer60 = new wxFlexGridSizer(1, 4, 0, 0); + WheelRotationType = new wxStaticText(PanelForceFeedback, ID_STATICTEXT56, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT56")); + FlexGridSizer60->Add(WheelRotationType, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + WheelRotationName = new wxStaticText(PanelForceFeedback, ID_STATICTEXT57, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT57")); + FlexGridSizer60->Add(WheelRotationName, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + WheelRotationId = new wxStaticText(PanelForceFeedback, ID_STATICTEXT58, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT58")); + FlexGridSizer60->Add(WheelRotationId, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + WheelRotationAxis = new wxStaticText(PanelForceFeedback, ID_STATICTEXT59, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT59")); + FlexGridSizer60->Add(WheelRotationAxis, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + StaticBoxSizer13->Add(FlexGridSizer60, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + FlexGridSizer59->Add(StaticBoxSizer13, 1, wxALL|wxEXPAND, 5); + WheelRotationAutoDetectButton = new wxButton(PanelForceFeedback, ID_BUTTON26, _("Auto Detect"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON26")); + FlexGridSizer59->Add(WheelRotationAutoDetectButton, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + StaticLine17 = new wxStaticLine(PanelForceFeedback, ID_STATICLINE17, wxDefaultPosition, wxSize(1,50), wxLI_HORIZONTAL, _T("ID_STATICLINE17")); + FlexGridSizer59->Add(StaticLine17, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + FlexGridSizer61 = new wxFlexGridSizer(2, 1, 0, 0); + StaticText23 = new wxStaticText(PanelForceFeedback, ID_STATICTEXT60, _("Rotation"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT60")); + FlexGridSizer61->Add(StaticText23, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + WheelRotationDegrees = new wxTextCtrl(PanelForceFeedback, ID_TEXTCTRL19, _("900"), wxDefaultPosition, wxSize(55,-1), 0, wxDefaultValidator, _T("ID_TEXTCTRL19")); + WheelRotationDegrees->SetToolTip(_("[200..900]")); + FlexGridSizer61->Add(WheelRotationDegrees, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + FlexGridSizer59->Add(FlexGridSizer61, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + StaticLine18 = new wxStaticLine(PanelForceFeedback, ID_STATICLINE18, wxDefaultPosition, wxSize(1,50), wxLI_HORIZONTAL, _T("ID_STATICLINE18")); + FlexGridSizer59->Add(StaticLine18, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + DeleteRotationButton = new wxButton(PanelForceFeedback, ID_BUTTON27, _("Delete Rotation"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON27")); + FlexGridSizer59->Add(DeleteRotationButton, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + FlexGridSizer39->Add(FlexGridSizer59, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); PanelForceFeedback->SetSizer(FlexGridSizer39); FlexGridSizer39->Fit(PanelForceFeedback); FlexGridSizer39->SetSizeHints(PanelForceFeedback); @@ -1400,11 +1446,14 @@ configFrame::configFrame(wxString file,wxWindow* parent, wxWindowID id __attribu 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_BUTTON26,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&configFrame::OnButtonWheelRotationAutoDetect); Connect(ID_TEXTCTRL14,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&configFrame::OnTextCtrl); Connect(ID_TEXTCTRL16,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&configFrame::OnTextCtrl); Connect(ID_TEXTCTRL15,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&configFrame::OnTextCtrl); Connect(ID_TEXTCTRL17,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&configFrame::OnTextCtrl); + Connect(ID_TEXTCTRL19,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&configFrame::OnTextCtrl); Connect(ID_BUTTON24,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&configFrame::OnButtonFFBTweaksDelete); + Connect(ID_BUTTON27,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&configFrame::OnButtonWheelRotationDelete); 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); @@ -2349,6 +2398,21 @@ void configFrame::save_current() wxString damper; damper << FFBTweaksDamperGain->GetValue(); profile->GetForceFeedback()->setDamperGain(string(damper.mb_str(wxConvUTF8))); + //Save Rotation settings + wxString rotation; + rotation << WheelRotationDegrees->GetValue(); + long rotationVal; + if(!rotation.ToLong(&rotationVal)){ + rotation = "900"; + } else if(rotationVal < 200){ + rotation = "200"; + } else if(rotationVal > 900){ + rotation = "900"; + } + profile->GetWheelRotation()->GetJoystick()->SetType(reverseTranslate(string(WheelRotationType->GetLabel().mb_str(wxConvUTF8)))); + profile->GetWheelRotation()->GetJoystick()->SetName(wheelRotationDeviceName); + profile->GetWheelRotation()->GetJoystick()->SetId(string(WheelRotationId->GetLabel().mb_str(wxConvUTF8))); + profile->GetWheelRotation()->SetRotation(string(rotation.mb_str(wxConvUTF8))); //Save ControlMappers buttonMappers = profile->GetButtonMapperList(); buttonMappers->erase(buttonMappers->begin(), buttonMappers->end()); @@ -2572,6 +2636,19 @@ void configFrame::load_current() FFBTweaksConstantGain->SetValue(wxString(tweaks->getConstantGain().c_str(),wxConvUTF8)); FFBTweaksSpringGain->SetValue(wxString(tweaks->getSpringGain().c_str(),wxConvUTF8)); FFBTweaksDamperGain->SetValue(wxString(tweaks->getDamperGain().c_str(),wxConvUTF8)); + + WheelRotation* rotation = profile->GetWheelRotation(); + wheelRotationDeviceName = rotation->GetJoystick()->GetName(); + name = wheelRotationDeviceName; + if (name.size() > 20) + { + name = name.substr(0, 20); + name.append("..."); + } + WheelRotationType->SetLabel(_CN(rotation->GetJoystick()->GetType())); + WheelRotationName->SetLabel(wxString(name.c_str(), wxConvUTF8)); + WheelRotationId->SetLabel(wxString(rotation->GetJoystick()->GetId().c_str(), wxConvUTF8)); + WheelRotationDegrees->SetValue(wxString(rotation->GetRotation().c_str(), wxConvUTF8)); //Load buttonMappers clearGrid(GridPanelButton); buttonMappers = profile->GetButtonMapperList(); @@ -3758,6 +3835,12 @@ void configFrame::OnTextCtrl(wxCommandEvent& event) text->SetValue(wxT("1000")); } } + else if (text == WheelRotationDegrees) { + if (!str.ToLong(&lvalue)) + { + text->SetValue(wxT("900")); + } + } text->SetInsertionPoint(pos); @@ -4623,6 +4706,25 @@ pair configFrame::selectEvent() return make_pair(Device(), Event()); } +void configFrame::OnButtonWheelRotationAutoDetect(wxCommandEvent& event __attribute__((unused))) { + if (evcatch->hasJoystick() == false) + { + wxMessageBox(_("No joystick found!"), _("Error"), wxICON_ERROR); + } + + WheelRotationAutoDetectButton->Enable(false); + + WheelRotationType->SetLabel(wxT("")); + + while (WheelRotationType->GetLabel() != _("joystick")) + { + auto_detect(WheelRotationType, &wheelRotationDeviceName, WheelRotationName, WheelRotationId, _("axis"), WheelRotationAxis); + } + + WheelRotationAutoDetectButton->Enable(true); + + refresh_gui(); +} void configFrame::OnButtonForceFeedbackAutoDetect(wxCommandEvent& event __attribute__((unused))) { @@ -4663,6 +4765,14 @@ void configFrame::OnButtonFFBTweaksDelete(wxCommandEvent& event __attribute__((u refresh_gui(); } +void configFrame::OnButtonWheelRotationDelete(wxCommandEvent& event __attribute__((unused))) { + WheelRotationType->SetLabel(wxEmptyString); + WheelRotationName->SetLabel(wxEmptyString); + WheelRotationId->SetLabel(wxEmptyString); + wheelRotationDeviceName.clear(); + WheelRotationDegrees->SetValue(_T("900")); + refresh_gui(); +} void configFrame::OnAxisTabAxisIdSelect(wxCommandEvent& event __attribute__((unused))) { diff --git a/config/gimx-config.h b/config/gimx-config.h index 5c9cb4f1..3e088d5e 100644 --- a/config/gimx-config.h +++ b/config/gimx-config.h @@ -104,7 +104,9 @@ class configFrame: public wxFrame void OnJoystickCorrectionsRemoveClick(wxCommandEvent& event); void OnJoystickCorrectionsModifyClick(wxCommandEvent& event); void OnJoystickCorrectionsAutoDetectClick(wxCommandEvent& event); + void OnButtonWheelRotationAutoDetect(wxCommandEvent& event); void OnButtonForceFeedbackAutoDetect(wxCommandEvent& event); + void OnButtonWheelRotationDelete(wxCommandEvent& event); void OnButtonFFBTweaksDelete(wxCommandEvent& event); void OnAxisTabAxisIdSelect(wxCommandEvent& event); void OnMenuItemExport(wxCommandEvent& event); @@ -226,6 +228,16 @@ class configFrame: public wxFrame static const long ID_TEXTCTRL17; static const long ID_STATICLINE15; static const long ID_BUTTON24; + static const long ID_STATICTEXT56; + static const long ID_STATICTEXT57; + static const long ID_STATICTEXT58; + static const long ID_STATICTEXT59; + static const long ID_BUTTON26; + static const long ID_STATICLINE17; + static const long ID_STATICTEXT60; + static const long ID_TEXTCTRL19; + static const long ID_STATICLINE18; + static const long ID_BUTTON27; static const long ID_PANEL8; static const long ID_NOTEBOOK2; static const long ID_PANEL1; @@ -342,6 +354,7 @@ class configFrame: public wxFrame wxButton* ButtonTabAutoDetect; wxButton* ButtonTabModify; wxButton* ButtonTabRemove; + wxButton* DeleteRotationButton; wxButton* ForceFeedbackAutoDetect; wxButton* IntensityAdd; wxButton* IntensityAutoDetect; @@ -355,6 +368,7 @@ class configFrame: public wxFrame wxButton* MouseOptionsAutoDetect; wxButton* MouseOptionsModify; wxButton* MouseOptionsRemove; + wxButton* WheelRotationAutoDetectButton; wxCheckBox* CheckBoxSwitchBack; wxCheckBox* FFBTweaksInvert; wxChoice* AxisTabAxisId; @@ -441,6 +455,8 @@ class configFrame: public wxFrame wxStaticLine* StaticLine13; wxStaticLine* StaticLine14; wxStaticLine* StaticLine15; + wxStaticLine* StaticLine17; + wxStaticLine* StaticLine18; wxStaticLine* StaticLine1; wxStaticLine* StaticLine2; wxStaticLine* StaticLine3; @@ -488,6 +504,7 @@ class configFrame: public wxFrame wxStaticText* StaticText18; wxStaticText* StaticText19; wxStaticText* StaticText1; + wxStaticText* StaticText23; wxStaticText* StaticText24; wxStaticText* StaticText2; wxStaticText* StaticText3; @@ -506,6 +523,10 @@ class configFrame: public wxFrame wxStaticText* StaticTextSensPanelAxis; wxStaticText* StaticTextShapePanelAxis; wxStaticText* StaticTextThresholdPanelButton; + wxStaticText* WheelRotationAxis; + wxStaticText* WheelRotationId; + wxStaticText* WheelRotationName; + wxStaticText* WheelRotationType; wxStatusBar* StatusBar1; wxTextCtrl* AxisTabAcceleration; wxTextCtrl* AxisTabDeadZone; @@ -524,6 +545,7 @@ class configFrame: public wxFrame wxTextCtrl* MouseOptionsBuffer; wxTextCtrl* MouseOptionsFilter; wxTextCtrl* ProfileTriggerDelay; + wxTextCtrl* WheelRotationDegrees; //*) wxLocale* locale; @@ -543,7 +565,7 @@ class configFrame: public wxFrame unsigned int grid3mod; unsigned int grid4mod; unsigned int gridJoystickCorrectionsMod; - + wxString default_directory; string buttonTabDeviceName; @@ -553,6 +575,7 @@ class configFrame: public wxFrame string intensityTabDeviceName; string joystickTabDeviceName; string ffbTweaksTabDeviceName; + string wheelRotationDeviceName; DECLARE_EVENT_TABLE() }; From 7fe1e782012a0b9118c32100ea7d480d30518a60 Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:25:27 -0500 Subject: [PATCH 05/16] Haptic core logic to support wheel rotation settings. --- core/haptic/haptic_core.c | 16 ++++++++++++++++ core/haptic/haptic_core.h | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/core/haptic/haptic_core.c b/core/haptic/haptic_core.c index 5552300f..69624f1e 100644 --- a/core/haptic/haptic_core.c +++ b/core/haptic/haptic_core.c @@ -24,6 +24,7 @@ struct haptic_core { struct haptic_sink_state * state; } sink; s_haptic_core_tweaks tweaks; + s_haptic_core_wheel_rotation rotationTweaks; GLIST_LINK(struct haptic_core); }; @@ -64,6 +65,7 @@ struct haptic_core * haptic_core_init(s_haptic_core_ids source_ids, int sink_joy core->tweaks.gain.constant = 100; core->tweaks.gain.spring = 100; core->tweaks.gain.damper = 100; + core->rotationTweaks.rotation = 900; GLIST_ADD(ff_cores, core); @@ -106,6 +108,7 @@ void haptic_core_update(struct haptic_core * core) { s_haptic_core_data data; while (core->source.ptr->get(core->source.state, &data)) { haptic_tweak_apply(&core->tweaks, &data); + haptic_rotation_apply(&core->rotationTweaks, &data); core->sink.ptr->process(core->sink.state, &data); } @@ -142,3 +145,16 @@ void haptic_core_set_tweaks(struct haptic_core * core, const s_haptic_core_tweak core->tweaks = *tweaks; } + +void haptic_core_set_rotation(struct haptic_core* core, const s_haptic_core_wheel_rotation* rotation) { + + if (core == NULL) { + return; + } + + if (gimx_params.status) { + if (core->sink.ptr->caps & E_HAPTIC_SINK_CAP_RANGE) { + ginfo("wheel lock=%d\n", rotation->rotation); + } + } +} diff --git a/core/haptic/haptic_core.h b/core/haptic/haptic_core.h index 0549ff01..dd07be72 100644 --- a/core/haptic/haptic_core.h +++ b/core/haptic/haptic_core.h @@ -79,12 +79,17 @@ typedef struct { } gain; } s_haptic_core_tweaks; +typedef struct { + int rotation; +} s_haptic_core_wheel_rotation; + struct haptic_core; struct haptic_core * haptic_core_init(s_haptic_core_ids source_ids, int source_joystick); int haptic_core_clean(struct haptic_core * core); void haptic_core_set_tweaks(struct haptic_core * core, const s_haptic_core_tweaks * tweaks); +void haptic_core_set_rotation(struct haptic_core* core, const s_haptic_core_wheel_rotation* rotation); void haptic_core_process_report(struct haptic_core * core, size_t size, const unsigned char * data); void haptic_core_update(struct haptic_core * core); From 25bb1052038c385314bf71a45807351f14162e1b Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:26:20 -0500 Subject: [PATCH 06/16] haptic tweaks logic added to support wheel rotation application. --- core/haptic/haptic_tweaks.c | 11 +++++++++++ core/haptic/haptic_tweaks.h | 1 + 2 files changed, 12 insertions(+) diff --git a/core/haptic/haptic_tweaks.c b/core/haptic/haptic_tweaks.c index 4a92f7fa..c47c7b85 100644 --- a/core/haptic/haptic_tweaks.c +++ b/core/haptic/haptic_tweaks.c @@ -3,6 +3,7 @@ License: GPLv3 */ +#include #include #include @@ -18,6 +19,16 @@ int64_t tmp = VALUE * GAIN / 100; \ VALUE = CLAMP(MIN, tmp, MAX); \ } + +void haptic_rotation_apply(const s_haptic_core_wheel_rotation* rotation, s_haptic_core_data* data) { + + if (data->type == E_DATA_TYPE_RANGE) { + if (data->range.value > rotation->rotation) { + ginfo("Setting range to user set %d* limit.\n", rotation->rotation); + data->range.value = rotation->rotation; + } + } +} void haptic_tweak_apply(const s_haptic_core_tweaks * tweaks, s_haptic_core_data * data) { diff --git a/core/haptic/haptic_tweaks.h b/core/haptic/haptic_tweaks.h index dd46b0e4..7835a096 100644 --- a/core/haptic/haptic_tweaks.h +++ b/core/haptic/haptic_tweaks.h @@ -8,6 +8,7 @@ #include +void haptic_rotation_apply(const s_haptic_core_wheel_rotation* rotation, s_haptic_core_data* data); void haptic_tweak_apply(const s_haptic_core_tweaks * tweaks, s_haptic_core_data * data); #endif /* HAPTIC_TWEAKS_H_ */ From eb15ba2d5848b204ac9b84fd25ea6bf37f39836e Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:27:11 -0500 Subject: [PATCH 07/16] Config core updated to support addition of Wheel rotation settings into the config layout. --- core/config.c | 27 +++++++++++++++++++++++++++ core/config.h | 6 ++++++ 2 files changed, 33 insertions(+) diff --git a/core/config.c b/core/config.c index c18af29c..03475805 100644 --- a/core/config.c +++ b/core/config.c @@ -117,6 +117,29 @@ void cfg_init_ffb_tweaks() } } +static s_haptic_core_wheel_rotation wheelRotations[MAX_CONTROLLERS][MAX_PROFILES]; + +void cfg_set_wheel_rotation(const s_config_entry* entry) { + wheelRotations[entry->controller_id][entry->profile_id].rotation = entry->params.wheel_rotation.degrees; +} + +const s_haptic_core_wheel_rotation* cfg_get_wheel_rotation(int controller) +{ + return wheelRotations[controller] + cfg_controllers[controller].current->index; +} + +void cfg_init_wheel_rotations() +{ + unsigned int i, j; + for (i = 0; i < MAX_CONTROLLERS; ++i) + { + for (j = 0; j < MAX_PROFILES; ++j) + { + wheelRotations[i][j].rotation = 900; + } + } +} + static struct { unsigned int nb; @@ -876,6 +899,10 @@ void cfg_profile_activation() adapter_set_haptic_tweaks(i, tweaks); + const s_haptic_core_wheel_rotation* rot = cfg_get_wheel_rotation(i); + + adapter_set_haptic_wheel_rotation(i, rot); + unsigned int k; for (k = 0; k < sizeof(mouse_control) / sizeof(*mouse_control); ++k) { diff --git a/core/config.h b/core/config.h index fc2048ed..ee7bc431 100644 --- a/core/config.h +++ b/core/config.h @@ -145,6 +145,9 @@ typedef struct int damper; } gain; } ffb_tweaks; + struct { + int degrees; + } wheel_rotation; } params; }s_config_entry; @@ -203,6 +206,9 @@ int cfg_add_js_corr(int joystick, s_js_corr * corr); void cfg_set_ffb_tweaks(const s_config_entry * entry); const s_haptic_core_tweaks * cfg_get_ffb_tweaks(int controller); void cfg_init_ffb_tweaks(); +void cfg_set_wheel_rotation(const s_config_entry* entry); +const s_haptic_core_wheel_rotation* cfg_get_wheel_rotation(int controller); +void cfg_init_wheel_rotations(); void cfg_pair_mouse_mappers(); void cfg_set_profile(int controller, int profile); From 7c0cef0eb63d65321ac5a0e10c52d2a56bdfb3cc Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:28:00 -0500 Subject: [PATCH 08/16] Config reader updates to read new node from XML configs. --- core/config_reader.c | 53 ++++++++++++++++++- shared/gimxconfigeditor/include/XmlReader.h | 6 +++ shared/gimxconfigeditor/src/XmlReader.cpp | 56 +++++++++++++++++++-- 3 files changed, 110 insertions(+), 5 deletions(-) diff --git a/core/config_reader.c b/core/config_reader.c index 451fc486..a6e2ec90 100644 --- a/core/config_reader.c +++ b/core/config_reader.c @@ -1061,6 +1061,51 @@ static void ProcessGainElement(xmlNode * a_node) GetIntProp(a_node, X_ATTR_DAMPER, &entry.params.ffb_tweaks.gain.damper); } +static int ProcessRotationElement(xmlNode* a_node) { + + int ret = 0; + int has_device = 0; + + reset_entry(); + + entry.params.wheel_rotation.degrees = 900; + + xmlNode* cur_node = NULL; + for (cur_node = a_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type == XML_ELEMENT_NODE) + { + if (xmlStrEqual(cur_node->name, (xmlChar*)X_NODE_DEVICE)) + { + has_device = 1; + ret = ProcessDeviceElement(cur_node); + } + else if (xmlStrEqual(cur_node->name, (xmlChar*)X_NODE_ROTATION)) + { + GetIntProp(cur_node, X_ATTR_DEGREES, &entry.params.wheel_rotation.degrees); + } + else + { + gerror("unexpected element: %s\n", cur_node->name); + } + } + } + if (has_device == 0) + { + gerror("missing device element\n"); + ret = -1; + } + + if (ret == 0) + { + cfg_set_wheel_rotation(&entry); + // force FFB selection for 1st profile only + adapter_set_haptic_sink(entry.controller_id, entry.device.id, entry.profile_id == 0 ? 1 : 0); + } + + return ret; +} + static int ProcessForceFeedbackElement(xmlNode * a_node) { int ret = 0; @@ -1188,9 +1233,13 @@ static int ProcessConfigurationElement(xmlNode * a_node) { ret = ProcessJoystickCorrectionsListElement(cur_node); } - else if (xmlStrEqual(cur_node->name, (xmlChar*) X_NODE_FORCE_FEEDBACK)) + else if (xmlStrEqual(cur_node->name, (xmlChar*)X_NODE_FORCE_FEEDBACK)) + { + ret = ProcessForceFeedbackElement(cur_node); + } + else if (xmlStrEqual(cur_node->name, (xmlChar*)X_NODE_WHEEL_SETTINGS)) { - ret = ProcessForceFeedbackElement(cur_node); + ret = ProcessRotationElement(cur_node); } else if (xmlStrEqual(cur_node->name, (xmlChar*) X_NODE_MACROS)) { diff --git a/shared/gimxconfigeditor/include/XmlReader.h b/shared/gimxconfigeditor/include/XmlReader.h index be6dd366..7548f1e0 100644 --- a/shared/gimxconfigeditor/include/XmlReader.h +++ b/shared/gimxconfigeditor/include/XmlReader.h @@ -72,6 +72,10 @@ #define X_ATTR_SPRING "spring" #define X_ATTR_DAMPER "damper" +#define X_NODE_WHEEL_SETTINGS "wheel_settings" +#define X_NODE_ROTATION "wheel_rotation" +#define X_ATTR_DEGREES "degrees" + #define X_ATTR_VALUE_YES "yes" #define X_ATTR_VALUE_NO "no" @@ -104,6 +108,7 @@ class XmlReader void ProcessIntensityElement(xmlNode * a_node); void ProcessIntensityListElement(xmlNode * a_node); void ProcessJoystickCorrectionsListElement(xmlNode * a_node); + void ProcessRotationElement(xmlNode* a_node); void ProcessForceFeedbackElement(xmlNode * a_node); void ProcessMacrosElement(xmlNode * a_node); void ProcessCorrectionElement(xmlNode * a_node); @@ -123,6 +128,7 @@ class XmlReader Trigger m_TempTrigger; MouseOptions m_TempMouseOptions; JoystickCorrection m_TempJoystickCorrection; + WheelRotation m_TempWheelRotation; ForceFeedback m_TempForceFeedback; Intensity m_TempIntensity; Profile m_TempConfiguration; diff --git a/shared/gimxconfigeditor/src/XmlReader.cpp b/shared/gimxconfigeditor/src/XmlReader.cpp index 274b628e..a1c27deb 100644 --- a/shared/gimxconfigeditor/src/XmlReader.cpp +++ b/shared/gimxconfigeditor/src/XmlReader.cpp @@ -526,7 +526,7 @@ void XmlReader::ProcessIntensityElement(xmlNode * a_node) string message(string("bad element name: ") + string((char*)cur_node->name)); throw invalid_argument(message); } - + prop = (char*)xmlGetProp(cur_node, (xmlChar*) X_ATTR_TYPE); device_type = string(prop?prop:""); xmlFree(prop); @@ -544,7 +544,7 @@ void XmlReader::ProcessIntensityElement(xmlNode * a_node) { m_TempIntensity.SetDevice(Device(device_type, device_id, device_name)); m_TempIntensity.SetEvent(Event(button_id)); - + if(control == "left_stick") { m_TempIntensity.SetAxis(Intensity::GetAxisProps("lstick")); @@ -705,6 +705,52 @@ void XmlReader::ProcessGainElement(xmlNode * a_node) xmlFree(prop); } +void XmlReader::ProcessRotationElement(xmlNode* a_node) { + xmlNode* cur_node = NULL; + + for (cur_node = a_node->children; cur_node; cur_node = cur_node->next) + { + if (cur_node->type == XML_ELEMENT_NODE) + { + if (xmlStrEqual(cur_node->name, (xmlChar*)X_NODE_DEVICE)) + { + ProcessDeviceElement(cur_node); + break; + } + else + { + string message(string("bad element name: ") + string((char*)cur_node->name)); + throw invalid_argument(message); + } + } + } + if (!cur_node) + { + string message(string("missing device element")); + throw invalid_argument(message); + } + + for (cur_node = cur_node->next; cur_node; cur_node = cur_node->next) + { + if (cur_node->type == XML_ELEMENT_NODE) + { + if (xmlStrEqual(cur_node->name, (xmlChar*)X_NODE_ROTATION)) + { + char* prop; + + prop = (char*)xmlGetProp(cur_node, (xmlChar*)X_ATTR_DEGREES); + string str(prop); + printf("Degrees prop: %s\n", prop); + m_TempWheelRotation.SetRotation(string(prop ? prop : "900")); + xmlFree(prop); + } + } + } + m_TempWheelRotation.SetJoystick(m_TempDevice); + + m_TempConfiguration.SetWheelRotation(m_TempWheelRotation); +} + void XmlReader::ProcessForceFeedbackElement(xmlNode * a_node) { xmlNode* cur_node = NULL; @@ -819,10 +865,14 @@ void XmlReader::ProcessConfigurationElement(xmlNode * a_node) { ProcessJoystickCorrectionsListElement(cur_node); } - else if (xmlStrEqual(cur_node->name, (xmlChar*) X_NODE_FORCE_FEEDBACK)) + else if (xmlStrEqual(cur_node->name, (xmlChar*)X_NODE_FORCE_FEEDBACK)) { ProcessForceFeedbackElement(cur_node); } + else if (xmlStrEqual(cur_node->name, (xmlChar*)X_NODE_WHEEL_SETTINGS)) + { + ProcessRotationElement(cur_node); + } else if (xmlStrEqual(cur_node->name, (xmlChar*) X_NODE_MACROS)) { ProcessMacrosElement(cur_node); From 86ea60cdddbfeda091525303b6439838ea512f07 Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:28:47 -0500 Subject: [PATCH 09/16] Config writer updates to add new node to XML config layout. --- core/xml_defs.h | 4 ++++ shared/gimxconfigeditor/include/XmlWritter.h | 1 + shared/gimxconfigeditor/src/XmlWritter.cpp | 14 +++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/xml_defs.h b/core/xml_defs.h index f1926b56..cb2ac5d4 100644 --- a/core/xml_defs.h +++ b/core/xml_defs.h @@ -74,6 +74,10 @@ #define X_ATTR_SPRING "spring" #define X_ATTR_DAMPER "damper" +#define X_NODE_WHEEL_SETTINGS "wheel_settings" +#define X_NODE_ROTATION "wheel_rotation" +#define X_ATTR_DEGREES "degrees" + #define X_NODE_MACROS "macros" #endif /* XML_DEFS_H_ */ diff --git a/shared/gimxconfigeditor/include/XmlWritter.h b/shared/gimxconfigeditor/include/XmlWritter.h index 494177c8..20bc4dc8 100644 --- a/shared/gimxconfigeditor/include/XmlWritter.h +++ b/shared/gimxconfigeditor/include/XmlWritter.h @@ -29,6 +29,7 @@ class XmlWritter void CreateControllerNodes(xmlNodePtr parent_node); void CreateJoystickCorrectionsNodes(xmlNodePtr parent_node); void CreateForceFeedbackNode(xmlNodePtr parent_node); + void CreateRotationNode(xmlNodePtr parent_node); void CreateInversionNode(xmlNodePtr parent_node, ForceFeedback* ffb); void CreateGainNode(xmlNodePtr parent_node, ForceFeedback* ffb); void CreateMacrosNode(xmlNodePtr parent_node); diff --git a/shared/gimxconfigeditor/src/XmlWritter.cpp b/shared/gimxconfigeditor/src/XmlWritter.cpp index 90c464bc..9bd5dcf7 100644 --- a/shared/gimxconfigeditor/src/XmlWritter.cpp +++ b/shared/gimxconfigeditor/src/XmlWritter.cpp @@ -196,6 +196,16 @@ void XmlWritter::CreateForceFeedbackNode(xmlNodePtr parent_node) } } +void XmlWritter::CreateRotationNode(xmlNodePtr parent_node) { + WheelRotation* rotation = m_ConfigurationFile->GetController(m_CurrentController)->GetProfile(m_CurrentProfile)->GetWheelRotation(); + if (!rotation->GetJoystick()->GetName().empty()) { + xmlNodePtr node = xmlNewChild(parent_node, NULL, BAD_CAST X_NODE_WHEEL_SETTINGS, NULL); + CreateDeviceNode(node, rotation->GetJoystick()); + xmlNodePtr d_node = xmlNewChild(node, NULL, BAD_CAST X_NODE_ROTATION, NULL); + xmlNewProp(d_node, BAD_CAST X_ATTR_DEGREES, BAD_CAST rotation->GetRotation().c_str()); + } +} + void XmlWritter::CreateMacrosNode(xmlNodePtr parent_node) { const std::string& macros = m_ConfigurationFile->GetController(m_CurrentController)->GetProfile(m_CurrentProfile)->getMacros(); @@ -288,6 +298,8 @@ void XmlWritter::CreateConfigurationNodes(xmlNodePtr parent_node) CreateJoystickCorrectionsNodes(node); + CreateRotationNode(node); + CreateForceFeedbackNode(node); CreateMacrosNode(node); @@ -356,7 +368,7 @@ int XmlWritter::WriteConfigFile(const string& directory, const string& file) #ifndef WIN32 if(ret != -1 && gfile_makeown(path.c_str()) < 0) { - ret = -1; + ret = -1; } #endif From f71b94d211da9a79d06daea4b33f5ee0583e2130 Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:36:23 -0500 Subject: [PATCH 10/16] Wheel rotation class to structure related data. --- .../gimxconfigeditor/include/WheelRotation.h | 28 +++++++++++++++ shared/gimxconfigeditor/src/WheelRotation.cpp | 34 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 shared/gimxconfigeditor/include/WheelRotation.h create mode 100644 shared/gimxconfigeditor/src/WheelRotation.cpp diff --git a/shared/gimxconfigeditor/include/WheelRotation.h b/shared/gimxconfigeditor/include/WheelRotation.h new file mode 100644 index 00000000..7d013df8 --- /dev/null +++ b/shared/gimxconfigeditor/include/WheelRotation.h @@ -0,0 +1,28 @@ +/* + Copyright (c) 2017 Mathieu Laurendeau + License: GPLv3 + */ + +#ifndef WHEELROTATION_H +#define WHEELROTATION_H + +#include "Device.h" + +class WheelRotation { +public: + WheelRotation(); + WheelRotation(string deviceName, string deviceId, string rotation); + virtual ~WheelRotation(); + WheelRotation(const WheelRotation& other); + WheelRotation& operator=(const WheelRotation& other); + bool operator==(const WheelRotation& other) const; + Device* GetJoystick() { return &m_Joystick; } + void SetJoystick(Device val) { m_Joystick = val; } + string GetRotation() { return m_Rotation; } + void SetRotation(string rotation) { m_Rotation = rotation; } +protected: +private: + Device m_Joystick; + string m_Rotation; +}; +#endif \ No newline at end of file diff --git a/shared/gimxconfigeditor/src/WheelRotation.cpp b/shared/gimxconfigeditor/src/WheelRotation.cpp new file mode 100644 index 00000000..cb04fb82 --- /dev/null +++ b/shared/gimxconfigeditor/src/WheelRotation.cpp @@ -0,0 +1,34 @@ +/* + Copyright (c) 2017 Mathieu Laurendeau + License: GPLv3 + */ + +#include + +WheelRotation::WheelRotation() : m_Rotation("900") { + +} + +WheelRotation::WheelRotation(string deviceName, string deviceId, string rotation) : m_Joystick("joystick", deviceName, deviceId), m_Rotation(rotation) { + +} + +WheelRotation::~WheelRotation() { + +} + +WheelRotation::WheelRotation(const WheelRotation& other) : m_Joystick(other.m_Joystick), m_Rotation(other.m_Rotation) { + +} + +WheelRotation& WheelRotation::operator=(const WheelRotation& rhs) { + if (this == &rhs) return *this; // handle self assignment + m_Joystick = rhs.m_Joystick; + m_Rotation = rhs.m_Rotation; + return *this; +} + +bool WheelRotation::operator==(const WheelRotation& other) const { + return m_Joystick == other.m_Joystick + && m_Rotation == other.m_Rotation; +} \ No newline at end of file From 4cafd96364d1a6ceff38f316b84eb934cf6e6bec Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:37:03 -0500 Subject: [PATCH 11/16] Additional logic to set rotation prop within controller logic. --- core/controller.c | 11 +++++++++-- core/controller.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/controller.c b/core/controller.c index d2f48431..08e330be 100644 --- a/core/controller.c +++ b/core/controller.c @@ -1206,6 +1206,8 @@ int adapter_start() adapter->ff_core = haptic_core_init(source, adapter->haptic_sink_joystick); const s_haptic_core_tweaks * tweaks = cfg_get_ffb_tweaks(i); adapter_set_haptic_tweaks(i, tweaks); + const s_haptic_core_wheel_rotation* rotation = cfg_get_wheel_rotation(i); + adapter_set_haptic_wheel_rotation(i, rotation); } if(is_gimx_adapter(i)) @@ -1642,7 +1644,12 @@ void adapter_set_haptic_sink(int adapter, int joystick, int force) } } -void adapter_set_haptic_tweaks(int adapter, const s_haptic_core_tweaks * tweaks) +void adapter_set_haptic_tweaks(int adapter, const s_haptic_core_tweaks* tweaks) { - haptic_core_set_tweaks(adapters[adapter].ff_core, tweaks); + haptic_core_set_tweaks(adapters[adapter].ff_core, tweaks); +} + +void adapter_set_haptic_wheel_rotation(int adapter, const s_haptic_core_wheel_rotation* rot) +{ + haptic_core_set_rotation(adapters[adapter].ff_core, rot); } diff --git a/core/controller.h b/core/controller.h index b0db84bc..a667ff83 100644 --- a/core/controller.h +++ b/core/controller.h @@ -105,5 +105,6 @@ int adapter_forward_interrupt_in(int adapter, unsigned char* data, unsigned char void adapter_set_haptic_sink(int adapter, int joystick, int force); void adapter_set_haptic_tweaks(int adapter, const s_haptic_core_tweaks * tweaks); +void adapter_set_haptic_wheel_rotation(int adapter, const s_haptic_core_wheel_rotation* rot); #endif /* CONTROLLER_H_ */ From f3419f9eb5ceb6297c4faeca1787e6db5e5d3dab Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:37:31 -0500 Subject: [PATCH 12/16] Init wheel rotation struct. --- core/gimx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/gimx.c b/core/gimx.c index 700cae94..b5f23251 100755 --- a/core/gimx.c +++ b/core/gimx.c @@ -377,6 +377,7 @@ int main(int argc, char *argv[]) cfg_intensity_init(); cfg_init_ffb_tweaks(); + cfg_init_wheel_rotations(); if(read_config_file(gimx_params.config_file) < 0) { @@ -393,7 +394,7 @@ int main(int argc, char *argv[]) cfg_intensity_init(); cfg_init_ffb_tweaks(); - + cfg_init_wheel_rotations(); read_config_file(gimx_params.config_file); } From ae68d298f58be869fc6aee037ac8e0e951ea7deb Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:38:12 -0500 Subject: [PATCH 13/16] Add WheelRotation field to profile. --- shared/gimxconfigeditor/include/Profile.h | 4 ++++ shared/gimxconfigeditor/src/Profile.cpp | 26 ++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/shared/gimxconfigeditor/include/Profile.h b/shared/gimxconfigeditor/include/Profile.h index 41927afa..2e394936 100644 --- a/shared/gimxconfigeditor/include/Profile.h +++ b/shared/gimxconfigeditor/include/Profile.h @@ -14,6 +14,7 @@ #include "MouseOptions.h" #include "JoystickCorrection.h" #include "ForceFeedback.h" +#include "WheelRotation.h" #include class Profile @@ -33,6 +34,8 @@ class Profile void SetJoystickCorrectionsList(std::list val) { m_JoystickCorrectionsList = val; } ForceFeedback* GetForceFeedback() { return &m_ForceFeedback; } void SetForceFeedback(ForceFeedback val) { m_ForceFeedback = val; } + WheelRotation* GetWheelRotation() { return &m_WheelRotation; } + void SetWheelRotation(WheelRotation val) { m_WheelRotation = val; } std::list* GetButtonMapperList() { return &m_ButtonMappers; } std::list* GetAxisMapperList() { return &m_AxisMappers; } void SetButtonMappers(std::list bml) { m_ButtonMappers = bml; } @@ -50,6 +53,7 @@ class Profile std::list m_AxisMappers; std::list m_JoystickCorrectionsList; ForceFeedback m_ForceFeedback; + WheelRotation m_WheelRotation; std::string m_Macros; }; diff --git a/shared/gimxconfigeditor/src/Profile.cpp b/shared/gimxconfigeditor/src/Profile.cpp index 310efd6f..f04f6208 100644 --- a/shared/gimxconfigeditor/src/Profile.cpp +++ b/shared/gimxconfigeditor/src/Profile.cpp @@ -17,7 +17,7 @@ Profile::~Profile() Profile::Profile(const Profile& other):m_Trigger(other.m_Trigger), m_IntensityList(other.m_IntensityList), m_MouseOptionsList(other.m_MouseOptionsList), m_ButtonMappers(other.m_ButtonMappers), m_AxisMappers(other.m_AxisMappers), - m_JoystickCorrectionsList(other.m_JoystickCorrectionsList), m_ForceFeedback(other.m_ForceFeedback), m_Macros(other.m_Macros) + m_JoystickCorrectionsList(other.m_JoystickCorrectionsList), m_ForceFeedback(other.m_ForceFeedback), m_WheelRotation(other.m_WheelRotation), m_Macros(other.m_Macros) { //copy ctor } @@ -32,6 +32,7 @@ Profile& Profile::operator=(const Profile& rhs) m_AxisMappers = rhs.m_AxisMappers; m_JoystickCorrectionsList = rhs.m_JoystickCorrectionsList; m_ForceFeedback = rhs.m_ForceFeedback; + m_WheelRotation = rhs.m_WheelRotation; m_Macros = rhs.m_Macros; return *this; } @@ -62,9 +63,13 @@ bool Profile::IsEmpty() { return false; } - if(m_ForceFeedback.GetJoystick()->GetType().size()) + if (m_ForceFeedback.GetJoystick()->GetType().size()) { - return false; + return false; + } + if (m_WheelRotation.GetJoystick()->GetType().size()) + { + return false; } if(!m_Macros.empty()) { @@ -76,11 +81,12 @@ bool Profile::IsEmpty() bool Profile::operator==(const Profile &other) const { return m_Trigger == other.m_Trigger - && m_IntensityList == other.m_IntensityList - && m_MouseOptionsList == other.m_MouseOptionsList - && m_ButtonMappers == other.m_ButtonMappers - && m_AxisMappers == other.m_AxisMappers - && m_JoystickCorrectionsList == other.m_JoystickCorrectionsList - && m_ForceFeedback == other.m_ForceFeedback - && m_Macros == other.m_Macros; + && m_IntensityList == other.m_IntensityList + && m_MouseOptionsList == other.m_MouseOptionsList + && m_ButtonMappers == other.m_ButtonMappers + && m_AxisMappers == other.m_AxisMappers + && m_JoystickCorrectionsList == other.m_JoystickCorrectionsList + && m_ForceFeedback == other.m_ForceFeedback + && m_WheelRotation == other.m_WheelRotation + && m_Macros == other.m_Macros; } From e2c7f45727366545aa3f80a6b478cbc2c43c0e13 Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:38:47 -0500 Subject: [PATCH 14/16] Git Ignore .vs and setup folders. --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 82038178..4394cabc 100644 --- a/.gitignore +++ b/.gitignore @@ -59,5 +59,3 @@ core/test/haptic/ff_lg_test loader/gimx-loader /.vs /setup -/setup_720 -/setup_640 From b10768452f236b9fcfd6e49c59b55f4c5c34fa2c Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 21:42:34 -0500 Subject: [PATCH 15/16] Missed setter for rotationTweaks. --- core/haptic/haptic_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/haptic/haptic_core.c b/core/haptic/haptic_core.c index 69624f1e..8d7bf8cb 100644 --- a/core/haptic/haptic_core.c +++ b/core/haptic/haptic_core.c @@ -157,4 +157,5 @@ void haptic_core_set_rotation(struct haptic_core* core, const s_haptic_core_whee ginfo("wheel lock=%d\n", rotation->rotation); } } + core->rotationTweaks = *rotation; } From 2b1dfb7c50f67e293c5cf428b3b7206897c7017a Mon Sep 17 00:00:00 2001 From: Tad Tarrant <69368213+crowbarmaster@users.noreply.github.com> Date: Thu, 23 Jan 2025 21:48:03 -0500 Subject: [PATCH 16/16] Haptic sink caps enum added for Range. Define as cap. --- core/haptic/haptic_sink.h | 1 + core/haptic/sink/haptic_sink_lg.c | 2 +- core/haptic/sink/haptic_sink_os.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/haptic/haptic_sink.h b/core/haptic/haptic_sink.h index e6b279bd..b0fbb61b 100644 --- a/core/haptic/haptic_sink.h +++ b/core/haptic/haptic_sink.h @@ -21,6 +21,7 @@ typedef enum { E_HAPTIC_SINK_CAP_CONSTANT = (1 << 1), E_HAPTIC_SINK_CAP_SPRING = (1 << 2), E_HAPTIC_SINK_CAP_DAMPER = (1 << 3), + E_HAPTIC_SINK_CAP_RANGE = (1 << 4), } e_haptic_sink_caps; typedef struct { diff --git a/core/haptic/sink/haptic_sink_lg.c b/core/haptic/sink/haptic_sink_lg.c index c680b6b7..d614c12e 100644 --- a/core/haptic/sink/haptic_sink_lg.c +++ b/core/haptic/sink/haptic_sink_lg.c @@ -379,7 +379,7 @@ static s_haptic_core_ids haptic_sink_lg_ids[] = { static s_haptic_sink sink_lg = { .name = "haptic_sink_lg", .ids = haptic_sink_lg_ids, - .caps = E_HAPTIC_SINK_CAP_CONSTANT | E_HAPTIC_SINK_CAP_SPRING | E_HAPTIC_SINK_CAP_DAMPER, + .caps = E_HAPTIC_SINK_CAP_CONSTANT | E_HAPTIC_SINK_CAP_SPRING | E_HAPTIC_SINK_CAP_DAMPER | E_HAPTIC_SINK_CAP_RANGE, .init = haptic_sink_lg_init, .clean = haptic_sink_lg_clean, .process = haptic_sink_lg_process, diff --git a/core/haptic/sink/haptic_sink_os.c b/core/haptic/sink/haptic_sink_os.c index 52464ee5..9847cdbe 100644 --- a/core/haptic/sink/haptic_sink_os.c +++ b/core/haptic/sink/haptic_sink_os.c @@ -142,7 +142,7 @@ static s_haptic_core_ids haptic_sink_os_ids[] = { static s_haptic_sink sink_os = { .name = "haptic_sink_os", .ids = haptic_sink_os_ids, - .caps = E_HAPTIC_SINK_CAP_RUMBLE | E_HAPTIC_SINK_CAP_CONSTANT | E_HAPTIC_SINK_CAP_SPRING | E_HAPTIC_SINK_CAP_DAMPER, + .caps = E_HAPTIC_SINK_CAP_RUMBLE | E_HAPTIC_SINK_CAP_CONSTANT | E_HAPTIC_SINK_CAP_SPRING | E_HAPTIC_SINK_CAP_DAMPER | E_HAPTIC_SINK_CAP_RANGE, .init = haptic_sink_os_init, .clean = haptic_sink_os_clean, .process = haptic_sink_os_process,