From f999ae94df58ce7403990b673bb1d7b4cd23bc33 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Tue, 3 Feb 2009 06:21:22 +0000 Subject: [PATCH] Make checking for focus optional for njoy input. So if one wants, on one monitor play Dolphin, and on the other use the keyboard for something else git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2082 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp | 2 ++ Source/Plugins/Plugin_nJoy_SDL/Src/Config.h | 1 + Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp | 12 +++++++++++- Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h | 4 ++-- Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp | 5 +++-- Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h | 1 + 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp index a425e7576a..bfe22f2f01 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/Config.cpp @@ -164,6 +164,7 @@ void Config::Save(int Slot) file.Set(SectionName.c_str(), "Diagonal", PadMapping[i].SDiagonal); file.Set(SectionName.c_str(), "SquareToCircle", PadMapping[i].bSquareToCircle); + file.Set(SectionName.c_str(), "CheckForFocus", bCheckFocus); // ====================================== // Debugging @@ -246,6 +247,7 @@ void Config::Load(bool ChangePad, bool ChangeSaveByID) file.Get(SectionName.c_str(), "Diagonal", &PadMapping[i].SDiagonal, "100%"); file.Get(SectionName.c_str(), "SquareToCircle", &Tmp, false); PadMapping[i].bSquareToCircle = Tmp; + file.Get(SectionName.c_str(), "CheckForFocus", &bCheckFocus, true); // ============================= // Debugging diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/Config.h b/Source/Plugins/Plugin_nJoy_SDL/Src/Config.h index f7002ff66a..de1a91e86a 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/Config.h +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/Config.h @@ -28,6 +28,7 @@ struct Config // General bool bShowAdvanced; // Only allow one of these bool bSaveByID; + bool bCheckFocus; }; extern Config g_Config; diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp index dfba6e4d3b..e80994deb0 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp @@ -74,6 +74,7 @@ BEGIN_EVENT_TABLE(ConfigBox,wxDialog) // Other settings EVT_CHECKBOX(IDC_SAVEBYID, ConfigBox::ChangeSettings) EVT_CHECKBOX(IDC_SHOWADVANCED, ConfigBox::ChangeSettings) + EVT_CHECKBOX(IDC_CHECKFOCUS, ConfigBox::ChangeSettings) EVT_COMBOBOX(IDCB_MAINSTICK_DIAGONAL, ConfigBox::ChangeSettings) EVT_COMBOBOX(IDC_CONTROLTYPE, ConfigBox::ChangeSettings) EVT_COMBOBOX(IDC_TRIGGERTYPE, ConfigBox::ChangeSettings) @@ -415,7 +416,13 @@ void ConfigBox::ChangeSettings( wxCommandEvent& event ) } SizeWindow(); break; - + case IDC_CHECKFOCUS: + bCheckFocus = m_CBCheckFocus[notebookpage]->IsChecked(); + for(int i = 0; i < 4; i++) + { + m_CBCheckFocus[i]->SetValue(bCheckFocus); + } + break; case IDC_CONTROLTYPE: case IDC_TRIGGERTYPE: //UpdateGUI(notebookpage); @@ -481,6 +488,7 @@ void ConfigBox::UpdateGUI(int _notebookpage) // General settings m_CBSaveByID[_notebookpage]->SetValue(g_Config.bSaveByID); m_CBShowAdvanced[_notebookpage]->SetValue(g_Config.bShowAdvanced); + m_CBCheckFocus[_notebookpage]->SetValue(g_Config.bCheckFocus); LogMsg("Update: %i\n", g_Config.bSaveByID); @@ -796,10 +804,12 @@ void ConfigBox::CreateGUIControls() m_gGenSettingsID[i] = new wxStaticBoxSizer( wxVERTICAL, m_Controller[i], wxT("Settings") ); m_CBSaveByID[i] = new wxCheckBox(m_Controller[i], IDC_SAVEBYID, wxT("Save by ID"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_CBShowAdvanced[i] = new wxCheckBox(m_Controller[i], IDC_SHOWADVANCED, wxT("Show advanced settings"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_CBCheckFocus[i] = new wxCheckBox(m_Controller[i], IDC_CHECKFOCUS, wxT("Only accept input when Dolphin is in focus"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); // Populate general settings 3 m_gGenSettingsID[i]->Add(m_CBSaveByID[i], 0, wxEXPAND | wxALL, 3); m_gGenSettingsID[i]->Add(m_CBShowAdvanced[i], 0, wxEXPAND | wxALL, 3); + m_gGenSettingsID[i]->Add(m_CBCheckFocus[i], 0, wxEXPAND | wxALL, 3); // Create tooltips m_ControlType[i]->SetToolTip(wxT( diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h index fa1f953e19..80823dc868 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h @@ -112,7 +112,7 @@ class ConfigBox : public wxDialog wxStaticBoxSizer *m_gGenSettingsID[4]; wxGridBagSizer * m_gGBGenSettings[4]; - wxCheckBox *m_CBSaveByID[4], *m_CBShowAdvanced[4]; + wxCheckBox *m_CBSaveByID[4], *m_CBShowAdvanced[4], *m_CBCheckFocus[4]; wxStaticText *m_TSControltype[4], *m_TSTriggerType[4]; wxStaticBoxSizer *m_gStatusIn[4], *m_gStatusInSettings[4]; // Advanced settings @@ -210,7 +210,7 @@ class ConfigBox : public wxDialog IDG_CONTROLLERTYPE, IDC_CONTROLTYPE, IDC_TRIGGERTYPE, // Controller type - IDC_SAVEBYID, IDC_SHOWADVANCED, // Settings + IDC_SAVEBYID, IDC_SHOWADVANCED, IDC_CHECKFOCUS, // Settings ID_INSTATUS1, ID_INSTATUS2, ID_INSTATUS3, ID_INSTATUS4, // Advanced status ID_STATUSBMP1, ID_STATUSBMP2, ID_STATUSBMP3, ID_STATUSBMP4, diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp index 396b10dfe4..0f3a274d81 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp @@ -89,6 +89,7 @@ CONTROLLER_STATE PadState[4]; CONTROLLER_MAPPING PadMapping[4]; bool emulator_running = false; int NumPads = 0, NumGoodPads = 0; +bool bCheckFocus = true; HWND m_hWnd; // Handle to window SPADInitialize *g_PADInitialize = NULL; @@ -400,7 +401,7 @@ void Shutdown() void PAD_Input(u16 _Key, u8 _UpDown) { // Check that Dolphin is in focus, otherwise don't update the pad status - if (!IsFocus()) return; + if (bCheckFocus && !IsFocus()) return; // Check if the keys are interesting, and then update it for(int i = 0; i < 4; i++) @@ -784,7 +785,7 @@ void ReadButton(int controller, int button) void GetJoyState(int controller) { // Check that Dolphin is in focus, otherwise don't update the pad status - if (!IsFocus()) return; + if (bCheckFocus && !IsFocus()) return; // Update the gamepad status SDL_JoystickUpdate(); diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h index 9295304e7e..00b5a7b894 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h @@ -232,6 +232,7 @@ extern std::vector Keys; extern CONTROLLER_MAPPING PadMapping[4]; extern HWND m_hWnd; // Handle to window extern int NumPads, NumGoodPads; // Number of goods pads + extern bool bCheckFocus; #endif