mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Wiimote and nJoy > Gamepad changes
1. Added LiveUpdates, while the configuration window is open nJoy and Wiimote will check for connected/disconnected pads 2. Removed the 'Nintendo RVL-CNT-01' device from the device list, and other SDL devices with no axes/buttons 3. Added SDL (from the current SVN) to get debugging information for SDL.dll 4. Added 'Upright Wiimote' option to emulated Wiimote options git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4534 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
|
||||
// Project description
|
||||
// -------------------
|
||||
// Name: nJoy
|
||||
@ -32,14 +31,15 @@
|
||||
// ---------
|
||||
#include "ConfigBox.h"
|
||||
#include "../nJoy.h"
|
||||
#include "LogManager.h"
|
||||
#include "Images/controller.xpm"
|
||||
|
||||
extern bool g_EmulatorRunning;
|
||||
|
||||
// Set PAD status
|
||||
// --------------
|
||||
void PADConfigDialognJoy::PadGetStatus()
|
||||
{
|
||||
void PADConfigDialognJoy::PadShowStatus()
|
||||
{
|
||||
// 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::PadGetStatus()
|
||||
}
|
||||
|
||||
// Get physical device status
|
||||
int PhysicalDevice = PadMapping[notebookpage].ID;
|
||||
int ID = PadMapping[notebookpage].ID;
|
||||
int TriggerType = PadMapping[notebookpage].triggertype;
|
||||
|
||||
// Get original values
|
||||
@ -105,7 +105,6 @@ void PADConfigDialognJoy::PadGetStatus()
|
||||
m_bmpDotOutC[notebookpage]->SetPosition(wxPoint(sub_x_out, sub_y_out));
|
||||
///////////////////// Analog stick
|
||||
|
||||
|
||||
|
||||
// Triggers
|
||||
// -----------------
|
||||
@ -143,84 +142,12 @@ void PADConfigDialognJoy::PadGetStatus()
|
||||
///////////////////// Triggers
|
||||
}
|
||||
|
||||
// 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
|
||||
// Update 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
|
||||
@ -228,17 +155,41 @@ void PADConfigDialognJoy::Update()
|
||||
if (g_Config.bCheckFocus || IsFocus()) // && !g_EmulatorRunning)
|
||||
{
|
||||
for (int i = 0; (u32)i < joyinfo.size(); i++)
|
||||
InputCommon::GetJoyState(PadState[i], PadMapping[i], i, joyinfo[PadMapping[i].ID].NumButtons);
|
||||
InputCommon::GetJoyState(PadState[notebookpage], PadMapping[notebookpage]);
|
||||
PadShowStatus();
|
||||
}
|
||||
|
||||
// Show the current status in a window in the wxPanel
|
||||
#ifdef SHOW_PAD_STATUS
|
||||
m_pStatusBar->SetLabel(wxString::Format(
|
||||
"%s", ShowStatus(notebookpage).c_str()
|
||||
));
|
||||
m_pStatusBar->SetLabel(wxString::FromAscii(InputCommon::ShowStatus(
|
||||
notebookpage, m_Joyname[notebookpage]->GetSelection(),
|
||||
PadMapping, PadState, joyinfo
|
||||
).c_str()));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Search for devices
|
||||
void PADConfigDialognJoy::UpdateSlow()
|
||||
{
|
||||
if (!LiveUpdates) return;
|
||||
|
||||
// Search for connected devices and update dialog
|
||||
int 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
|
||||
// -----------------
|
||||
@ -368,6 +319,5 @@ 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;
|
||||
}
|
@ -103,6 +103,7 @@ 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
|
||||
@ -112,26 +113,40 @@ PADConfigDialognJoy::PADConfigDialognJoy(wxWindow *parent, wxWindowID id, const
|
||||
const wxPoint &position, const wxSize& size, long style)
|
||||
: wxDialog(parent, id, title, position, size, style)
|
||||
{
|
||||
// Define values
|
||||
// Initialize values
|
||||
notebookpage = 0;
|
||||
g_Pressed = 0;
|
||||
Debugging = false;
|
||||
g_Pressed = 0;
|
||||
m_TCDebugging = NULL;
|
||||
ControlsCreated = false;
|
||||
|
||||
// Settings
|
||||
Debugging = false;
|
||||
// Only tested in Windows
|
||||
#ifdef _WIN32
|
||||
LiveUpdates = true;
|
||||
#else
|
||||
LiveUpdates = false;
|
||||
#endif
|
||||
|
||||
// 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 the constant timer
|
||||
int TimesPerSecond = 30;
|
||||
m_ConstantTimer->Start( floor((double)(1000 / TimesPerSecond)) );
|
||||
// Start timers
|
||||
StartTimer();
|
||||
#endif
|
||||
|
||||
// wxEVT_KEY_DOWN is blocked for enter, tab and the directional keys
|
||||
@ -148,6 +163,24 @@ 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();
|
||||
@ -160,7 +193,9 @@ 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();
|
||||
@ -256,7 +291,7 @@ void PADConfigDialognJoy::DoSave(bool ChangePad, int Slot)
|
||||
|
||||
g_Config.Save(Slot);
|
||||
// Now we can update the ID
|
||||
PadMapping[notebookpage].ID = m_Joyname[notebookpage]->GetSelection();
|
||||
UpdateID();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -268,6 +303,21 @@ 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()
|
||||
@ -290,11 +340,52 @@ 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
|
||||
// Load the settings for the new ID
|
||||
WARN_LOG(PAD, "Load");
|
||||
g_Config.Load(true);
|
||||
UpdateGUI(notebookpage); // Update the GUI
|
||||
// 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 (NumPads > 0)
|
||||
{
|
||||
for (int j = 0; j < NumPads; 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 < NumPads; 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Notebook page changed
|
||||
@ -303,7 +394,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
|
||||
@ -335,28 +426,28 @@ void PADConfigDialognJoy::ToBlank(bool ToBlank)
|
||||
}
|
||||
|
||||
|
||||
// Change settings
|
||||
// Change settings for all slots that have this pad selected
|
||||
// -----------------------
|
||||
void PADConfigDialognJoy::SetButtonTextAll(int id, const char *text)
|
||||
{
|
||||
for (int i = 0; i < 4; 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);
|
||||
if (IDToName(PadMapping[i].ID) == IDToName(PadMapping[notebookpage].ID))
|
||||
{
|
||||
SetButtonText(id, text, i);
|
||||
DEBUG_LOG(PAD, "Updated button text for slot %i", i);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void PADConfigDialognJoy::SaveButtonMappingAll(int Slot)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
// 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);
|
||||
if (IDToName(PadMapping[i].ID) == IDToName(PadMapping[Slot].ID))
|
||||
SaveButtonMapping(i, false, Slot);
|
||||
}
|
||||
}
|
||||
// -----------------------
|
||||
|
||||
void PADConfigDialognJoy::UpdateGUIAll(int Slot)
|
||||
{
|
||||
@ -368,10 +459,8 @@ void PADConfigDialognJoy::UpdateGUIAll(int Slot)
|
||||
{
|
||||
for (int i = 0; i < 4; 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);
|
||||
if (IDToName(PadMapping[i].ID) == IDToName(PadMapping[Slot].ID))
|
||||
UpdateGUI(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -438,8 +527,10 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@ -447,12 +538,18 @@ 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 (NumGoodPads == 0)
|
||||
if (NumPads == 0)
|
||||
{
|
||||
m_Notebook->Enable(false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Notebook->Enable(true);
|
||||
}
|
||||
|
||||
// Update the GUI from PadMapping[]
|
||||
UpdateGUIButtonMapping(_notebookpage);
|
||||
@ -505,6 +602,8 @@ 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
|
||||
@ -565,24 +664,9 @@ 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]));
|
||||
@ -721,7 +805,7 @@ void PADConfigDialognJoy::CreateGUIControls()
|
||||
// Populate Controller sizer
|
||||
// Groups
|
||||
#ifdef _WIN32
|
||||
m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, arrayStringFor_Joyname[0], wxDefaultPosition, wxSize(476, 21), arrayStringFor_Joyname, wxCB_READONLY);
|
||||
m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, wxEmptyString, wxDefaultPosition, wxSize(476, 21), 0, NULL, wxCB_READONLY);
|
||||
#else
|
||||
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
|
||||
@ -954,9 +1038,6 @@ 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.
|
||||
@ -975,7 +1056,7 @@ void PADConfigDialognJoy::CreateGUIControls()
|
||||
|
||||
// Debugging
|
||||
#ifdef SHOW_PAD_STATUS
|
||||
m_pStatusBar = new wxStaticText(this, IDT_DEBUGGING, wxT("Debugging"), wxPoint(135, 100), wxDefaultSize);
|
||||
m_pStatusBar = new wxStaticText(this, IDT_DEBUGGING, wxT("Debugging"), wxPoint(135, 100), wxSize(200, -1));
|
||||
#endif
|
||||
|
||||
// Set window size
|
||||
|
@ -62,12 +62,17 @@ 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_ConstantTimer, *m_ButtonMappingTimer;
|
||||
wxTimer *m_SlowTimer, *m_ConstantTimer, *m_ButtonMappingTimer;
|
||||
#endif
|
||||
|
||||
// Functions
|
||||
void DoShow();
|
||||
|
||||
// Debugging
|
||||
wxStaticText* m_pStatusBar, * m_pStatusBar2;
|
||||
wxTextCtrl* m_TCDebugging;
|
||||
@ -195,7 +200,10 @@ 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];
|
||||
|
||||
int notebookpage; bool ControlsCreated;
|
||||
// Settings
|
||||
int notebookpage;
|
||||
bool ControlsCreated;
|
||||
bool LiveUpdates;
|
||||
|
||||
private:
|
||||
enum
|
||||
@ -233,7 +241,7 @@ class PADConfigDialognJoy : public wxDialog
|
||||
IDT_TRIGGERS, IDCB_CHECKFOCUS, IDCB_FILTER_SETTINGS,
|
||||
|
||||
// Timers
|
||||
IDTM_CONSTANT, IDTM_BUTTON,
|
||||
IDTM_SLOW, IDTM_CONSTANT, IDTM_BUTTON,
|
||||
|
||||
|
||||
// ==============================================
|
||||
@ -316,6 +324,8 @@ 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();
|
||||
|
||||
@ -323,20 +333,22 @@ 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 PadGetStatus();
|
||||
void PadShowStatus();
|
||||
void UpdateSlow();
|
||||
void Update();
|
||||
|
||||
void UpdateGUIButtonMapping(int controller);
|
||||
void SaveButtonMapping(int controller, bool DontChangeId = false, int FromSlot = -1);
|
||||
void SaveButtonMappingAll(int Slot);
|
||||
void UpdateGUIAll(int Slot);
|
||||
void UpdateGUIAll(int Slot = -1);
|
||||
void ToBlank(bool ToBlank = true);
|
||||
void OnSaveById();
|
||||
|
||||
|
@ -50,8 +50,11 @@ 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]->SetSelection(PadMapping[controller].ID);
|
||||
m_Joyname[controller]->SetValue(wxString::FromAscii(PadMapping[controller].Name.c_str()));
|
||||
|
||||
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();
|
||||
@ -99,7 +102,8 @@ 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
|
||||
@ -117,7 +121,21 @@ void PADConfigDialognJoy::SaveButtonMapping(int controller, bool DontChangeId, i
|
||||
ToBlank(false);
|
||||
|
||||
// Set other settings
|
||||
if(!DontChangeId) PadMapping[controller].ID = m_Joyname[FromSlot]->GetSelection();
|
||||
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
|
||||
PadMapping[controller].controllertype = m_ControlType[FromSlot]->GetSelection();
|
||||
PadMapping[controller].triggertype = m_TriggerType[FromSlot]->GetSelection();
|
||||
PadMapping[controller].deadzone = m_Deadzone[FromSlot]->GetSelection();
|
||||
@ -264,6 +282,13 @@ 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
|
||||
// ----------------
|
||||
@ -280,7 +305,7 @@ void PADConfigDialognJoy::DoGetButtons(int GetId)
|
||||
int Axes = SDL_JoystickNumAxes(joy);
|
||||
int Hats = SDL_JoystickNumHats(joy);
|
||||
|
||||
INFO_LOG(CONSOLE, "PadID: %i Axes: %i\n", PadID, joyinfo[PadID].NumAxes, joyinfo[PadID].joy);
|
||||
//NOTICE_LOG(PAD, "PadID: %i Axes: %i Handle: %i\n", PadID, joyinfo[PadID].NumAxes, joyinfo[PadID].joy);
|
||||
|
||||
// Get the controller and trigger type
|
||||
int ControllerType = PadMapping[Controller].controllertype;
|
||||
@ -343,6 +368,8 @@ void PADConfigDialognJoy::DoGetButtons(int GetId)
|
||||
#if wxUSE_TIMER
|
||||
m_ButtonMappingTimer->Start( floor((double)(1000 / TimesPerSecond)) );
|
||||
#endif
|
||||
|
||||
//INFO_LOG(PAD, "Timer started");
|
||||
}
|
||||
|
||||
// ===============================================
|
||||
@ -353,7 +380,7 @@ void PADConfigDialognJoy::DoGetButtons(int GetId)
|
||||
else
|
||||
{
|
||||
InputCommon::GetButton(
|
||||
joy, PadID, Buttons, Axes, Hats,
|
||||
joy, PadID,
|
||||
g_Pressed, value, type, pressed, Succeed, Stop,
|
||||
LeftRight, Axis, XInput, Button, Hat, NoTriggerFilter);
|
||||
}
|
||||
@ -368,7 +395,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);
|
||||
@ -379,7 +406,7 @@ void PADConfigDialognJoy::DoGetButtons(int GetId)
|
||||
}
|
||||
|
||||
// Time's up
|
||||
if( (GetButtonWaitingTimer / TimesPerSecond) >= Seconds )
|
||||
if ( (GetButtonWaitingTimer / TimesPerSecond) >= Seconds )
|
||||
{
|
||||
Stop = true;
|
||||
// Leave a blank mapping
|
||||
@ -387,8 +414,10 @@ 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);
|
||||
@ -396,10 +425,12 @@ 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
|
||||
|
Reference in New Issue
Block a user