mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-10 06:29:00 +01:00
nJoy: Don't allow input when Dolphin is not in focus (supports both the
rendering to main window and render to separate window options) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2062 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
ad995a68ea
commit
8c9d07b26b
@ -462,7 +462,7 @@ void ConfigBox::UpdateGUI(int _notebookpage)
|
||||
m_textDpadLeft[_notebookpage]->Show(!Hat);
|
||||
m_textDpadRight[_notebookpage]->Show(!Hat);
|
||||
|
||||
m_textDpadDown[_notebookpage]->SetLabel(Hat ? wxT("Select hat") : wxT("Up"));
|
||||
m_textDpadDown[_notebookpage]->SetLabel(Hat ? wxT("Select hat") : wxT("Down"));
|
||||
m_bJoyDpadDown[_notebookpage]->SetToolTip(Hat ?
|
||||
wxT("Select a hat by pressing the hat in any direction") : wxT(""));
|
||||
|
||||
|
@ -90,6 +90,7 @@ CONTROLLER_MAPPING PadMapping[4];
|
||||
bool emulator_running = false;
|
||||
int NumPads = 0, NumGoodPads = 0;
|
||||
HWND m_hWnd; // Handle to window
|
||||
SPADInitialize *g_PADInitialize;
|
||||
|
||||
// TODO: fix this dirty hack to stop missing symbols
|
||||
void __Log(int log, const char *format, ...) {}
|
||||
@ -239,7 +240,7 @@ void Initialize(void *init)
|
||||
// Debugging
|
||||
//Console::Open();
|
||||
Console::Print("Initialize: %i\n", SDL_WasInit(0));
|
||||
SPADInitialize *_PADInitialize = (SPADInitialize*)init;
|
||||
g_PADInitialize = (SPADInitialize*)init;
|
||||
emulator_running = true;
|
||||
|
||||
#ifdef _DEBUG
|
||||
@ -247,7 +248,7 @@ void Initialize(void *init)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
m_hWnd = (HWND)_PADInitialize->hWnd;
|
||||
m_hWnd = (HWND)g_PADInitialize->hWnd;
|
||||
#endif
|
||||
|
||||
NumPads = Search_Devices(); // Populate joyinfo for all attached devices
|
||||
@ -259,7 +260,7 @@ void Initialize(void *init)
|
||||
|| (PadMapping[2].enabled && PadState[2].joy == NULL)
|
||||
|| (PadMapping[3].enabled && PadState[3].joy == NULL))
|
||||
{
|
||||
_PADInitialize->padNumber = -1;
|
||||
g_PADInitialize->padNumber = -1;
|
||||
Console::Print("%s\n", SDL_GetError());
|
||||
}
|
||||
}
|
||||
@ -398,6 +399,9 @@ 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;
|
||||
|
||||
// Check if the keys are interesting, and then update it
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
@ -606,6 +610,29 @@ unsigned int PAD_GetAttachedPads()
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Supporting functions
|
||||
//******************************************************************************
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Check if Dolphin is in focus
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
bool IsFocus()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HWND Parent = GetParent(g_PADInitialize->hWnd);
|
||||
HWND TopLevel = GetParent(Parent);
|
||||
// Support both rendering to main window and not
|
||||
if (GetForegroundWindow() == TopLevel || GetForegroundWindow() == g_PADInitialize->hWnd)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Convert stick values
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
@ -747,6 +774,9 @@ void ReadButton(int controller, int button)
|
||||
for a virtual controller 0 to 3. */
|
||||
void GetJoyState(int controller)
|
||||
{
|
||||
// Check that Dolphin is in focus, otherwise don't update the pad status
|
||||
if (!IsFocus()) return;
|
||||
|
||||
// Update the gamepad status
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
|
@ -243,6 +243,7 @@ void GetJoyState(int controller);
|
||||
int Search_Devices();
|
||||
void DEBUG_INIT();
|
||||
void DEBUG_QUIT();
|
||||
bool IsFocus();
|
||||
|
||||
void Pad_Use_Rumble(u8 _numPAD, SPADStatus* _pPADStatus); // Rumble
|
||||
int Pad_Convert(int _val); // Value conversion
|
||||
|
Loading…
x
Reference in New Issue
Block a user