revert to r4531, but keep the changes from the following revisions: 4533,4550-4551,4556-4559

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4566 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman
2009-11-14 17:08:32 +00:00
parent 18305c7c49
commit 06aa62504c
66 changed files with 2170 additions and 1570 deletions

View File

@ -1,3 +1,4 @@
// Project description
// -------------------
// Name: nJoy
@ -31,15 +32,14 @@
// ---------
#include "ConfigBox.h"
#include "../nJoy.h"
#include "LogManager.h"
#include "Images/controller.xpm"
extern bool g_EmulatorRunning;
// Set PAD status
// --------------
void PADConfigDialognJoy::PadShowStatus()
{
void PADConfigDialognJoy::PadGetStatus()
{
// Return if it's not detected. The ID should never be less than zero here, it can only be that
// because of a manual ini file change, but we make that check anway.
if(PadMapping[notebookpage].ID < 0 || PadMapping[notebookpage].ID >= SDL_NumJoysticks())
@ -51,7 +51,7 @@ void PADConfigDialognJoy::PadShowStatus()
}
// Get physical device status
int ID = PadMapping[notebookpage].ID;
int PhysicalDevice = PadMapping[notebookpage].ID;
int TriggerType = PadMapping[notebookpage].triggertype;
// Get original values
@ -105,6 +105,7 @@ void PADConfigDialognJoy::PadShowStatus()
m_bmpDotOutC[notebookpage]->SetPosition(wxPoint(sub_x_out, sub_y_out));
///////////////////// Analog stick
// Triggers
// -----------------
@ -142,12 +143,84 @@ void PADConfigDialognJoy::PadShowStatus()
///////////////////// Triggers
}
// Update the advanced tab
// Show the current pad status
// -----------------
std::string ShowStatus(int VirtualController)
{
// Save the physical device
int PhysicalDevice = PadMapping[VirtualController].ID;
// Make local shortcut
SDL_Joystick *joy = PadState[VirtualController].joy;
// Make shortcuts for all pads
SDL_Joystick *joy0 = PadState[0].joy;
SDL_Joystick *joy1 = PadState[1].joy;
SDL_Joystick *joy2 = PadState[2].joy;
SDL_Joystick *joy3 = PadState[3].joy;
// Temporary storage
std::string StrAxes, StrHats, StrBut;
int value;
// Get status
int Axes = joyinfo[PhysicalDevice].NumAxes;
int Balls = joyinfo[PhysicalDevice].NumBalls;
int Hats = joyinfo[PhysicalDevice].NumHats;
int Buttons = joyinfo[PhysicalDevice].NumButtons;
// Update the internal values
SDL_JoystickUpdate();
// Go through all axes and read out their values
for(int i = 0; i < Axes; i++)
{
value = SDL_JoystickGetAxis(joy, i);
StrAxes += StringFromFormat(" %i:%06i", i, value);
}
for(int i = 0;i < Hats; i++)
{
value = SDL_JoystickGetHat(joy, i);
StrHats += StringFromFormat(" %i:%i", i, value);
}
for(int i = 0;i < Buttons; i++)
{
value = SDL_JoystickGetButton(joy, i);
StrBut += StringFromFormat(" %i:%i", i+1, value);
}
return StringFromFormat(
"All pads:\n"
"ID: %i %i %i %i\n"
"Controllertype: %i %i %i %i\n"
"SquareToCircle: %i %i %i %i\n\n"
#ifdef _WIN32
"Handles: %i %i %i %i\n"
"XInput: %i %i %i\n"
#endif
"This pad:\n"
"Axes: %s\n"
"Hats: %s\n"
"But: %s\n"
"Device: Ax: %i Balls:%i Hats:%i But:%i",
PadMapping[0].ID, PadMapping[1].ID, PadMapping[2].ID, PadMapping[3].ID,
PadMapping[0].controllertype, PadMapping[1].controllertype, PadMapping[2].controllertype, PadMapping[3].controllertype,
PadMapping[0].bSquareToCircle, PadMapping[1].bSquareToCircle, PadMapping[2].bSquareToCircle, PadMapping[3].bSquareToCircle,
#ifdef _WIN32
joy0, joy1, joy2, joy3,
//PadState[PadMapping[0].ID].joy, PadState[PadMapping[1].ID].joy, PadState[PadMapping[2].ID].joy, PadState[PadMapping[3].ID].joy,
XInput::IsConnected(0), XInput::GetXI(0, InputCommon::XI_TRIGGER_L), XInput::GetXI(0, InputCommon::XI_TRIGGER_R),
#endif
StrAxes.c_str(), StrHats.c_str(), StrBut.c_str(),
Axes, Balls, Hats, Buttons
);
}
// Populate the advanced tab
// -----------------
void PADConfigDialognJoy::Update()
{
if (!IsPolling()) return;
{
// Check that Dolphin is in focus, otherwise don't update the pad status
/* If the emulator is running and unpaused GetJoyState() is run a little more often than needed,
but I allow that since it can confuse the user if the input status in the configuration window
@ -155,46 +228,17 @@ void PADConfigDialognJoy::Update()
if (g_Config.bCheckFocus || IsFocus()) // && !g_EmulatorRunning)
{
for (int i = 0; (u32)i < joyinfo.size(); i++)
InputCommon::GetJoyState(PadState[notebookpage], PadMapping[notebookpage]);
PadShowStatus();
InputCommon::GetJoyState(PadState[i], PadMapping[i], i, joyinfo[PadMapping[i].ID].NumButtons);
}
// Show the current status in a window in the wxPanel
#ifdef SHOW_PAD_STATUS
m_pStatusBar->SetLabel(wxString::FromAscii(InputCommon::ShowStatus(
notebookpage, m_Joyname[notebookpage]->GetSelection(),
PadMapping, PadState, joyinfo
).c_str()));
m_pStatusBar->SetLabel(wxString::Format(
"%s", ShowStatus(notebookpage).c_str()
));
#endif
}
// Search for devices
void PADConfigDialognJoy::UpdateSlow()
{
if (!LiveUpdates) return;
// Don't run this the first time
int OldNumDIDevices;
if (NumDIDevices == -1)
OldNumDIDevices = InputCommon::SearchDIDevices();
else
// Search for connected devices and update dialog
OldNumDIDevices = NumDIDevices;
NumDIDevices = InputCommon::SearchDIDevices();
// Update if a pad has been connected/disconnected. Todo: Add a better check that also takes into consideration the pad id
// and other things to better ensure that nothing has changed
//DEBUG_LOG(PAD, "Found %i devices", NumDIDevices);
//DEBUG_LOG(PAD, "UpdateSlow: %i %i", OldNumPads, NumPads);
if (OldNumDIDevices != NumDIDevices)
{
WARN_LOG(PAD, "\n---- %s ----", (NumDIDevices > OldNumDIDevices) ? "Pad connected" : "Pad disconnected");
LocalSearchDevicesReset(joyinfo, NumPads);
UpdateDeviceList();
// Enable controls again, if disabled
UpdateGUIAll();
}
}
// Populate the advanced tab
// -----------------
@ -324,5 +368,6 @@ wxBitmap PADConfigDialognJoy::CreateBitmapArea(int Max, int Diagonal)
Points[7].x = (int)(-Diagonal * Adj + iAdj); Points[7].y = (int)(Diagonal * Adj + iAdj);
// Draw polygon
dc.DrawPolygon(8, Points);
return bitmap;
}

View File

@ -103,7 +103,6 @@ BEGIN_EVENT_TABLE(PADConfigDialognJoy,wxDialog)
EVT_BUTTON(IDB_ANALOG_SUB_Y, PADConfigDialognJoy::GetButtons)
#if wxUSE_TIMER
EVT_TIMER(IDTM_SLOW, PADConfigDialognJoy::OnSlowTimer)
EVT_TIMER(IDTM_CONSTANT, PADConfigDialognJoy::OnTimer)
EVT_TIMER(IDTM_BUTTON, PADConfigDialognJoy::OnButtonTimer)
#endif
@ -113,34 +112,26 @@ PADConfigDialognJoy::PADConfigDialognJoy(wxWindow *parent, wxWindowID id, const
const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
// Initialize values
// Define values
notebookpage = 0;
g_Pressed = 0;
g_Pressed = 0;
Debugging = false;
m_TCDebugging = NULL;
ControlsCreated = false;
// Settings
Debugging = false;
// Create controls
CreateGUIControls();
// Update GUI
UpdateGUIAll();
// Update device list
UpdateDeviceList();
#if wxUSE_TIMER
m_SlowTimer = new wxTimer(this, IDTM_SLOW);
m_ConstantTimer = new wxTimer(this, IDTM_CONSTANT);
m_ButtonMappingTimer = new wxTimer(this, IDTM_BUTTON);
// Reset values
GetButtonWaitingID = 0; GetButtonWaitingTimer = 0;
// Start timers
StartTimer();
// Start the constant timer
int TimesPerSecond = 30;
m_ConstantTimer->Start( floor((double)(1000 / TimesPerSecond)) );
#endif
// wxEVT_KEY_DOWN is blocked for enter, tab and the directional keys
@ -157,24 +148,6 @@ PADConfigDialognJoy::~PADConfigDialognJoy()
#endif
}
void PADConfigDialognJoy::DoShow()
{
// Start timers
StartTimer();
// Show
ShowModal();
}
void PADConfigDialognJoy::StartTimer()
{
// Start the slow timer
double TimesPerSecond = 2;
m_SlowTimer->Start( floor((double)(1000.0 / TimesPerSecond)) );
// Start the constant timer
TimesPerSecond = 30;
m_ConstantTimer->Start( floor((double)(1000 / TimesPerSecond)) );
}
void PADConfigDialognJoy::OnKeyDown(wxKeyEvent& event)
{
g_Pressed = event.GetKeyCode();
@ -187,9 +160,7 @@ void PADConfigDialognJoy::OnClose(wxCloseEvent& event)
event.Skip();
// Stop the timer
m_SlowTimer->Stop();
m_ConstantTimer->Stop();
m_ButtonMappingTimer->Stop();
// Close pads, unless we are running a game
if (!g_EmulatorRunning) Shutdown();
@ -285,7 +256,7 @@ void PADConfigDialognJoy::DoSave(bool ChangePad, int Slot)
g_Config.Save(Slot);
// Now we can update the ID
UpdateID();
PadMapping[notebookpage].ID = m_Joyname[notebookpage]->GetSelection();
}
else
{
@ -297,21 +268,6 @@ void PADConfigDialognJoy::DoSave(bool ChangePad, int Slot)
// Then change it back to ""
ToBlank();
}
void PADConfigDialognJoy::UpdateID()
{
INFO_LOG(PAD, "Slot %i: Changed PadMapping ID from %i to %i", notebookpage, PadMapping[notebookpage].ID, m_Joyname[notebookpage]->GetSelection());
PadMapping[notebookpage].ID = joyinfo.at(m_Joyname[notebookpage]->GetSelection()).ID;
PadMapping[notebookpage].Name = joyinfo.at(m_Joyname[notebookpage]->GetSelection()).Name;
// Update all handles
for(int i = 0; i < 4; i++)
{
if (PadMapping[i].Name == PadMapping[notebookpage].Name)
{
if (m_Joyname[i]->GetSelection() >= 0 && joyinfo.size() > m_Joyname[i]->GetSelection())
PadState[i].joy = joyinfo.at(m_Joyname[i]->GetSelection()).joy;
}
}
}
// On changing the SaveById option we update all pages
void PADConfigDialognJoy::OnSaveById()
@ -334,52 +290,11 @@ void PADConfigDialognJoy::OnSaveById()
void PADConfigDialognJoy::DoChangeJoystick()
{
// Before changing the pad we save potential changes to the current pad (to support SaveByID)
WARN_LOG(PAD, "\n--- DoChangeJoystick ----");
WARN_LOG(PAD, "DoSave");
DoSave(true);
// Load the settings for the new ID
WARN_LOG(PAD, "Load");
// Load the settings for the new Id
g_Config.Load(true);
// Update the GUI
WARN_LOG(PAD, "UpdateGUI");
UpdateGUI(notebookpage);
WARN_LOG(PAD, "");
}
// Pads have been connected/disconnected
void PADConfigDialognJoy::UpdateDeviceList()
{
if (!ControlsCreated) return;
DEBUG_LOG(PAD, "UpdateDeviceList");
for (int i = 0; i < 4; i++)
{
// Save current selection
//std::string CurrentSel = m_Joyname[i]->GetValue().mb_str();
m_Joyname[i]->Clear();
// Search for devices and add them to the device list
if (joyinfo.size() > 0)
{
for (int j = 0; j < joyinfo.size(); j++)
m_Joyname[i]->Append(wxString::FromAscii(joyinfo.at(j).Name.c_str()));
// Set selection
//PanicAlert("%s", PadMapping[i].Name.c_str());
for (int j = 0; j < joyinfo.size(); j++)
{
if (joyinfo.at(j).Name == PadMapping[i].Name) m_Joyname[i]->SetSelection(j);
}
if (m_Joyname[i]->GetSelection() == -1) m_Joyname[i]->SetSelection(0);
// Load settings
DoChangeJoystick();
}
else
{
m_Joyname[i]->Append(wxString::FromAscii("<No Gamepad Detected>"));
m_Joyname[i]->SetSelection(0);
}
}
UpdateGUI(notebookpage); // Update the GUI
}
// Notebook page changed
@ -388,7 +303,7 @@ void PADConfigDialognJoy::NotebookPageChanged(wxNotebookEvent& event)
// Save current settings now, don't wait for OK
if (ControlsCreated && !g_Config.bSaveByID) DoSave(false, notebookpage);
// Update the global variable
// Update the global variable
notebookpage = event.GetSelection();
// Update GUI
@ -420,28 +335,28 @@ void PADConfigDialognJoy::ToBlank(bool ToBlank)
}
// Change settings for all slots that have this pad selected
// -----------------------
// Change settings
void PADConfigDialognJoy::SetButtonTextAll(int id, const char *text)
{
for (int i = 0; i < 4; i++)
{
if (IDToName(PadMapping[i].ID) == IDToName(PadMapping[notebookpage].ID))
{
SetButtonText(id, text, i);
DEBUG_LOG(PAD, "Updated button text for slot %i", i);
}
// Safety check to avoid crash
if (joyinfo.size() > (u32)PadMapping[i].ID)
if (joyinfo[PadMapping[i].ID].Name == joyinfo[PadMapping[notebookpage].ID].Name)
SetButtonText(id, text, i);
};
}
void PADConfigDialognJoy::SaveButtonMappingAll(int Slot)
{
for (int i = 0; i < 4; i++)
{
if (PadMapping[i].Name.length() > 0 && PadMapping[i].Name == PadMapping[Slot].Name)
SaveButtonMapping(i, false, Slot);
// This can occur when no gamepad is detected
if (joyinfo.size() > (u32)PadMapping[i].ID)
if (joyinfo[PadMapping[i].ID].Name == joyinfo[PadMapping[Slot].ID].Name)
SaveButtonMapping(i, false, Slot);
}
}
// -----------------------
void PADConfigDialognJoy::UpdateGUIAll(int Slot)
{
@ -453,8 +368,10 @@ void PADConfigDialognJoy::UpdateGUIAll(int Slot)
{
for (int i = 0; i < 4; i++)
{
if (IDToName(PadMapping[i].ID) == IDToName(PadMapping[Slot].ID))
UpdateGUI(i);
// Safety check to avoid crash
if (joyinfo.size() > (u32)PadMapping[i].ID)
if (joyinfo[PadMapping[i].ID].Name == joyinfo[PadMapping[Slot].ID].Name)
UpdateGUI(i);
}
}
}
@ -521,10 +438,8 @@ void PADConfigDialognJoy::ChangeSettings( wxCommandEvent& event )
}
// Update all slots that use this device
//if(g_Config.bSaveByID)
SaveButtonMappingAll(notebookpage);
//if(g_Config.bSaveByID)
UpdateGUIAll(notebookpage);
if(g_Config.bSaveByID) SaveButtonMappingAll(notebookpage);
if(g_Config.bSaveByID) UpdateGUIAll(notebookpage);
}
@ -532,18 +447,12 @@ void PADConfigDialognJoy::ChangeSettings( wxCommandEvent& event )
// Called from: CreateGUIControls(), ChangeControllertype()
void PADConfigDialognJoy::UpdateGUI(int _notebookpage)
{
DEBUG_LOG(PAD, "UpdateGUI for slot %i, %i pads connected", _notebookpage, NumPads);
// If there are no good pads disable the entire notebook
if (NumPads == 0)
if (NumGoodPads == 0)
{
m_Notebook->Enable(false);
return;
}
else
{
m_Notebook->Enable(true);
}
// Update the GUI from PadMapping[]
UpdateGUIButtonMapping(_notebookpage);
@ -596,8 +505,6 @@ void PADConfigDialognJoy::UpdateGUI(int _notebookpage)
else m_CoBRadiusC[_notebookpage]->Enable(false);
if (PadMapping[_notebookpage].bSquareToCircleC) m_CoBDiagonalC[_notebookpage]->Enable(true);
else m_CoBDiagonalC[_notebookpage]->Enable(false);
DEBUG_LOG(PAD, "Main radius %s", PadMapping[_notebookpage].bRadiusOnOff ? "enabled" : "disabled");
}
// Repaint the background
@ -658,9 +565,24 @@ void PADConfigDialognJoy::CreateGUIControls()
m_Controller[3] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE4, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_Controller[3], wxT("Controller 4"));
// Define bitmap for EVT_PAINT
WxStaticBitmap1_BITMAP = wxBitmap(ConfigBox_WxStaticBitmap1_XPM);
// Search for devices and add them to the device list
wxArrayString arrayStringFor_Joyname; // The string array
if (NumGoodPads > 0)
{
for(int x = 0; (u32)x < joyinfo.size(); x++)
{
arrayStringFor_Joyname.Add(wxString::FromAscii(joyinfo[x].Name.c_str()));
}
}
else
{
arrayStringFor_Joyname.Add(wxString::FromAscii("<No Gamepad Detected>"));
}
// Populate the DPad type and Trigger type list
wxArrayString wxAS_DPadType;
wxAS_DPadType.Add(wxString::FromAscii(DPadType[InputCommon::CTL_DPAD_HAT]));
@ -799,9 +721,9 @@ void PADConfigDialognJoy::CreateGUIControls()
// Populate Controller sizer
// Groups
#ifdef _WIN32
m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, wxEmptyString, wxDefaultPosition, wxSize(476, 21), 0, NULL, wxCB_READONLY);
m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, arrayStringFor_Joyname[0], wxDefaultPosition, wxSize(476, 21), arrayStringFor_Joyname, wxCB_READONLY);
#else
m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, wxEmptyString, wxDefaultPosition, wxSize(450, 25), 0, NULL, wxCB_READONLY);
m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, arrayStringFor_Joyname[0], wxDefaultPosition, wxSize(450, 25), arrayStringFor_Joyname, 0, wxDefaultValidator, wxT("m_Joyname"));
#endif
m_gJoyname[i] = new wxStaticBoxSizer (wxHORIZONTAL, m_Controller[i], wxT("Controller"));
@ -1032,6 +954,9 @@ void PADConfigDialognJoy::CreateGUIControls()
// Show or hide it. We have to do this after we add it to its sizer
m_sMainRight[i]->Show(g_Config.bShowAdvanced);
// Update GUI
UpdateGUI(i);
} // end of loop
// Populate buttons sizer.
@ -1050,7 +975,7 @@ void PADConfigDialognJoy::CreateGUIControls()
// Debugging
#ifdef SHOW_PAD_STATUS
m_pStatusBar = new wxStaticText(this, IDT_DEBUGGING, wxT("Debugging"), wxPoint(135, 100), wxSize(200, -1));
m_pStatusBar = new wxStaticText(this, IDT_DEBUGGING, wxT("Debugging"), wxPoint(135, 100), wxDefaultSize);
#endif
// Set window size

View File

@ -62,17 +62,12 @@ class PADConfigDialognJoy : public wxDialog
long style = wxDEFAULT_DIALOG_STYLE);
virtual ~PADConfigDialognJoy();
// Timers
#if wxUSE_TIMER
void OnSlowTimer(wxTimerEvent& WXUNUSED(event)) { UpdateSlow(); }
void OnTimer(wxTimerEvent& WXUNUSED(event)) { Update(); }
void OnButtonTimer(wxTimerEvent& WXUNUSED(event)) { DoGetButtons(GetButtonWaitingID); }
wxTimer *m_SlowTimer, *m_ConstantTimer, *m_ButtonMappingTimer;
wxTimer *m_ConstantTimer, *m_ButtonMappingTimer;
#endif
// Functions
void DoShow();
// Debugging
wxStaticText* m_pStatusBar, * m_pStatusBar2;
wxTextCtrl* m_TCDebugging;
@ -200,10 +195,7 @@ class PADConfigDialognJoy : public wxDialog
*m_bmpSquare[4], *m_bmpDot[4], *m_bmpSquareOut[4], *m_bmpDotOut[4], *m_bmpAreaOut[4],
*m_bmpSquareC[4], *m_bmpDotC[4], *m_bmpSquareOutC[4], *m_bmpDotOutC[4], *m_bmpAreaOutC[4];
// Settings
int notebookpage;
bool ControlsCreated;
bool LiveUpdates;
int notebookpage; bool ControlsCreated;
private:
enum
@ -241,7 +233,7 @@ class PADConfigDialognJoy : public wxDialog
IDT_TRIGGERS, IDCB_CHECKFOCUS, IDCB_FILTER_SETTINGS,
// Timers
IDTM_SLOW, IDTM_CONSTANT, IDTM_BUTTON,
IDTM_CONSTANT, IDTM_BUTTON,
// ==============================================
@ -324,8 +316,6 @@ class PADConfigDialognJoy : public wxDialog
void OKClick(wxCommandEvent& event);
void CancelClick(wxCommandEvent& event);
void DoSave(bool ChangePad = false, int Slot = -1);
void UpdateID();
void StartTimer();
void DoChangeJoystick();
@ -333,22 +323,20 @@ class PADConfigDialognJoy : public wxDialog
void ChangeSettings(wxCommandEvent& event);
void ComboChange(wxCommandEvent& event);
void OnClose(wxCloseEvent& event);
void UpdateDeviceList();
void CreateGUIControls();
void CreateAdvancedControls(int i);
wxBitmap CreateBitmap();
wxBitmap CreateBitmapDot();
wxBitmap CreateBitmapArea(int,int);
void PadShowStatus();
void UpdateSlow();
void PadGetStatus();
void Update();
void UpdateGUIButtonMapping(int controller);
void SaveButtonMapping(int controller, bool DontChangeId = false, int FromSlot = -1);
void SaveButtonMappingAll(int Slot);
void UpdateGUIAll(int Slot = -1);
void UpdateGUIAll(int Slot);
void ToBlank(bool ToBlank = true);
void OnSaveById();

View File

@ -50,11 +50,8 @@ void PADConfigDialognJoy::UpdateGUIButtonMapping(int controller)
// http://wiki.wxwidgets.org/Converting_everything_to_and_from_wxString
wxString tmp;
// Assert
//if (!ControlsCreated[i]) return;
// Update selected gamepad
m_Joyname[controller]->SetValue(wxString::FromAscii(PadMapping[controller].Name.c_str()));
m_Joyname[controller]->SetSelection(PadMapping[controller].ID);
tmp << PadMapping[controller].buttons[InputCommon::CTL_L_SHOULDER]; m_JoyShoulderL[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].buttons[InputCommon::CTL_R_SHOULDER]; m_JoyShoulderR[controller]->SetValue(tmp); tmp.clear();
@ -102,8 +99,7 @@ void PADConfigDialognJoy::UpdateGUIButtonMapping(int controller)
tmp << PadMapping[controller].dpad2[InputCommon::CTL_D_PAD_LEFT]; m_JoyDpadLeft[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].dpad2[InputCommon::CTL_D_PAD_RIGHT]; m_JoyDpadRight[controller]->SetValue(tmp); tmp.clear();
}
NOTICE_LOG(PAD, "Loaded from PadMapping[%i] to slot %i", controller, controller);
}
/* Populate the PadMapping array with the dialog items settings (for example
@ -121,21 +117,7 @@ void PADConfigDialognJoy::SaveButtonMapping(int controller, bool DontChangeId, i
ToBlank(false);
// Set other settings
if(!DontChangeId)
{
if (joyinfo.size() > m_Joyname[FromSlot]->GetSelection())
{
INFO_LOG(PAD, "%i: Changed PadMapping ID from %i to %i", controller, PadMapping[controller].ID, joyinfo.at(m_Joyname[FromSlot]->GetSelection()).ID);
PadMapping[controller].ID = joyinfo.at(m_Joyname[FromSlot]->GetSelection()).ID;
}
//else
// Assert
PadMapping[controller].Name = m_Joyname[FromSlot]->GetValue().mb_str();
}
NOTICE_LOG(PAD, "Saved PadMapping[%i] from slot %i", controller, FromSlot);
// Settings
if(!DontChangeId) PadMapping[controller].ID = m_Joyname[FromSlot]->GetSelection();
PadMapping[controller].controllertype = m_ControlType[FromSlot]->GetSelection();
PadMapping[controller].triggertype = m_TriggerType[FromSlot]->GetSelection();
PadMapping[controller].deadzone = m_Deadzone[FromSlot]->GetSelection();
@ -282,13 +264,6 @@ void PADConfigDialognJoy::GetButtons(wxCommandEvent& event)
void PADConfigDialognJoy::DoGetButtons(int GetId)
{
//INFO_LOG(PAD, "DoGetButtons: %i", GetId);
if (!SDLPolling || SDL_JoystickEventState(SDL_QUERY) == SDL_ENABLE) return;
// Turn off live updates because the change the joy handles
LiveUpdates = false;
// =============================================
// Collect the starting values
// ----------------
@ -305,7 +280,7 @@ void PADConfigDialognJoy::DoGetButtons(int GetId)
int Axes = SDL_JoystickNumAxes(joy);
int Hats = SDL_JoystickNumHats(joy);
//NOTICE_LOG(PAD, "PadID: %i Axes: %i Handle: %i\n", PadID, joyinfo[PadID].NumAxes, joyinfo[PadID].joy);
INFO_LOG(CONSOLE, "PadID: %i Axes: %i\n", PadID, joyinfo[PadID].NumAxes, joyinfo[PadID].joy);
// Get the controller and trigger type
int ControllerType = PadMapping[Controller].controllertype;
@ -368,8 +343,6 @@ void PADConfigDialognJoy::DoGetButtons(int GetId)
#if wxUSE_TIMER
m_ButtonMappingTimer->Start( floor((double)(1000 / TimesPerSecond)) );
#endif
//INFO_LOG(PAD, "Timer started");
}
// ===============================================
@ -380,7 +353,7 @@ void PADConfigDialognJoy::DoGetButtons(int GetId)
else
{
InputCommon::GetButton(
joy, PadID,
joy, PadID, Buttons, Axes, Hats,
g_Pressed, value, type, pressed, Succeed, Stop,
LeftRight, Axis, XInput, Button, Hat, NoTriggerFilter);
}
@ -395,7 +368,7 @@ void PADConfigDialognJoy::DoGetButtons(int GetId)
GetButtonWaitingTimer++;
// This is run every second
if (GetButtonWaitingTimer % TimesPerSecond == 0)
if(GetButtonWaitingTimer % TimesPerSecond == 0)
{
// Current time
int TmpTime = Seconds - (GetButtonWaitingTimer / TimesPerSecond);
@ -406,7 +379,7 @@ void PADConfigDialognJoy::DoGetButtons(int GetId)
}
// Time's up
if ( (GetButtonWaitingTimer / TimesPerSecond) >= Seconds )
if( (GetButtonWaitingTimer / TimesPerSecond) >= Seconds )
{
Stop = true;
// Leave a blank mapping
@ -414,10 +387,8 @@ void PADConfigDialognJoy::DoGetButtons(int GetId)
}
// If we got a button
if (Succeed)
if(Succeed)
{
//INFO_LOG(PAD, "Button mapping succeeded: %i", pressed);
Stop = true;
// Write the number of the pressed button to the text box
sprintf(format, "%d", pressed);
@ -425,12 +396,10 @@ void PADConfigDialognJoy::DoGetButtons(int GetId)
}
// Stop the timer
if (Stop)
if(Stop)
{
m_ButtonMappingTimer->Stop();
GetButtonWaitingTimer = 0;
LiveUpdates = true;
//INFO_LOG(PAD, "Timer stopped");
/* Update the button mapping for all slots that use this device. (It doesn't make sense to have several slots
controlled by the same device, but several DirectInput instances of different but identical devices may possible