PadSimple: Don't allow input when Dolphin is not in focus supports the rendering to main window option to

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2058 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2009-02-01 15:48:52 +00:00
parent d352372ccf
commit 4837dac8b6
2 changed files with 26 additions and 2 deletions

View File

@ -60,6 +60,10 @@ SPADInitialize g_PADInitialize;
SPADStatus recordBuffer[RECORD_SIZE]; SPADStatus recordBuffer[RECORD_SIZE];
int count = 0; int count = 0;
//******************************************************************************
// Supporting functions
//******************************************************************************
void RecordInput(const SPADStatus& _rPADStatus) void RecordInput(const SPADStatus& _rPADStatus)
{ {
if (count >= RECORD_SIZE) if (count >= RECORD_SIZE)
@ -102,6 +106,18 @@ void SaveRecord()
} }
} }
// Check if Dolphin is in focus
bool IsFocus()
{
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;
}
#ifdef _WIN32 #ifdef _WIN32
@ -147,6 +163,11 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
#endif #endif
//******************************************************************************
// Plugin specification functions
//******************************************************************************
void GetDllInfo(PLUGIN_INFO* _PluginInfo) void GetDllInfo(PLUGIN_INFO* _PluginInfo)
{ {
_PluginInfo->Version = 0x0100; _PluginInfo->Version = 0x0100;
@ -618,8 +639,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
// TODO fix g_PADInitialize.hWnd != DolphinWX frame // TODO fix g_PADInitialize.hWnd != DolphinWX frame
if (pad[_numPAD].bDisable) if (pad[_numPAD].bDisable)
{ {
if (g_PADInitialize.hWnd != GetForegroundWindow()) if (!IsFocus()) return;
return;
} }
// Dolphin doesn't really care about the pad error codes anyways... // Dolphin doesn't really care about the pad error codes anyways...
_pPADStatus->err = PAD_ERR_NONE; _pPADStatus->err = PAD_ERR_NONE;
@ -689,6 +709,9 @@ unsigned int PAD_GetAttachedPads()
return connected; return connected;
} }
//******************************************************************************
// Load and save the configuration
//******************************************************************************
void LoadConfig() void LoadConfig()
{ {

View File

@ -86,5 +86,6 @@ extern SPads pad[];
void LoadConfig(); void LoadConfig();
void SaveConfig(); void SaveConfig();
bool IsFocus();
#endif #endif