mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
More work. Must press calibrate to figure out the min and max first. Triggers are annoying in Linux, because each is treated as a different axis from 0 to 255. but Windows it's from -255 to 25. It keeps setting the pressed button to the l-Trigger in Linux because of this. Must do more work.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1381 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
ab36429fb0
commit
395129d2c4
@ -62,6 +62,7 @@ BEGIN_EVENT_TABLE(ConfigBox,wxDialog)
|
||||
EVT_BUTTON(IDB_BUTTON_Y, ConfigBox::GetInputs)
|
||||
EVT_BUTTON(IDB_BUTTON_Z, ConfigBox::GetInputs)
|
||||
EVT_BUTTON(IDB_BUTTONSTART, ConfigBox::GetInputs)
|
||||
EVT_BUTTON(ID_BUTTONCALIBRATE, ConfigBox::Calibrate)
|
||||
EVT_BUTTON(IDB_BUTTONHALFPRESS, ConfigBox::GetInputs)
|
||||
EVT_BUTTON(IDB_DPAD_UP, ConfigBox::GetInputs)
|
||||
EVT_BUTTON(IDB_DPAD_DOWN, ConfigBox::GetInputs)
|
||||
@ -239,6 +240,7 @@ void ConfigBox::CreateGUIControls()
|
||||
// GUI center button
|
||||
m_JoyButtonStart[i] = new wxTextCtrl(m_Controller[i], ID_BUTTONSTART, wxT("0"), wxPoint(278, 403), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
|
||||
m_JoyButtonStart[i]->Enable(false);
|
||||
m_bJoyButtonCalibrate[i] = new wxButton(m_Controller[i], ID_BUTTONCALIBRATE, wxT("Calibrate"), wxPoint(297, 440), wxSize(21, 14), 0, wxDefaultValidator, wxT("Calibrate"));
|
||||
m_JoyButtonHalfpress[i] = new wxTextCtrl(m_Controller[i], ID_BUTTONHALFPRESS, wxT("0"), wxPoint(167, 424), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
|
||||
m_JoyButtonHalfpress[i]->Enable(false);
|
||||
m_bJoyButtonStart[i] = new wxButton(m_Controller[i], IDB_BUTTONSTART, wxEmptyString, wxPoint(297, 385), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString);
|
||||
@ -321,6 +323,34 @@ void ConfigBox::CancelClick(wxCommandEvent& event)
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigBox::Calibrate(wxCommandEvent& event)
|
||||
{
|
||||
int controller = notebookpage;
|
||||
|
||||
|
||||
SDL_Joystick *joy = SDL_JoystickOpen(joysticks[controller].ID);
|
||||
int axes = SDL_JoystickNumAxes(joy);
|
||||
Sint16 value;
|
||||
unsigned long Started = SDL_GetTicks();
|
||||
while(1)
|
||||
{
|
||||
for(int b = 0; b < axes; b++)
|
||||
{
|
||||
SDL_JoystickUpdate();
|
||||
value = SDL_JoystickGetAxis(joy, b);
|
||||
if(value < joysticks[controller].sData[b].Min)
|
||||
joysticks[controller].sData[b].Min = value;
|
||||
if(value > joysticks[controller].sData[b].Max)
|
||||
joysticks[controller].sData[b].Max = value;
|
||||
}
|
||||
if(SDL_GetTicks() - Started >= 5000)
|
||||
break;
|
||||
}
|
||||
for(int a = 0; a < axes;a++)
|
||||
printf("Axis %d has a Min of %d, and a Max of %d\n", a, joysticks[controller].sData[a].Min, joysticks[controller].sData[a].Max);
|
||||
if(SDL_JoystickOpened(joysticks[controller].ID))
|
||||
SDL_JoystickClose(joy);
|
||||
}
|
||||
// Set dialog items
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::SetControllerAll(int controller)
|
||||
@ -613,7 +643,8 @@ void ConfigBox::GetInputs(wxCommandEvent& event)
|
||||
sprintf(format, "[%d]", counter2);
|
||||
SetButtonText(ID, format);
|
||||
wxWindow::Update(); // win only? doesnt seem to work in linux...
|
||||
|
||||
|
||||
SDL_JoystickUpdate();
|
||||
while(waiting)
|
||||
{
|
||||
SDL_JoystickUpdate();
|
||||
@ -629,10 +660,12 @@ void ConfigBox::GetInputs(wxCommandEvent& event)
|
||||
}
|
||||
}
|
||||
for(int b = 0; b < axes; b++)
|
||||
{
|
||||
{
|
||||
value = SDL_JoystickGetAxis(joy, b);
|
||||
if(value < -10000 || value > 10000)
|
||||
{
|
||||
if(value <= (joysticks[controller].sData[b].Min - (joysticks[controller].sData[b].Min * joysticks[controller].deadzone / 100)) || value >= (joysticks[controller].sData[b].Max - (joysticks[controller].sData[b].Max * joysticks[controller].deadzone / 100))) // Add and subtract a small value
|
||||
{ // It allows for some small jitter
|
||||
printf("value %d, Min %d Max %d Removal %d\n", value, joysticks[controller].sData[b].Min,joysticks[controller].sData[b].Max, (joysticks[controller].sData[b].Min * joysticks[controller].deadzone / 100));
|
||||
value = value <= (joysticks[controller].sData[b].Min - joysticks[controller].sData[b].Min * joysticks[controller].deadzone) ? -1 : 1; // Makes it know if the value is negative or positive
|
||||
pressed = b;
|
||||
waiting = false;
|
||||
succeed = true;
|
||||
|
@ -96,6 +96,7 @@ class ConfigBox : public wxDialog
|
||||
wxButton *m_bJoyButtonY[4];
|
||||
wxButton *m_bJoyButtonZ[4];
|
||||
wxButton *m_bJoyButtonStart[4];
|
||||
wxButton *m_bJoyButtonCalibrate[4];
|
||||
wxButton *m_bJoyButtonHalfpress[4];
|
||||
|
||||
wxTextCtrl *m_JoyAnalogMainX[4];
|
||||
@ -209,6 +210,7 @@ class ConfigBox : public wxDialog
|
||||
IDT_ANALOG_SUB_X,
|
||||
IDT_ANALOG_SUB_Y,
|
||||
IDT_WEBSITE,
|
||||
ID_BUTTONCALIBRATE,
|
||||
|
||||
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
|
||||
};
|
||||
@ -230,6 +232,7 @@ class ConfigBox : public wxDialog
|
||||
|
||||
void NotebookPageChanged(wxNotebookEvent& event);
|
||||
|
||||
void Calibrate(wxCommandEvent& event);
|
||||
void GetInputs(wxCommandEvent& event);
|
||||
void GetHats(int ID);
|
||||
|
||||
|
@ -599,14 +599,12 @@ int Search_Devices()
|
||||
joyinfo[i].NumHats = SDL_JoystickNumHats(joyinfo[i].joy);
|
||||
joyinfo[i].Name = SDL_JoystickName(i);
|
||||
|
||||
#ifdef _DEBUG
|
||||
fprintf(pFile, "ID: %d\n", i);
|
||||
fprintf(pFile, "Name: %s\n", joyinfo[i].Name);
|
||||
fprintf(pFile, "Buttons: %d\n", joyinfo[i].NumButtons);
|
||||
fprintf(pFile, "Axes: %d\n", joyinfo[i].NumAxes);
|
||||
fprintf(pFile, "Hats: %d\n", joyinfo[i].NumHats);
|
||||
fprintf(pFile, "Balls: %d\n\n", joyinfo[i].NumBalls);
|
||||
#endif
|
||||
printf("ID: %d\n", i);
|
||||
printf("Name: %s\n", joyinfo[i].Name);
|
||||
printf("Buttons: %d\n", joyinfo[i].NumButtons);
|
||||
printf("Axises: %d\n", joyinfo[i].NumAxes);
|
||||
printf("Hats: %d\n", joyinfo[i].NumHats);
|
||||
printf("Balls: %d\n\n", joyinfo[i].NumBalls);
|
||||
|
||||
// Close if opened
|
||||
if(SDL_JoystickOpened(i))
|
||||
@ -690,6 +688,14 @@ void SaveConfig()
|
||||
file.Set(SectionName, "joy_id", joysticks[i].ID);
|
||||
file.Set(SectionName, "controllertype", joysticks[i].controllertype);
|
||||
file.Set(SectionName, "eventnum", joysticks[i].eventnum);
|
||||
for(int a = 0; a < MAX_AXISES; a++)
|
||||
{
|
||||
char Section[32];
|
||||
sprintf(Section, "SAxis%dMin", a);
|
||||
file.Set(SectionName, Section, (int)joysticks[i].sData[a].Min);
|
||||
sprintf(Section, "SAxis%dMax", a);
|
||||
file.Set(SectionName, Section, (int)joysticks[i].sData[a].Max);
|
||||
}
|
||||
}
|
||||
|
||||
file.Save("nJoy.ini");
|
||||
@ -730,6 +736,18 @@ void LoadConfig()
|
||||
file.Get(SectionName, "joy_id", &joysticks[i].ID, 0);
|
||||
file.Get(SectionName, "controllertype", &joysticks[i].controllertype, 0);
|
||||
file.Get(SectionName, "eventnum", &joysticks[i].eventnum, 0);
|
||||
for(int a = 0; a < MAX_AXISES; a++)
|
||||
{
|
||||
char Section[32];
|
||||
int Min;
|
||||
int Max;
|
||||
sprintf(Section, "SAxis%dMin", a);
|
||||
file.Get(SectionName, Section, &Min, 0);
|
||||
sprintf(Section, "SAxis%dMax", a);
|
||||
file.Get(SectionName, Section, &Max, 0);
|
||||
joysticks[i].sData[a].Min = Min;
|
||||
joysticks[i].sData[a].Max = Max;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,9 +94,20 @@
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Structures
|
||||
// ¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
#define MAX_AXISES 12 // If more than 12 is needed. Up it
|
||||
class sCalibration
|
||||
{
|
||||
public:
|
||||
sCalibration()
|
||||
{
|
||||
Min = 0;
|
||||
Max = 0;
|
||||
}
|
||||
Sint16 Min;
|
||||
Sint16 Max;
|
||||
}; // Simple Calibration Data
|
||||
struct CONTROLLER_STATE{ // GC PAD INFO/STATE
|
||||
int buttons[12]; // Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
|
||||
int buttons[12]; // Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
|
||||
int dpad; // 1 HAT (8 directions + neutral)
|
||||
int dpad2[4]; // d-pad using buttons
|
||||
int halfpress; // ...
|
||||
@ -104,7 +115,8 @@ struct CONTROLLER_STATE{ // GC PAD INFO/STATE
|
||||
};
|
||||
|
||||
struct CONTROLLER_MAPPING{ // GC PAD MAPPING
|
||||
std::string buttons[12]; // Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
|
||||
std::string buttons[12];// Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
|
||||
sCalibration sData[MAX_AXISES]; // Calibration Data
|
||||
int dpad; // 1 HAT (8 directions + neutral)
|
||||
int dpad2[4]; // d-pad using buttons
|
||||
int enabled; // Pad attached?
|
||||
|
Loading…
Reference in New Issue
Block a user