Njoy: added an option to choose what kind of analog filtering you want. it should be changeable when you choose to view advanced settings. this solved my analog/digital config problems i had and it *should* still work for those who had np with Jpeterson's change. i was told the wiimote had the same problem (makes sense) but im not sure if alot of ppl had that problem with their controllers so i have kept it as an ini changeable option only (set AdvancedMapFilter to True to use the same filtering as Njoy 0.3 does with AdvancedMapFilter enabled.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2180 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
1026b3b6f1
commit
2ff2852771
|
@ -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;
|
||||
|
|
|
@ -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<CONTROLLER_INFO> &_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);
|
||||
|
|
|
@ -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);
|
||||
// ======================================
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -168,6 +168,7 @@ void Config::Save(int Slot)
|
|||
|
||||
file.Set(SectionName.c_str(), "Diagonal", PadMapping[i].SDiagonal);
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
@ -521,6 +522,7 @@ void ConfigBox::UpdateGUI(int _notebookpage)
|
|||
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(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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue