mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
nJoy: Fixed the 360 pad triggers with XInput, now they are separate triggers that work just like they should
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1953 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -138,12 +138,20 @@ void ConfigBox::PadGetStatus()
|
||||
m_JoyShoulderL[notebookpage]->GetValue().ToLong(&Left);
|
||||
m_JoyShoulderR[notebookpage]->GetValue().ToLong(&Right);
|
||||
|
||||
int SDLTriggerLeft = joystate[notebookpage].axis[CTL_L_SHOULDER];
|
||||
int SDLTriggerRight = joystate[notebookpage].axis[CTL_R_SHOULDER];
|
||||
// Get the trigger values
|
||||
int TriggerLeft = joystate[notebookpage].axis[CTL_L_SHOULDER];
|
||||
int TriggerRight = joystate[notebookpage].axis[CTL_R_SHOULDER];
|
||||
|
||||
// Convert the triggers values
|
||||
u8 TriggerLeft = Pad_Convert(SDLTriggerLeft, TriggerType);
|
||||
u8 TriggerRight = Pad_Convert(SDLTriggerRight, TriggerType);
|
||||
if (joysticks[notebookpage].triggertype == CTL_TRIGGER_SDL)
|
||||
{
|
||||
TriggerLeft = Pad_Convert(TriggerLeft);
|
||||
TriggerRight = Pad_Convert(TriggerRight);
|
||||
}
|
||||
|
||||
// If we don't have any axis selected for the shoulder buttons
|
||||
if(Left < 1000) TriggerLeft = 0;
|
||||
if(Right < 1000) TriggerRight = 0;
|
||||
|
||||
// Get the digital values
|
||||
if(Left < 1000 && joystate[notebookpage].buttons[CTL_L_SHOULDER]) TriggerLeft = TriggerValue;
|
||||
@ -196,7 +204,7 @@ std::string ShowStatus(int VirtualController)
|
||||
for(int i = 0; i < Axes; i++)
|
||||
{
|
||||
value = SDL_JoystickGetAxis(joy, i);
|
||||
StrAxes += StringFromFormat(" %i:%05i", i, value);
|
||||
StrAxes += StringFromFormat(" %i:%06i", i, value);
|
||||
}
|
||||
for(int i = 0;i < Hats; i++)
|
||||
{
|
||||
@ -210,9 +218,10 @@ std::string ShowStatus(int VirtualController)
|
||||
}
|
||||
|
||||
return StringFromFormat(
|
||||
"joysticks.ID: %p %p %p %p\n"
|
||||
"joysticks.ID: %i %i %i %i\n"
|
||||
"joysticks.controllertype, triggertype: %i %i\n"
|
||||
"Handles: %i %i %i %i\n"
|
||||
"XInput: %i %i %i\n"
|
||||
"Axes: %s\n"
|
||||
"Hats: %s\n"
|
||||
"But: %s\n"
|
||||
@ -220,6 +229,7 @@ std::string ShowStatus(int VirtualController)
|
||||
joysticks[0].ID, joysticks[1].ID, joysticks[2].ID, joysticks[3].ID,
|
||||
controllertype, triggertype,
|
||||
joy0, joy1, joy2, joy3,
|
||||
XInput::IsConnected(0), XInput::GetXI(0, XI_TRIGGER_L), XInput::GetXI(0, XI_TRIGGER_R),
|
||||
StrAxes.c_str(), StrHats.c_str(), StrBut.c_str(),
|
||||
Axes, Balls, Hats, Buttons
|
||||
);
|
||||
|
@ -53,8 +53,8 @@ static const char* DPadType[] =
|
||||
// Trigger type
|
||||
static const char* TriggerType[] =
|
||||
{
|
||||
"Half", // 0x0000 to 0x8000
|
||||
"Full", // -0x8000 to 0x8000
|
||||
"SDL", // 0x0000 to 0x8000
|
||||
"XInput", // -0x8000 to 0x8000
|
||||
};
|
||||
////////////////////////
|
||||
|
||||
@ -293,15 +293,21 @@ void ConfigBox::NotebookPageChanged(wxNotebookEvent& event)
|
||||
// Check if it has changed. If it has save the old Id and load the new Id
|
||||
if(OldId != NewId)
|
||||
DoChangeJoystick();
|
||||
|
||||
}
|
||||
|
||||
// Replace the harder to understand -1 with "" for the sake of user friendliness
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void ConfigBox::ToBlank(bool ToBlank)
|
||||
{
|
||||
if(ToBlank)
|
||||
{
|
||||
for(int i = IDB_ANALOG_MAIN_X; i <= IDB_BUTTONHALFPRESS; i++)
|
||||
#ifndef _WIN32
|
||||
if(GetButtonText(i).ToAscii() == "-1") SetButtonText(i, "");
|
||||
#else
|
||||
if(GetButtonText(i) == "-1") SetButtonText(i, "");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -360,6 +366,7 @@ void ConfigBox::UpdateGUI(int _notebookpage)
|
||||
m_JoyShoulderL[_notebookpage]->GetValue().ToLong(&Left);
|
||||
m_JoyShoulderR[_notebookpage]->GetValue().ToLong(&Right);
|
||||
bool AnalogTrigger = (Left >= 1000 || Right >= 1000);
|
||||
bool XInput = XInput::IsConnected(0);
|
||||
|
||||
m_JoyDpadUp[_notebookpage]->Show(!Hat);
|
||||
m_JoyDpadLeft[_notebookpage]->Show(!Hat);
|
||||
@ -382,6 +389,9 @@ void ConfigBox::UpdateGUI(int _notebookpage)
|
||||
m_CBSaveByIDNotice[_notebookpage]->SetValue(g_Config.bSaveByIDNotice);
|
||||
m_CBShowAdvanced[_notebookpage]->SetValue(g_Config.bShowAdvanced);
|
||||
|
||||
// Controller type values
|
||||
if (!XInput) m_TriggerType[_notebookpage]->SetSelection(CTL_TRIGGER_SDL);
|
||||
|
||||
// Advanced settings
|
||||
m_CoBDiagonal[_notebookpage]->SetValue(wxString::FromAscii(g_Config.SDiagonal.at(_notebookpage).c_str()));
|
||||
m_CBS_to_C[_notebookpage]->SetValue(g_Config.bSquareToCircle.at(_notebookpage));
|
||||
@ -396,7 +406,7 @@ void ConfigBox::UpdateGUI(int _notebookpage)
|
||||
// Controller type settings
|
||||
m_Controller[_notebookpage]->FindItem(IDC_DEADZONE)->Enable(Enabled);
|
||||
m_Controller[_notebookpage]->FindItem(IDC_CONTROLTYPE)->Enable(Enabled);
|
||||
m_Controller[_notebookpage]->FindItem(IDC_TRIGGERTYPE)->Enable(Enabled && AnalogTrigger);
|
||||
m_Controller[_notebookpage]->FindItem(IDC_TRIGGERTYPE)->Enable(Enabled && AnalogTrigger && XInput);
|
||||
m_Controller[_notebookpage]->FindItem(IDCB_MAINSTICK_DIAGONAL)->Enable(Enabled);
|
||||
m_Controller[_notebookpage]->FindItem(IDCB_MAINSTICK_S_TO_C)->Enable(Enabled);
|
||||
#endif
|
||||
@ -497,8 +507,8 @@ void ConfigBox::CreateGUIControls()
|
||||
wxAS_DPadType.Add(wxString::FromAscii(DPadType[CTL_DPAD_CUSTOM]));
|
||||
|
||||
wxArrayString wxAS_TriggerType;
|
||||
wxAS_TriggerType.Add(wxString::FromAscii(TriggerType[CTL_TRIGGER_HALF]));
|
||||
wxAS_TriggerType.Add(wxString::FromAscii(TriggerType[CTL_TRIGGER_WHOLE]));
|
||||
wxAS_TriggerType.Add(wxString::FromAscii(TriggerType[CTL_TRIGGER_SDL]));
|
||||
wxAS_TriggerType.Add(wxString::FromAscii(TriggerType[CTL_TRIGGER_XINPUT]));
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Populate the deadzone list
|
||||
@ -708,9 +718,7 @@ void ConfigBox::CreateGUIControls()
|
||||
"Use a 'hat' on your gamepad or configure a custom button for each direction."
|
||||
));
|
||||
m_TriggerType[i]->SetToolTip(wxT(
|
||||
"This is for the analog trigger settings. You can look under 'Trigger values' in the advanced settings to see"
|
||||
" which of these modes work for your gamepad. If it works correctly the unpressed to pressed range should be"
|
||||
" 0 to 255."
|
||||
"Select XInput if you want the triggers to work with the XBox 360 pad."
|
||||
));
|
||||
m_CBSaveByID[i]->SetToolTip(wxString::Format(wxT(
|
||||
"Map these settings to the selected controller device instead of to the"
|
||||
@ -861,8 +869,8 @@ void ConfigBox::CreateGUIControls()
|
||||
// --------------------------------------------------------------------
|
||||
// Debugging
|
||||
// -----------------------------
|
||||
//m_pStatusBar = new wxStaticText(this, IDT_DEBUGGING, wxT("Debugging"), wxPoint(100, 490), wxDefaultSize);
|
||||
//m_pStatusBar2 = new wxStaticText(this, IDT_DEBUGGING2, wxT("Debugging2"), wxPoint(100, 530), wxDefaultSize);
|
||||
//m_pStatusBar = new wxStaticText(this, IDT_DEBUGGING, wxT("Debugging"), wxPoint(150, 100), wxDefaultSize);
|
||||
//m_pStatusBar2 = new wxStaticText(this, IDT_DEBUGGING2, wxT("Debugging2"), wxPoint(150, 200), wxDefaultSize);
|
||||
//m_pStatusBar->SetLabel(wxString::Format("Debugging text"));
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
@ -270,12 +270,18 @@ void ConfigBox::DoGetButtons(int GetId)
|
||||
// Get the current controller
|
||||
int Controller = notebookpage;
|
||||
|
||||
// Get the controller and trigger type
|
||||
int ControllerType = joysticks[Controller].controllertype;
|
||||
int TriggerType = joysticks[Controller].triggertype;
|
||||
|
||||
// Collect the accepted buttons for this slot
|
||||
bool LeftRight = (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R);
|
||||
bool Axis = (GetId >= IDB_ANALOG_MAIN_X && GetId <= IDB_SHOULDER_R);
|
||||
bool Axis = (GetId >= IDB_ANALOG_MAIN_X && GetId <= IDB_SHOULDER_R)
|
||||
&& (TriggerType == CTL_TRIGGER_SDL);
|
||||
bool XInput = (TriggerType == CTL_TRIGGER_XINPUT);
|
||||
bool Button = (GetId >= IDB_BUTTON_A && GetId <= IDB_BUTTONHALFPRESS)
|
||||
|| (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R)
|
||||
|| (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT && joysticks[Controller].controllertype == CTL_DPAD_CUSTOM);
|
||||
|| (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT && ControllerType == CTL_DPAD_CUSTOM);
|
||||
bool Hat = (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT)
|
||||
&& (joysticks[Controller].controllertype == CTL_DPAD_HAT);
|
||||
|
||||
@ -383,6 +389,20 @@ void ConfigBox::DoGetButtons(int GetId)
|
||||
}
|
||||
}
|
||||
|
||||
// Check for a XInput trigger
|
||||
if(XInput)
|
||||
{
|
||||
for(int i = 0; i <= XI_TRIGGER_R; i++)
|
||||
{
|
||||
if(XInput::GetXI(0, i))
|
||||
{
|
||||
pressed = i + 1000;
|
||||
type = CTL_AXIS;
|
||||
Succeed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for keyboard action
|
||||
if (g_Pressed && Button)
|
||||
{
|
||||
|
Reference in New Issue
Block a user