Re-added Semi-Pressure

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4990 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
ayuanx 2010-02-02 02:39:21 +00:00
parent c28ef357f5
commit 4692f1084f
7 changed files with 96 additions and 34 deletions

View File

@ -102,8 +102,8 @@ bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_
bool AvoidValues(int value, bool NoTriggerFilter)
{
// Avoid detecting very small or very big (for triggers) values
if( (value > -200 && value < 200) // Small values
|| ((value < -0x6000 || value > 0x6000) && !NoTriggerFilter)) // Big values
if( (value > -0x1000 && value < 0x1000) // Small values
|| ((value < -0x7000 || value > 0x7000) && !NoTriggerFilter)) // Big values
return true; // Avoid
else
return false; // Keep

View File

@ -41,11 +41,13 @@ static const char* gcControlNames[] =
"Stick_Down",
"Stick_Left",
"Stick_Right",
"Stick_Semi",
"CStick_Up",
"CStick_Down",
"CStick_Left",
"CStick_Right",
"CStick_Semi",
"Shoulder_L",
"Shoulder_R",
@ -70,10 +72,12 @@ static const int gcDefaultControls[] =
VK_DOWN,
VK_LEFT,
VK_RIGHT,
VK_LSHIFT,
'I',
'K',
'J',
'L',
VK_LCONTROL,
'Q',
'W',
0x00,
@ -95,10 +99,12 @@ static const int gcDefaultControls[] =
XK_Down, // Main stick down
XK_Left, // Main stick left
XK_Right, // Main stick right
XK_Shift_L, // Main stick semi
XK_i, // C-stick up
XK_k, // C-stick down
XK_j, // C-stick left
XK_l, // C-stick right
XK_Control_L, // C-stick semi
XK_q, // L
XK_w, // R
0x00, // L semi-press
@ -122,10 +128,12 @@ static const int gcDefaultControls[] =
125, // Main stick down (down)
123, // Main stick left (left)
124, // Main stick right (right)
56, // Main stick semi (left shift)
34, // C-stick up (i)
40, // C-stick down (k)
38, // C-stick left (j)
37, // C-stick right (l)
59, // C-stick semi (left control)
12, // L (q)
13, // R (w)
-1, // L semi-press (none)
@ -182,6 +190,10 @@ void Config::Save()
file.Set(SectionName.c_str(), "Source_CStick", GCMapping[i].Stick.Sub);
file.Set(SectionName.c_str(), "Source_Shoulder", GCMapping[i].Stick.Shoulder);
file.Set(SectionName.c_str(), "Pressure_Stick", GCMapping[i].Pressure.Main);
file.Set(SectionName.c_str(), "Pressure_CStick", GCMapping[i].Pressure.Sub);
file.Set(SectionName.c_str(), "Pressure_Shoulder", GCMapping[i].Pressure.Shoulder);
// ButtonMapping
for (int x = 0; x < LAST_CONSTANT; x++)
file.Set(SectionName.c_str(), gcControlNames[x], GCMapping[i].Button[x]);
@ -225,6 +237,10 @@ void Config::Load()
file.Get(SectionName.c_str(), "Source_CStick", &GCMapping[i].Stick.Sub, 0);
file.Get(SectionName.c_str(), "Source_Shoulder", &GCMapping[i].Stick.Shoulder, 0);
file.Get(SectionName.c_str(), "Pressure_Stick", &GCMapping[i].Pressure.Main, DEF_STICK_HALF);
file.Get(SectionName.c_str(), "Pressure_CStick", &GCMapping[i].Pressure.Sub, DEF_STICK_HALF);
file.Get(SectionName.c_str(), "Pressure_Shoulder", &GCMapping[i].Pressure.Shoulder, DEF_TRIGGER_HALF);
// ButtonMapping
for (int x = 0; x < LAST_CONSTANT; x++)
file.Get(SectionName.c_str(), gcControlNames[x], &GCMapping[i].Button[x], gcDefaultControls[x]);

View File

@ -46,6 +46,9 @@ BEGIN_EVENT_TABLE(GCPadConfigDialog,wxDialog)
EVT_COMBOBOX(IDC_STICK_SOURCE, GCPadConfigDialog::ChangeSettings)
EVT_COMBOBOX(IDC_CSTICK_SOURCE, GCPadConfigDialog::ChangeSettings)
EVT_COMBOBOX(IDC_TRIGGER_SOURCE, GCPadConfigDialog::ChangeSettings)
EVT_SLIDER(IDS_STICK_PRESS, GCPadConfigDialog::ChangeSettings)
EVT_SLIDER(IDS_CSTICK_PRESS, GCPadConfigDialog::ChangeSettings)
EVT_SLIDER(IDS_TRIGGER_PRESS, GCPadConfigDialog::ChangeSettings)
EVT_BUTTON(IDB_ANALOG_LEFT_X, GCPadConfigDialog::OnAxisClick)
EVT_BUTTON(IDB_ANALOG_LEFT_Y, GCPadConfigDialog::OnAxisClick)
@ -68,10 +71,12 @@ BEGIN_EVENT_TABLE(GCPadConfigDialog,wxDialog)
EVT_BUTTON(IDB_MAIN_DOWN, GCPadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_MAIN_LEFT, GCPadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_MAIN_RIGHT, GCPadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_MAIN_SEMI, GCPadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_SUB_UP, GCPadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_SUB_DOWN, GCPadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_SUB_LEFT, GCPadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_SUB_RIGHT, GCPadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_SUB_SEMI, GCPadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_SHDR_L, GCPadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_SHDR_R, GCPadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_SHDR_SEMI_L, GCPadConfigDialog::OnButtonClick)
@ -310,6 +315,15 @@ void GCPadConfigDialog::ChangeSettings(wxCommandEvent& event)
case IDC_TRIGGER_SOURCE:
GCMapping[m_Page].Stick.Shoulder = m_Combo_TriggerSrc[m_Page]->GetSelection();
break;
case IDS_STICK_PRESS:
GCMapping[m_Page].Pressure.Main = m_Slider_Stick[m_Page]->GetValue();
break;
case IDS_CSTICK_PRESS:
GCMapping[m_Page].Pressure.Sub = m_Slider_CStick[m_Page]->GetValue();
break;
case IDS_TRIGGER_PRESS:
GCMapping[m_Page].Pressure.Shoulder = m_Slider_Trigger[m_Page]->GetValue();
break;
}
UpdateGUI();
@ -348,6 +362,9 @@ void GCPadConfigDialog::UpdateGUI()
m_Combo_StickSrc[m_Page]->SetSelection(GCMapping[m_Page].Stick.Main);
m_Combo_CStickSrc[m_Page]->SetSelection(GCMapping[m_Page].Stick.Sub);
m_Combo_TriggerSrc[m_Page]->SetSelection(GCMapping[m_Page].Stick.Shoulder);
m_Slider_Stick[m_Page]->SetValue(GCMapping[m_Page].Pressure.Main);
m_Slider_CStick[m_Page]->SetValue(GCMapping[m_Page].Pressure.Sub);
m_Slider_Trigger[m_Page]->SetValue(GCMapping[m_Page].Pressure.Shoulder);
for (int i = 0; i <= IDB_TRIGGER_R - IDB_ANALOG_LEFT_X; i++)
{
@ -439,11 +456,13 @@ void GCPadConfigDialog::CreateGUIControls()
wxT("Down"),
wxT("Left"),
wxT("Right"),
wxT("Semi"),
wxT("Up"), // C-Stick
wxT("Down"),
wxT("Left"),
wxT("Right"),
wxT("Semi"),
wxT("L"), // Triggers
wxT("R"),
@ -671,14 +690,21 @@ void GCPadConfigDialog::CreateGUIControls()
m_gButton[i]->Add(m_Sizer_Pad[x - IDB_BTN_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
else if (x <= IDB_DPAD_RIGHT)
m_gDPad[i]->Add(m_Sizer_Pad[x - IDB_BTN_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
else if (x <= IDB_MAIN_RIGHT)
else if (x <= IDB_MAIN_SEMI)
m_gStick[i]->Add(m_Sizer_Pad[x - IDB_BTN_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
else if (x <= IDB_SUB_RIGHT)
else if (x <= IDB_SUB_SEMI)
m_gCStick[i]->Add(m_Sizer_Pad[x - IDB_BTN_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
else
m_gTrigger[i]->Add(m_Sizer_Pad[x - IDB_BTN_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
}
m_Slider_Stick[i] = new wxSlider(m_Controller[i], IDS_STICK_PRESS, DEF_STICK_HALF, 0, DEF_STICK_FULL, wxDefaultPosition, wxSize(100,-1), wxSL_LABELS | wxSL_TOP);
m_gStick[i]->Add(m_Slider_Stick[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_Slider_CStick[i] = new wxSlider(m_Controller[i], IDS_CSTICK_PRESS, DEF_STICK_HALF, 0, DEF_STICK_FULL, wxDefaultPosition, wxSize(100,-1), wxSL_LABELS | wxSL_TOP);
m_gCStick[i]->Add(m_Slider_CStick[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
m_Slider_Trigger[i] = new wxSlider(m_Controller[i], IDS_TRIGGER_PRESS, DEF_TRIGGER_HALF, 0, DEF_TRIGGER_FULL, wxDefaultPosition, wxSize(100,-1), wxSL_LABELS | wxSL_TOP);
m_gTrigger[i]->Add(m_Slider_Trigger[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
// Row 4 Sizers: Button Mapping
m_sHorizMapping[i] = new wxBoxSizer(wxHORIZONTAL);
m_sHorizMapping[i]->Add(m_gButton[i], 0, (wxLEFT), 5);

View File

@ -62,11 +62,13 @@ class GCPadConfigDialog : public wxDialog
IDB_MAIN_DOWN,
IDB_MAIN_LEFT,
IDB_MAIN_RIGHT,
IDB_MAIN_SEMI,
IDB_SUB_UP,
IDB_SUB_DOWN,
IDB_SUB_LEFT,
IDB_SUB_RIGHT,
IDB_SUB_SEMI,
IDB_SHDR_L,
IDB_SHDR_R,
@ -97,6 +99,7 @@ class GCPadConfigDialog : public wxDialog
IDC_RUMBLE, IDC_RUMBLE_STRENGTH,
IDC_TRIGGER_TYPE,
IDC_STICK_SOURCE, IDC_CSTICK_SOURCE, IDC_TRIGGER_SOURCE,
IDS_STICK_PRESS, IDS_CSTICK_PRESS, IDS_TRIGGER_PRESS,
};
wxNotebook *m_Notebook;
@ -112,6 +115,10 @@ class GCPadConfigDialog : public wxDialog
*m_bmpSquareRightIn[4],
*m_bmpSquareRightOut[4];
wxSlider *m_Slider_Stick[4],
*m_Slider_CStick[4],
*m_Slider_Trigger[4];
wxCheckBox *m_CheckS2C[4],
*m_CheckRumble[4];
@ -176,9 +183,9 @@ class GCPadConfigDialog : public wxDialog
*m_tTriggerSource[4],
*m_Text_Analog[IDB_TRIGGER_R - IDB_ANALOG_LEFT_X + 1][4],
*m_Text_Pad[IDB_SHDR_SEMI_R - IDB_BTN_A + 1][4],
*m_Text_StickSrc[5],
*m_Text_CStickSrc[5],
*m_Text_TriggerSrc[5];
*m_Text_StickSrc[4],
*m_Text_CStickSrc[4],
*m_Text_TriggerSrc[4];
wxStaticBitmap *m_bmpDotLeftIn[4],
*m_bmpDotLeftOut[4],

View File

@ -205,7 +205,9 @@ void Shutdown()
// Finally close SDL
if (SDL_WasInit(0))
{
SDL_Quit();
}
// Remove the pointer to the initialize data
g_PADInitialize = NULL;
@ -280,15 +282,17 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
if (GCMapping[_numPAD].Stick.Main == FROM_KEYBOARD)
{
int iMagnitude = DEF_STICK_FULL;
bool bUp = false;
bool bDown = false;
bool bLeft = false;
bool bRight = false;
if (IsKey(EGC_STICK_SEMI)) iMagnitude = GCMapping[_numPAD].Pressure.Main;
if (IsKey(EGC_STICK_UP)) bUp = true;
else if (IsKey(EGC_STICK_DOWN)) bDown = true;
if (IsKey(EGC_STICK_LEFT)) bLeft = true;
else if (IsKey(EGC_STICK_RIGHT)) bRight = true;
EmulateAnalogStick(_pPADStatus->stickX, _pPADStatus->stickY, bUp, bDown, bLeft, bRight, DEF_STICK_FULL);
EmulateAnalogStick(_pPADStatus->stickX, _pPADStatus->stickY, bUp, bDown, bLeft, bRight, iMagnitude);
}
else if (GCMapping[_numPAD].Stick.Main == FROM_ANALOG1)
{
@ -310,15 +314,17 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
if (GCMapping[_numPAD].Stick.Sub == FROM_KEYBOARD)
{
int iMagnitude = DEF_STICK_FULL;
bool bUp = false;
bool bDown = false;
bool bLeft = false;
bool bRight = false;
if (IsKey(EGC_CSTICK_SEMI)) iMagnitude = GCMapping[_numPAD].Pressure.Sub;
if (IsKey(EGC_CSTICK_UP)) bUp = true;
else if (IsKey(EGC_CSTICK_DOWN)) bDown = true;
if (IsKey(EGC_CSTICK_LEFT)) bLeft = true;
else if (IsKey(EGC_CSTICK_RIGHT)) bRight = true;
EmulateAnalogStick(_pPADStatus->substickX, _pPADStatus->substickY, bUp, bDown, bLeft, bRight, DEF_STICK_FULL);
EmulateAnalogStick(_pPADStatus->substickX, _pPADStatus->substickY, bUp, bDown, bLeft, bRight, iMagnitude);
}
else if (GCMapping[_numPAD].Stick.Sub == FROM_ANALOG1)
{
@ -342,22 +348,26 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
{
if (IsKey(EGC_TGR_L))
{
_pPADStatus->button |= PAD_TRIGGER_L;
_pPADStatus->triggerLeft = DEF_TRIGGER_FULL;
_pPADStatus->button |= PAD_TRIGGER_L;
}
else if (IsKey(EGC_TGR_SEMI_L))
{
_pPADStatus->triggerLeft = DEF_TRIGGER_FULL / 2;
_pPADStatus->triggerLeft = GCMapping[_numPAD].Pressure.Shoulder;
if (_pPADStatus->triggerLeft > DEF_TRIGGER_THRESHOLD)
_pPADStatus->button |= PAD_TRIGGER_L;
}
if (IsKey(EGC_TGR_R))
{
_pPADStatus->button |= PAD_TRIGGER_R;
_pPADStatus->triggerRight = DEF_TRIGGER_FULL;
_pPADStatus->button |= PAD_TRIGGER_R;
}
else if (IsKey(EGC_TGR_SEMI_R))
{
_pPADStatus->triggerRight = DEF_TRIGGER_FULL / 2;
_pPADStatus->triggerRight = GCMapping[_numPAD].Pressure.Shoulder;
if (_pPADStatus->triggerRight > DEF_TRIGGER_THRESHOLD)
_pPADStatus->button |= PAD_TRIGGER_R;
}
}
else if (GCMapping[_numPAD].Stick.Shoulder == FROM_ANALOG1)

View File

@ -38,26 +38,11 @@
#include "pluginspecs_pad.h"
// SDL Haptic fails on windows, it just doesn't work (even the sample doesn't work)
// So until i can make it work, this is all disabled >:(
#if SDL_VERSION_ATLEAST(1, 3, 0) && !defined(_WIN32)
#define SDL_RUMBLE
#else
#ifdef _WIN32
#define RUMBLE_HACK
#define DIRECTINPUT_VERSION 0x0800
#define WIN32_LEAN_AND_MEAN
#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "winmm.lib")
#include <dinput.h>
#endif
#endif
#define DEF_BUTTON_FULL 255
#define DEF_STICK_FULL 100
#define DEF_STICK_HALF 50
#define DEF_TRIGGER_FULL 255
#define DEF_TRIGGER_HALF 128
#define DEF_TRIGGER_THRESHOLD 230
// GC Pad Buttons
@ -79,11 +64,13 @@ enum EGCPad
EGC_STICK_DOWN,
EGC_STICK_LEFT,
EGC_STICK_RIGHT,
EGC_STICK_SEMI,
EGC_CSTICK_UP,
EGC_CSTICK_DOWN,
EGC_CSTICK_LEFT,
EGC_CSTICK_RIGHT,
EGC_CSTICK_SEMI,
EGC_TGR_L,
EGC_TGR_R,
@ -137,6 +124,7 @@ struct CONTROLLER_MAPPING_GC // PAD MAPPING GC
int Diagonal;
SStickMapping Stick;
SStickMapping Pressure;
int Button[LAST_CONSTANT];
};

View File

@ -22,6 +22,23 @@
#include "XInput.h"
#endif
// SDL Haptic fails on windows, it just doesn't work (even the sample doesn't work)
// So until i can make it work, this is all disabled >:(
#if SDL_VERSION_ATLEAST(1, 3, 0) && !defined(_WIN32) && !defined(__APPLE__)
#define SDL_RUMBLE
#else
#ifdef _WIN32
#define RUMBLE_HACK
#define DIRECTINPUT_VERSION 0x0800
#define WIN32_LEAN_AND_MEAN
#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "winmm.lib")
#include <dinput.h>
#endif
#endif
#ifdef RUMBLE_HACK
@ -33,8 +50,6 @@ struct RUMBLE // GC Pad rumble DIDevice
DIEFFECT eff;
};
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=NULL; } }
BOOL CALLBACK EnumFFDevicesCallback(const DIDEVICEINSTANCE* pInst, VOID* pContext);
BOOL CALLBACK EnumAxesCallback(const DIDEVICEOBJECTINSTANCE* pdidoi, VOID* pContext);
void SetDeviceForcesXY(int pad, int nXYForce);