mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 13:57:57 -07:00
nJoy: Configuration bugfixes, and show the digital shoulder button status in the advanced settings to
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1945 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
00bca8d807
commit
6f4cbb89f9
@ -41,8 +41,10 @@ Config g_Config;
|
||||
Config::Config()
|
||||
{
|
||||
//memset(this, 0, sizeof(Config)); // Clear the memory
|
||||
|
||||
bSaveByID.resize(4); // Set vector size
|
||||
bSquareToCircle.resize(4); // Set vector size
|
||||
bSquareToCircle.resize(4);
|
||||
SDiagonal.resize(4);
|
||||
}
|
||||
|
||||
|
||||
@ -224,8 +226,8 @@ void Config::Save(bool CheckedForDuplicates)
|
||||
file.Set(SectionName.c_str(), "TriggerType", joysticks[i].triggertype);
|
||||
file.Set(SectionName.c_str(), "eventnum", joysticks[i].eventnum);
|
||||
|
||||
file.Set(SectionName.c_str(), "Diagonal", g_Config.SDiagonal);
|
||||
file.Set(SectionName.c_str(), "SquareToCircle", g_Config.bSquareToCircle.at(i));
|
||||
file.Set(SectionName.c_str(), "Diagonal", g_Config.SDiagonal.at(i).c_str());
|
||||
file.Set(SectionName.c_str(), "SquareToCircle", g_Config.bSquareToCircle.at(i));
|
||||
}
|
||||
|
||||
file.Save("nJoy.ini");
|
||||
@ -299,7 +301,7 @@ void Config::Load(bool config)
|
||||
file.Get(SectionName.c_str(), "TriggerType", &joysticks[i].triggertype, 0);
|
||||
file.Get(SectionName.c_str(), "eventnum", &joysticks[i].eventnum, 0);
|
||||
|
||||
file.Get(SectionName.c_str(), "Diagonal", &g_Config.SDiagonal, "100%");
|
||||
file.Get(SectionName.c_str(), "Diagonal", &g_Config.SDiagonal.at(i), "100%");
|
||||
file.Get(SectionName.c_str(), "SquareToCircle", &Tmp, false); g_Config.bSquareToCircle.at(i) = Tmp;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ struct Config
|
||||
std::vector<bool> bSaveByID; bool bSaveByIDNotice;
|
||||
|
||||
// Joystick
|
||||
std::string SDiagonal;
|
||||
std::vector<std::string> SDiagonal;
|
||||
std::vector<bool> bSquareToCircle;
|
||||
};
|
||||
|
||||
|
@ -91,7 +91,7 @@ void ConfigBox::PadGetStatus()
|
||||
int main_x_after = main_x, main_y_after = main_y;
|
||||
if(g_Config.bSquareToCircle.at(notebookpage))
|
||||
{
|
||||
std::vector<int> main_xy = Pad_Square_to_Circle(main_x, main_y);
|
||||
std::vector<int> main_xy = Pad_Square_to_Circle(main_x, main_y, notebookpage);
|
||||
main_x_after = main_xy.at(0);
|
||||
main_y_after = main_xy.at(1);
|
||||
}
|
||||
@ -130,6 +130,14 @@ void ConfigBox::PadGetStatus()
|
||||
//////////////////////////////////////
|
||||
// Triggers
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
int TriggerValue = 255;
|
||||
if (joystate[notebookpage].halfpress) TriggerValue = 100;
|
||||
|
||||
// Get the selected keys
|
||||
long Left, Right;
|
||||
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];
|
||||
|
||||
@ -137,8 +145,12 @@ void ConfigBox::PadGetStatus()
|
||||
u8 TriggerLeft = Pad_Convert(SDLTriggerLeft, TriggerType);
|
||||
u8 TriggerRight = Pad_Convert(SDLTriggerRight, TriggerType);
|
||||
|
||||
// Get the digital values
|
||||
if(Left < 1000 && joystate[notebookpage].buttons[CTL_L_SHOULDER]) TriggerLeft = TriggerValue;
|
||||
if(Right < 1000 && joystate[notebookpage].buttons[CTL_R_SHOULDER]) TriggerRight = TriggerValue;
|
||||
|
||||
m_TStatusTriggers[notebookpage]->SetLabel(wxString::Format(
|
||||
wxT("Left:%03i Right:%03i"),
|
||||
wxT("Left:%03i Right:%03i"),
|
||||
TriggerLeft, TriggerRight
|
||||
));
|
||||
///////////////////// Triggers
|
||||
@ -173,6 +185,10 @@ std::string ShowStatus(int VirtualController)
|
||||
int Hats = joyinfo[PhysicalDevice].NumHats;
|
||||
int Buttons = joyinfo[PhysicalDevice].NumButtons;
|
||||
|
||||
// More status
|
||||
int controllertype = joysticks[VirtualController].controllertype;
|
||||
int triggertype = joysticks[VirtualController].triggertype;
|
||||
|
||||
// Update the internal values
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
@ -194,13 +210,15 @@ std::string ShowStatus(int VirtualController)
|
||||
}
|
||||
|
||||
return StringFromFormat(
|
||||
"joysticks.ID: %i %i %i %i\n"
|
||||
"joysticks.ID: %i %i %i %i\n"
|
||||
"joysticks.controllertype, triggertype: %i %i\n"
|
||||
"Handles: %i %i %i %i\n"
|
||||
"Axes: %s\n"
|
||||
"Hats: %s\n"
|
||||
"But: %s\n"
|
||||
"Device: Ax: %i Balls:%i But:%i Hats:%i",
|
||||
joysticks[0].ID, joysticks[1].ID, joysticks[2].ID, joysticks[3].ID,
|
||||
controllertype, triggertype,
|
||||
(int)joy0, (int)joy1, (int)joy2, (int)joy3,
|
||||
StrAxes.c_str(), StrHats.c_str(), StrBut.c_str(),
|
||||
Axes, Balls, Hats, Buttons
|
||||
|
@ -236,10 +236,12 @@ void ConfigBox::ChangeSettings( wxCommandEvent& event )
|
||||
break;
|
||||
|
||||
case IDCB_MAINSTICK_DIAGONAL:
|
||||
g_Config.SDiagonal = m_CoBDiagonal[notebookpage]->GetLabel().mb_str();
|
||||
g_Config.SDiagonal.at(notebookpage) = m_CoBDiagonal[notebookpage]->GetLabel().mb_str();
|
||||
break;
|
||||
|
||||
case IDCB_MAINSTICK_S_TO_C:
|
||||
g_Config.bSquareToCircle.at(notebookpage) = m_CBS_to_C[notebookpage]->IsChecked();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,6 +270,11 @@ void ConfigBox::UpdateGUI(int _notebookpage)
|
||||
|
||||
// Controller type settings
|
||||
bool Hat = (joysticks[_notebookpage].controllertype == CTL_DPAD_HAT);
|
||||
long Left, Right;
|
||||
m_JoyShoulderL[_notebookpage]->GetValue().ToLong(&Left);
|
||||
m_JoyShoulderR[_notebookpage]->GetValue().ToLong(&Right);
|
||||
bool AnalogTrigger = (Left >= 1000 || Right >= 1000);
|
||||
|
||||
m_JoyDpadUp[_notebookpage]->Show(!Hat);
|
||||
m_JoyDpadLeft[_notebookpage]->Show(!Hat);
|
||||
m_JoyDpadRight[_notebookpage]->Show(!Hat);
|
||||
@ -284,13 +291,15 @@ void ConfigBox::UpdateGUI(int _notebookpage)
|
||||
m_bJoyDpadDown[_notebookpage]->SetToolTip(Hat ?
|
||||
wxT("Select a hat by pressing the hat in any direction") : wxT(""));
|
||||
|
||||
m_TriggerType[_notebookpage]->Enable(AnalogTrigger);
|
||||
|
||||
// General settings
|
||||
m_CBSaveByID[_notebookpage]->SetValue(g_Config.bSaveByID.at(_notebookpage));
|
||||
m_CBSaveByIDNotice[_notebookpage]->SetValue(g_Config.bSaveByIDNotice);
|
||||
m_CBShowAdvanced[_notebookpage]->SetValue(g_Config.bShowAdvanced);
|
||||
|
||||
// Advanced settings
|
||||
m_CoBDiagonal[_notebookpage]->SetValue(wxString::FromAscii(g_Config.SDiagonal.c_str()));
|
||||
m_CoBDiagonal[_notebookpage]->SetValue(wxString::FromAscii(g_Config.SDiagonal.at(_notebookpage).c_str()));
|
||||
m_CBS_to_C[_notebookpage]->SetValue(g_Config.bSquareToCircle.at(_notebookpage));
|
||||
|
||||
// There is no FindItem in linux so this doesn't work
|
||||
@ -454,7 +463,7 @@ void ConfigBox::CreateGUIControls()
|
||||
|
||||
|
||||
// Populate all four pages
|
||||
for(int i=0; i<4 ;i++)
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
// --------------------------------------------------------------------
|
||||
// Populate keys sizer
|
||||
@ -623,7 +632,7 @@ void ConfigBox::CreateGUIControls()
|
||||
m_TriggerType[i] = new wxComboBox(m_Controller[i], IDC_TRIGGERTYPE, wxAS_TriggerType[0], wxDefaultPosition, wxDefaultSize, wxAS_TriggerType, wxCB_READONLY);
|
||||
|
||||
// Populate general settings 2 (controller typ)
|
||||
m_gGenSettings[i] = new wxStaticBoxSizer( wxVERTICAL, m_Controller[i], wxT("D-Pad and Trigger"));
|
||||
m_gGenSettings[i] = new wxStaticBoxSizer( wxVERTICAL, m_Controller[i], wxT("D-Pad and Analog Trigger"));
|
||||
m_gGBGenSettings[i] = new wxGridBagSizer(0, 0);
|
||||
m_gGBGenSettings[i]->Add(m_TSControltype[i], wxGBPosition(0, 0), wxGBSpan(1, 1), (wxTOP), 4);
|
||||
m_gGBGenSettings[i]->Add(m_ControlType[i], wxGBPosition(0, 1), wxGBSpan(1, 1), (wxBOTTOM | wxLEFT), 2);
|
||||
@ -649,8 +658,9 @@ void ConfigBox::CreateGUIControls()
|
||||
"Use a 'hat' on your gamepad or configure a custom button for each direction."
|
||||
));
|
||||
m_TriggerType[i]->SetToolTip(wxT(
|
||||
"You can look under 'Trigger values' in the advanced settings to see which of these modes work for your gamepad."
|
||||
" If it works the unpressed to pressed range should be 0 - 255."
|
||||
"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."
|
||||
));
|
||||
m_CBSaveByID[i]->SetToolTip(wxString::Format(wxT(
|
||||
"Map these settings to the selected controller device instead of to the"
|
||||
|
@ -144,7 +144,7 @@ void ConfigBox::SaveButtonMapping(int controller)
|
||||
joysticks[controller].enabled = m_Joyattach[controller]->GetValue();
|
||||
joysticks[controller].controllertype = m_ControlType[controller]->GetSelection();
|
||||
joysticks[controller].triggertype = m_TriggerType[controller]->GetSelection();
|
||||
joysticks[controller].deadzone = m_Deadzone[controller]->GetSelection();
|
||||
joysticks[controller].deadzone = m_Deadzone[controller]->GetSelection();
|
||||
}
|
||||
|
||||
|
||||
@ -154,6 +154,7 @@ void ConfigBox::SaveButtonMapping(int controller)
|
||||
void ConfigBox::ChangeControllertype(wxCommandEvent& event)
|
||||
{
|
||||
SaveButtonMapping(notebookpage);
|
||||
UpdateGUI(notebookpage);
|
||||
}
|
||||
|
||||
|
||||
|
@ -440,7 +440,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
// Check if we should make adjustments
|
||||
if(g_Config.bSquareToCircle.at(_numPAD))
|
||||
{
|
||||
std::vector<int> main_xy = Pad_Square_to_Circle(i_main_stick_x, i_main_stick_y);
|
||||
std::vector<int> main_xy = Pad_Square_to_Circle(i_main_stick_x, i_main_stick_y, _numPAD);
|
||||
i_main_stick_x = main_xy.at(0);
|
||||
i_main_stick_y = main_xy.at(1);
|
||||
}
|
||||
@ -469,14 +469,14 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
///////////////////////////////////////////////////
|
||||
// The L and R triggers
|
||||
// -----------
|
||||
int triggervalue = 255;
|
||||
if (joystate[_numPAD].halfpress) triggervalue = 100;
|
||||
int TriggerValue = 255;
|
||||
if (joystate[_numPAD].halfpress) TriggerValue = 100;
|
||||
_pPADStatus->button |= PAD_USE_ORIGIN; // Neutral value, no button pressed
|
||||
|
||||
if (joystate[_numPAD].buttons[CTL_L_SHOULDER])
|
||||
{
|
||||
_pPADStatus->button |= PAD_TRIGGER_L;
|
||||
_pPADStatus->triggerLeft = triggervalue;
|
||||
_pPADStatus->triggerLeft = TriggerValue;
|
||||
}
|
||||
else if(joystate[_numPAD].axis[CTL_L_SHOULDER])
|
||||
_pPADStatus->triggerLeft = TriggerLeft;
|
||||
@ -484,7 +484,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
if (joystate[_numPAD].buttons[CTL_R_SHOULDER])
|
||||
{
|
||||
_pPADStatus->button |= PAD_TRIGGER_R;
|
||||
_pPADStatus->triggerRight = triggervalue;
|
||||
_pPADStatus->triggerRight = TriggerValue;
|
||||
}
|
||||
else if(joystate[_numPAD].axis[CTL_R_SHOULDER])
|
||||
_pPADStatus->triggerRight = TriggerRight;
|
||||
@ -547,7 +547,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
"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"),
|
||||
TriggerLeft, TriggerRight, triggervalue,
|
||||
TriggerLeft, TriggerRight, TriggerValue,
|
||||
(joysticks[_numPAD].controllertype ? "CTL_DPAD_CUSTOM" : "CTL_DPAD_HAT"),
|
||||
0, 0, 0, 0
|
||||
);*/
|
||||
@ -600,17 +600,11 @@ u8 Pad_Convert(int _val, int _type)
|
||||
if (_val >= 0x7f7f ) _val = 0x7fff;
|
||||
if (_val <= -0x7f80 ) _val = -0x8000;
|
||||
|
||||
//Console::Print("0x%04x %06i\n", _val, _val);
|
||||
|
||||
// Convert (-0x8000 to 0x7fff)
|
||||
if(!_type && _val < 0) _val = -_val - 1;
|
||||
|
||||
//Console::Print("0x%04x %06i\n", _val, _val);
|
||||
|
||||
// Convert (0x7fff to 0xfffe to 0xffff)
|
||||
if(!_type) _val = (_val * 2) + 1;
|
||||
|
||||
//Console::Print("0x%04x %06i\n", _val, _val);
|
||||
|
||||
// Convert the range (-0x8000 to 0x7fff) to (0 to 0xffff)
|
||||
if(_type) _val = 0x8000 +_val;
|
||||
@ -656,7 +650,7 @@ float SquareDistance(float deg)
|
||||
|
||||
return dist;
|
||||
}
|
||||
std::vector<int> Pad_Square_to_Circle(int _x, int _y)
|
||||
std::vector<int> Pad_Square_to_Circle(int _x, int _y, int _pad)
|
||||
{
|
||||
/* Do we need this? */
|
||||
if(_x > 32767) _x = 32767; if(_y > 32767) _y = 32767; // upper limit
|
||||
@ -665,7 +659,7 @@ std::vector<int> Pad_Square_to_Circle(int _x, int _y)
|
||||
// ====================================
|
||||
// Convert to circle
|
||||
// -----------
|
||||
int Tmp = atoi (g_Config.SDiagonal.substr(0, g_Config.SDiagonal.length() - 1).c_str());
|
||||
int Tmp = atoi (g_Config.SDiagonal.at(_pad).substr(0, g_Config.SDiagonal.at(_pad).length() - 1).c_str());
|
||||
float Diagonal = Tmp / 100.0;
|
||||
|
||||
// First make a perfect square in case we don't have one already
|
||||
|
@ -234,7 +234,7 @@ void DEBUG_QUIT();
|
||||
|
||||
void Pad_Use_Rumble(u8 _numPAD, SPADStatus* _pPADStatus); // Rumble
|
||||
u8 Pad_Convert(int _val, int _type = 1); // Value conversion
|
||||
std::vector<int> Pad_Square_to_Circle(int _x, int _y); // Value conversion
|
||||
std::vector<int> Pad_Square_to_Circle(int _x, int _y, int _pad); // Value conversion
|
||||
|
||||
//void SaveConfig();
|
||||
//void LoadConfig();
|
||||
|
Loading…
Reference in New Issue
Block a user