diff --git a/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj b/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj
index 8a16076ebf..e7ebb69766 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj
+++ b/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj
@@ -1,7 +1,7 @@
+
+
+
+
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
);
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp
index 3e9f5614a4..ad6e0b6305 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp
@@ -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
+// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
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"));
// --------------------------------------------------------------------
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp
index 77082b721f..9a426b0307 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp
@@ -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)
{
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/XInput.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/XInput.cpp
new file mode 100644
index 0000000000..66ba7ef10e
--- /dev/null
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/XInput.cpp
@@ -0,0 +1,133 @@
+//////////////////////////////////////////////////////////////////////////////////////////
+//
+// Licensetype: GNU General Public License (GPL)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 2.0.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License 2.0 for more details.
+//
+// A copy of the GPL 2.0 should have been included with the program.
+// If not, see http://www.gnu.org/licenses/
+//
+// Official SVN repository and contact information can be found at
+// http://code.google.com/p/dolphin-emu/
+//
+//////////////////////////////////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// File description
+/* ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+ Function: This file will get the status of the analog triggers of any connected XInput device.
+ This code was made with the help of SimpleController.cpp in the June 2008 Microsoft DirectX SDK
+ Samples.
+
+///////////////////////////////////////////////////// */
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Includes
+// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+#include
+#include // XInput API
+
+#include "nJoy.h" // Local
+///////////////////////////////////////////////
+
+
+namespace XInput
+{
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Declarations
+// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+
+#define MAX_CONTROLLERS 4 // XInput handles up to 4 controllers
+
+struct CONTROLER_STATE
+{
+ XINPUT_STATE state;
+ bool bConnected;
+};
+CONTROLER_STATE g_Controllers[MAX_CONTROLLERS];
+///////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Init
+// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+/* Function: Calculate the number of connected XInput devices
+ Todo: Implement this to figure out if there are multiple XInput controllers connected,
+ we currently only try to connect to XInput device 0 */
+void Init()
+{
+ // Init state
+ //ZeroMemory( g_Controllers, sizeof( CONTROLER_STATE ) * MAX_CONTROLLERS );
+
+ // Declaration
+ DWORD dwResult;
+
+ // Calculate the number of connected XInput devices
+ for( DWORD i = 0; i < MAX_CONTROLLERS; i++ )
+ {
+ // Simply get the state of the controller from XInput.
+ dwResult = XInputGetState( i, &g_Controllers[i].state );
+
+ if( dwResult == ERROR_SUCCESS )
+ g_Controllers[i].bConnected = true;
+ else
+ g_Controllers[i].bConnected = false;
+ }
+
+}
+///////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Get the trigger status
+// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+int GetXI(int Controller, int Button)
+{
+ // Update the internal status
+ DWORD dwResult;
+ dwResult = XInputGetState( Controller, &g_Controllers[Controller].state );
+
+ if( dwResult != ERROR_SUCCESS ) return -1;
+
+ switch(Button)
+ {
+ case XI_TRIGGER_L:
+ return g_Controllers[0].state.Gamepad.bLeftTrigger;
+
+ case XI_TRIGGER_R:
+ return g_Controllers[0].state.Gamepad.bRightTrigger;
+
+ default:
+ return 0;
+ }
+}
+///////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Check if a certain controller is connected
+// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+bool IsConnected(int Controller)
+{
+ DWORD dwResult = XInputGetState( Controller, &g_Controllers[Controller].state );
+
+ // Update the connected status
+ if( dwResult == ERROR_SUCCESS )
+ return true;
+ else
+ return false;
+}
+///////////////////////////////////////////
+
+} // XInput
\ No newline at end of file
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/XInput.h b/Source/Plugins/Plugin_nJoy_SDL/Src/XInput.h
new file mode 100644
index 0000000000..32b5088f02
--- /dev/null
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/XInput.h
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////////////////////
+//
+// Licensetype: GNU General Public License (GPL)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 2.0.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License 2.0 for more details.
+//
+// A copy of the GPL 2.0 should have been included with the program.
+// If not, see http://www.gnu.org/licenses/
+//
+// Official SVN repository and contact information can be found at
+// http://code.google.com/p/dolphin-emu/
+//
+//////////////////////////////////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Includes
+// ŻŻŻŻŻŻŻŻŻŻ
+#include
+//////////////////////////////
+
+
+namespace XInput
+{
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Declarations
+// ŻŻŻŻŻŻŻŻŻŻ
+void Init();
+int GetXI(int Controller, int Button);
+bool IsConnected(int Controller);
+//////////////////////////////
+
+} // XInput
\ No newline at end of file
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp
index 2e5f0394e0..0e64eba9e6 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp
@@ -434,8 +434,8 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
int i_main_stick_y = -joystate[_numPAD].axis[CTL_MAIN_Y];
int i_sub_stick_x = joystate[_numPAD].axis[CTL_SUB_X];
int i_sub_stick_y = -joystate[_numPAD].axis[CTL_SUB_Y];
- int SDLTriggerLeft = joystate[_numPAD].axis[CTL_L_SHOULDER];
- int SDLTriggerRight = joystate[_numPAD].axis[CTL_R_SHOULDER];
+ int TriggerLeft = joystate[_numPAD].axis[CTL_L_SHOULDER];
+ int TriggerRight = joystate[_numPAD].axis[CTL_R_SHOULDER];
// Check if we should make adjustments
if(g_Config.bSquareToCircle.at(_numPAD))
@@ -452,8 +452,11 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
u8 sub_stick_y = Pad_Convert(i_sub_stick_y);
// Convert the triggers values
- u8 TriggerLeft = Pad_Convert(SDLTriggerLeft, TriggerType);
- u8 TriggerRight = Pad_Convert(SDLTriggerRight, TriggerType);
+ if(joysticks[_numPAD].triggertype == CTL_TRIGGER_SDL)
+ {
+ TriggerLeft = Pad_Convert(TriggerLeft);
+ TriggerRight = Pad_Convert(TriggerRight);
+ }
// Set Deadzones (perhaps out of function?)
int deadzone = (int)(((float)(128.00/100.00)) * (float)(joysticks[_numPAD].deadzone + 1));
@@ -478,7 +481,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
_pPADStatus->button |= PAD_TRIGGER_L;
_pPADStatus->triggerLeft = TriggerValue;
}
- else if(joystate[_numPAD].axis[CTL_L_SHOULDER])
+ else if(TriggerLeft > 0)
_pPADStatus->triggerLeft = TriggerLeft;
if (joystate[_numPAD].buttons[CTL_R_SHOULDER])
@@ -486,7 +489,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
_pPADStatus->button |= PAD_TRIGGER_R;
_pPADStatus->triggerRight = TriggerValue;
}
- else if(joystate[_numPAD].axis[CTL_R_SHOULDER])
+ else if(TriggerRight > 0)
_pPADStatus->triggerRight = TriggerRight;
// Update the buttons in analog mode to
@@ -546,7 +549,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
Console::Print(
"Trigger type: %s Left:%04x Right:%04x Value:%i\n"
"D-Pad type: %s L:%i R:%i U:%i D:%i",
- (joysticks[_numPAD].triggertype ? "CTL_TRIGGER_WHOLE" : "CTL_TRIGGER_HALF"),
+ (joysticks[_numPAD].triggertype ? "CTL_TRIGGER_XINPUT" : "CTL_TRIGGER_SDL"),
TriggerLeft, TriggerRight, TriggerValue,
(joysticks[_numPAD].controllertype ? "CTL_DPAD_CUSTOM" : "CTL_DPAD_HAT"),
0, 0, 0, 0
@@ -584,38 +587,24 @@ unsigned int PAD_GetAttachedPads()
(-32768 to 32767). The value used for the gamecube controller is an unsigned
char u8 (0 to 255) with neutral at 0x80 (128), so that it's equivalent to a signed
-128 to 127.
-
- type = CTL_TRIGGER_WHOLE, !type = CTL_TRIGGER_HALF
- */
+*/
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
-u8 Pad_Convert(int _val, int _type)
+int Pad_Convert(int _val)
{
/* If the limits on joystate[].axis[] actually is a u16 then we don't need this
but if it's not actually limited to that we need to apply these limits */
if(_val > 32767) _val = 32767; // upper limit
if(_val < -32768) _val = -32768; // lower limit
-
- /* The XBox 360 pad only goes to 0x7f80 instead of 0x8000 (0x80 below the regular maximum)
- so I add the extra distance here */
- if (_val >= 0x7f7f ) _val = 0x7fff;
- if (_val <= -0x7f80 ) _val = -0x8000;
-
- // Convert (-0x8000 to 0x7fff)
- if(!_type && _val < 0) _val = -_val - 1;
-
- // Convert (0x7fff to 0xfffe to 0xffff)
- if(!_type) _val = (_val * 2) + 1;
// Convert the range (-0x8000 to 0x7fff) to (0 to 0xffff)
- if(_type) _val = 0x8000 +_val;
+ _val = 0x8000 +_val;
// Convert the range (-32768 to 32767) to (-128 to 127)
_val = _val >> 8;
//Console::Print("0x%04x %06i\n\n", _val, _val);
- u8 val = _val;
- return val;
+ return _val;
}
@@ -740,17 +729,21 @@ void GetJoyState(int controller)
joystate[controller].axis[CTL_MAIN_Y] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].axis[CTL_MAIN_Y]);
joystate[controller].axis[CTL_SUB_X] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].axis[CTL_SUB_X]);
joystate[controller].axis[CTL_SUB_Y] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].axis[CTL_SUB_Y]);
- joystate[controller].axis[CTL_L_SHOULDER] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].buttons[CTL_L_SHOULDER] - 1000);
- joystate[controller].axis[CTL_R_SHOULDER] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].buttons[CTL_R_SHOULDER] - 1000);
- // Adjust for the half value variant (for example the 360 pad)
- if (joysticks[controller].triggertype == CTL_TRIGGER_HALF)
+ // Update trigger axises
+ if (joysticks[controller].triggertype == CTL_TRIGGER_SDL)
{
- if (joystate[controller].axis[CTL_L_SHOULDER] < 0) joystate[controller].axis[CTL_L_SHOULDER] = 0;
- if (joystate[controller].axis[CTL_R_SHOULDER] > 0) joystate[controller].axis[CTL_R_SHOULDER] = 0;
+ joystate[controller].axis[CTL_L_SHOULDER] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].buttons[CTL_L_SHOULDER] - 1000);
+ joystate[controller].axis[CTL_R_SHOULDER] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].buttons[CTL_R_SHOULDER] - 1000);
+ }
+ else
+ {
+ joystate[controller].axis[CTL_L_SHOULDER] = XInput::GetXI(0, joysticks[controller].buttons[CTL_L_SHOULDER] - 1000);
+ joystate[controller].axis[CTL_R_SHOULDER] = XInput::GetXI(0, joysticks[controller].buttons[CTL_R_SHOULDER] - 1000);
}
/* Debugging
+ Console::ClearScreen();
Console::Print(
"Controller and handle: %i %i\n"
"Triggers:%i %i %i %i %i\n",
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h
index 629b0e6f01..88b053767c 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h
@@ -53,6 +53,7 @@
//#include "ConsoleWindow.h"
#include "Config.h" // Local
+#include "XInput.h"
#if defined(HAVE_WX) && HAVE_WX
#include "GUI/AboutBox.h"
@@ -178,8 +179,8 @@ enum
// Trigger Type
enum
{
- CTL_TRIGGER_HALF = 0, // XBox 360
- CTL_TRIGGER_WHOLE // Other pads
+ CTL_TRIGGER_SDL = 0, //
+ CTL_TRIGGER_XINPUT // The XBox 360 pad
};
enum
@@ -199,6 +200,13 @@ enum
CTL_KEY
};
+// XInput buttons
+enum
+{
+ XI_TRIGGER_L = 0,
+ XI_TRIGGER_R
+};
+
//////////////////////////////////////////////////////////////////////////////////////////
// Input vector. Todo: Save the configured keys here instead of in joystick
@@ -233,7 +241,7 @@ void DEBUG_INIT();
void DEBUG_QUIT();
void Pad_Use_Rumble(u8 _numPAD, SPADStatus* _pPADStatus); // Rumble
-u8 Pad_Convert(int _val, int _type = 1); // Value conversion
+int Pad_Convert(int _val); // Value conversion
std::vector Pad_Square_to_Circle(int _x, int _y, int _pad); // Value conversion
//void SaveConfig();