diff --git a/Source/Core/InputCommon/Src/SDL.cpp b/Source/Core/InputCommon/Src/SDL.cpp index 67c4b97b31..80d3b91308 100644 --- a/Source/Core/InputCommon/Src/SDL.cpp +++ b/Source/Core/InputCommon/Src/SDL.cpp @@ -240,14 +240,23 @@ void GetJoyState(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, in // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ /* Function: We have to avoid very big values to becuse some triggers are -0x8000 in the unpressed state (and then go from -0x8000 to 0x8000 as they are fully pressed) */ -bool AvoidValues(int value) +bool AvoidValues(int value,int AdvancedMapFilter) { // Avoid detecting very small or very big (for triggers) values - if( (value > -0x2000 && value < 0x2000) // Small values - || (value < -0x6000 || value > 0x6000)) // Big values - return true; // Avoid + if( (value > -0x2000 && value < 0x2000) )// Small values + { + return true; //Avoid + } else - return false; // Keep + { + if (!AdvancedMapFilter) + { + if (value < -0x6000 || value > 0x6000) // Big values + return true; //Avoid + } + return false; //Keep + } + } @@ -255,7 +264,7 @@ bool AvoidValues(int value) // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ void GetButton(SDL_Joystick *joy, int ControllerID, int buttons, int axes, int hats, int &KeyboardKey, int &value, int &type, int &pressed, bool &Succeed, bool &Stop, - bool LeftRight, bool Axis, bool XInput, bool Button, bool Hat) + bool LeftRight, bool Axis, bool XInput, bool Button, bool Hat , int FilterSet) { // It needs the wxWidgets excape keycode static const int WXK_ESCAPE = 27; @@ -270,7 +279,7 @@ void GetButton(SDL_Joystick *joy, int ControllerID, int buttons, int axes, int h { value = SDL_JoystickGetAxis(joy, i); - if(AvoidValues(value)) continue; // Avoid values + if(AvoidValues(value,FilterSet)) continue; // Avoid values pressed = i + (LeftRight ? 1000 : 0); // Identify the analog triggers type = InputCommon::CTL_AXIS; diff --git a/Source/Core/InputCommon/Src/SDL.h b/Source/Core/InputCommon/Src/SDL.h index e54895d7cd..515b8f9b39 100644 --- a/Source/Core/InputCommon/Src/SDL.h +++ b/Source/Core/InputCommon/Src/SDL.h @@ -86,6 +86,7 @@ struct CONTROLLER_MAPPING // GC PAD MAPPING int triggertype; // Triggers range std::string SDiagonal; bool bSquareToCircle; + bool bFilterSettings; int eventnum; // Linux Event Number, Can't be found dynamically yet }; @@ -180,6 +181,7 @@ struct CONTROLLER_MAPPING_NEW // GC PAD MAPPING int triggertype; // SDL or XInput trigger std::string SDiagonal; bool bSquareToCircle; + bool bFilterSettings; }; //////////////////////////// @@ -191,7 +193,7 @@ struct CONTROLLER_MAPPING_NEW // GC PAD MAPPING // General functions bool SearchDevices(std::vector &_joyinfo, int &NumPads, int &NumGoodPads); void GetJoyState(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, int controller, int NumButtons); -void GetButton(SDL_Joystick*, int,int,int,int, int&,int&,int&,int&,bool&,bool&, bool,bool,bool,bool,bool); +void GetButton(SDL_Joystick*, int,int,int,int, int&,int&,int&,int&,bool&,bool&, bool,bool,bool,bool,bool,int); // Value conversion int Pad_Convert(int _val); diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp index bcdf87cdb1..3d0363a83a 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp @@ -91,6 +91,7 @@ void Config::Load(bool ChangePad) iniFile.Get(SectionName.c_str(), "TriggerType", &WiiMoteEmu::PadMapping[i].triggertype, 0); iniFile.Get(SectionName.c_str(), "Diagonal", &WiiMoteEmu::PadMapping[i].SDiagonal, "100%"); iniFile.Get(SectionName.c_str(), "SquareToCircle", &WiiMoteEmu::PadMapping[i].bSquareToCircle, false); + iniFile.Get(SectionName.c_str(), "AdvancedMapFilter", &WiiMoteEmu::PadMapping[i].bFilterSettings,false); } // ============================= Console::Print("Load()\n"); @@ -153,6 +154,7 @@ void Config::Save() iniFile.Set(SectionName.c_str(), "TriggerType", WiiMoteEmu::PadMapping[i].triggertype); //iniFile.Set(SectionName.c_str(), "Diagonal", PadMapping[i].SDiagonal); //iniFile.Set(SectionName.c_str(), "SquareToCircle", PadMapping[i].bSquareToCircle); + iniFile.Set(SectionName.c_str(), "AdvancedMapFilter", WiiMoteEmu::PadMapping[i].bFilterSettings); // ====================================== } diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp index e745bca5e5..11af6123fd 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp @@ -254,6 +254,8 @@ void ConfigDialog::DoGetButtons(int GetId) bool Hat = false; // No hats allowed + bool AdvancedMapFilter = WiiMoteEmu::PadMapping[Controller].bFilterSettings; + // Values used in this function char format[128]; int Seconds = 4; // Seconds to wait for @@ -312,7 +314,7 @@ void ConfigDialog::DoGetButtons(int GetId) InputCommon::GetButton( WiiMoteEmu::joyinfo[PadID].joy, PadID, WiiMoteEmu::joyinfo[PadID].NumButtons, WiiMoteEmu::joyinfo[PadID].NumAxes, WiiMoteEmu::joyinfo[PadID].NumHats, g_Pressed, value, type, pressed, Succeed, Stop, - LeftRight, Axis, XInput, Button, Hat); + LeftRight, Axis, XInput, Button, Hat, AdvancedMapFilter); } // ========================= Check for keys diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp index 2a4e26045f..36094b6e9c 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp @@ -167,7 +167,8 @@ void Config::Save(int Slot) file.Set(SectionName.c_str(), "eventnum", PadMapping[i].eventnum); file.Set(SectionName.c_str(), "Diagonal", PadMapping[i].SDiagonal); - file.Set(SectionName.c_str(), "SquareToCircle", PadMapping[i].bSquareToCircle); + file.Set(SectionName.c_str(), "SquareToCircle", PadMapping[i].bSquareToCircle); + file.Set(SectionName.c_str(), "AdvancedMapFilter", PadMapping[i].bFilterSettings); // ====================================== // Debugging @@ -254,6 +255,7 @@ void Config::Load(bool ChangePad, bool ChangeSaveByID) file.Get(SectionName.c_str(), "Diagonal", &PadMapping[i].SDiagonal, "100%"); file.Get(SectionName.c_str(), "SquareToCircle", &Tmp, false); PadMapping[i].bSquareToCircle = Tmp; + file.Get(SectionName.c_str(), "AdvancedMapFilter", &Tmp,false); PadMapping[i].bFilterSettings = Tmp; // ============================= // Debugging diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp index 438877fd2c..fa9dc549ad 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp @@ -83,6 +83,7 @@ BEGIN_EVENT_TABLE(ConfigBox,wxDialog) // Advanced settings EVT_COMBOBOX(IDCB_MAINSTICK_DIAGONAL, ConfigBox::ChangeSettings) EVT_CHECKBOX(IDCB_MAINSTICK_S_TO_C, ConfigBox::ChangeSettings) + EVT_CHECKBOX(IDFILTER_SETTINGS, ConfigBox::ChangeSettings) EVT_BUTTON(IDB_SHOULDER_L, ConfigBox::GetButtons) EVT_BUTTON(IDB_SHOULDER_R, ConfigBox::GetButtons) @@ -520,7 +521,8 @@ void ConfigBox::UpdateGUI(int _notebookpage) m_Controller[_notebookpage]->FindItem(IDC_CONTROLTYPE)->Enable(Enabled); m_Controller[_notebookpage]->FindItem(IDC_TRIGGERTYPE)->Enable(Enabled && XInput); m_Controller[_notebookpage]->FindItem(IDCB_MAINSTICK_DIAGONAL)->Enable(Enabled); - m_Controller[_notebookpage]->FindItem(IDCB_MAINSTICK_S_TO_C)->Enable(Enabled); + m_Controller[_notebookpage]->FindItem(IDCB_MAINSTICK_S_TO_C)->Enable(Enabled); + m_Controller[_notebookpage]->FindItem(IDFILTER_SETTINGS)->Enable(Enabled); #endif // Replace the harder to understand -1 with "" for the sake of user friendliness @@ -896,8 +898,10 @@ void ConfigBox::CreateGUIControls() "This will convert a square stick radius to a circle stick radius like the one that the actual GameCube pad produce." " That is also the input the games expect to see." )); + AdvancedMapFilter[i] = new wxCheckBox(m_Controller[i],IDFILTER_SETTINGS,_("Advanced Controller filtering")); m_gStatusInSettings[i]->Add(m_CBS_to_C[i], 0, (wxALL), 4); + m_gStatusInSettings[i]->Add(AdvancedMapFilter[i],0,(wxALL),4); m_gStatusInSettings[i]->Add(m_gStatusInSettingsH[i], 0, (wxLEFT | wxRIGHT | wxBOTTOM), 4); m_gStatusInSettingsH[i]->Add(m_STDiagonal[i], 0, wxTOP, 3); diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h index bfc022a9b6..b41fb6c7a8 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h @@ -121,6 +121,7 @@ class ConfigBox : public wxDialog wxGridBagSizer * m_GBAdvancedMainStick[4]; wxStaticText *m_TStatusIn[4], *m_TStatusOut[4], *m_STDiagonal[4]; wxComboBox *m_CoBDiagonal[4]; wxCheckBox *m_CBS_to_C[4]; + wxCheckBox *AdvancedMapFilter[4]; wxStaticBoxSizer *m_gStatusTriggers[4]; // Triggers wxStaticText *m_TStatusTriggers[4]; @@ -219,7 +220,7 @@ class ConfigBox : public wxDialog IDT_STATUS_IN, IDT_STATUS_OUT, // Advaced settings - IDCB_MAINSTICK_DIAGONAL, IDCB_MAINSTICK_S_TO_C, IDT_MAINSTICK_DIAGONAL, IDT_TRIGGERS, + IDCB_MAINSTICK_DIAGONAL, IDCB_MAINSTICK_S_TO_C, IDT_MAINSTICK_DIAGONAL, IDT_TRIGGERS,IDFILTER_SETTINGS, // Timers IDTM_CONSTANT, IDTM_BUTTON, diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp index 51646b7859..2506053c49 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp @@ -79,6 +79,8 @@ void ConfigBox::UpdateGUIButtonMapping(int controller) m_Deadzone[controller]->SetSelection(PadMapping[controller].deadzone); m_CoBDiagonal[controller]->SetValue(wxString::FromAscii(PadMapping[controller].SDiagonal.c_str())); m_CBS_to_C[controller]->SetValue(PadMapping[controller].bSquareToCircle); + AdvancedMapFilter[controller]->SetValue(PadMapping[controller].bFilterSettings); + //LogMsg("m_TriggerType[%i] = %i\n", controller, PadMapping[controller].triggertype); @@ -122,6 +124,8 @@ void ConfigBox::SaveButtonMapping(int controller, bool DontChangeId, int FromSlo PadMapping[controller].deadzone = m_Deadzone[FromSlot]->GetSelection(); PadMapping[controller].SDiagonal = m_CoBDiagonal[FromSlot]->GetLabel().mb_str(); PadMapping[controller].bSquareToCircle = m_CBS_to_C[FromSlot]->IsChecked(); + PadMapping[controller].bFilterSettings = AdvancedMapFilter[FromSlot]->IsChecked(); + // The analog buttons m_JoyAnalogMainX[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[InputCommon::CTL_MAIN_X] = value; tmp.clear(); @@ -295,6 +299,8 @@ void ConfigBox::DoGetButtons(int GetId) bool Hat = (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT) // All DPads && (PadMapping[Controller].controllertype == InputCommon::CTL_DPAD_HAT); // Not with the hat option defined + bool AdvancedMapFilter = PadMapping[Controller].bFilterSettings; + // Values used in this function char format[128]; int Seconds = 4; // Seconds to wait for @@ -349,7 +355,7 @@ void ConfigBox::DoGetButtons(int GetId) InputCommon::GetButton( joyinfo[PadID].joy, PadID, joyinfo[PadID].NumButtons, joyinfo[PadID].NumAxes, joyinfo[PadID].NumHats, g_Pressed, value, type, pressed, Succeed, Stop, - LeftRight, Axis, XInput, Button, Hat); + LeftRight, Axis, XInput, Button, Hat, AdvancedMapFilter); } // ========================= Check for keys