Move async checking for pressed keys into Host_GetKeyState()

and use wxGetKeyState on platforms other than Windows.

I am not sure if wxGetKeyState is unreliable on Windows or if
the use of GetAsyncKeyState() is simply historical, but for now
I've left the Windows call in there just in case.

This does mean that Host_GetKeyState() is currently only valid
for the small set of keycodes that overlap between wx and Win32,
one of which is VK_TAB/WXK_TAB.

Anyway, please test wxGetKeyState on Windows and remove the
ifdef if it works, so we can extend it to the remaining hotkeys.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6988 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang 2011-01-30 16:40:38 +00:00
parent 864d24a86e
commit db1765c425
8 changed files with 26 additions and 60 deletions

View File

@ -20,6 +20,7 @@
#include "Mixer.h"
#include "AudioCommon.h"
#include "CPUDetect.h"
#include "Host.h"
#include "../../Core/Src/HW/AudioInterface.h"
@ -148,9 +149,8 @@ void CMixer::PushSamples(const short *samples, unsigned int num_samples)
if (*PowerPC::GetStatePtr() != 0)
break;
// Shortcut key for Throttle Skipping
#ifdef _WIN32
if (GetAsyncKeyState(VK_TAB)) break;;
#endif
if (Host_GetKeyState('\t'))
break;
SLEEP(1);
soundStream->Update();
}

View File

@ -78,7 +78,6 @@ void CBoot::Load_FST(bool _bIsWii)
void CBoot::UpdateDebugger_MapLoaded(const char *_gameID)
{
Host_NotifyMapLoaded();
Host_UpdateMemoryView();
}
std::string CBoot::GenerateMapFilename()

View File

@ -557,11 +557,8 @@ void VideoThrottle()
u32 TargetVPS = (SConfig::GetInstance().m_Framelimit > 1) ?
SConfig::GetInstance().m_Framelimit * 5 : VideoInterface::TargetRefreshRate;
#ifdef _WIN32
// Disable the frame-limiter when the throttle (Tab) key is held down
if (!GetAsyncKeyState(VK_TAB))
#endif
if (SConfig::GetInstance().m_Framelimit)
if (SConfig::GetInstance().m_Framelimit && !Host_GetKeyState('\t'))
{
u32 frametime = ((SConfig::GetInstance().b_UseFPS)? Common::AtomicLoad(DrawnFrame) : DrawnVideo) * 1000 / TargetVPS;

View File

@ -114,13 +114,10 @@ void CCPU::EnableStepping(const bool _bStepping)
if (_bStepping)
{
PowerPC::Pause();
// TODO(ector): why a sleep?
Host_SetDebugMode(true);
CPluginManager::GetInstance().EmuStateChange(PLUGIN_EMUSTATE_PAUSE);
}
else
{
Host_SetDebugMode(false);
PowerPC::Start();
m_StepEvent.Set();
CPluginManager::GetInstance().EmuStateChange(PLUGIN_EMUSTATE_PLAY);

View File

@ -36,26 +36,22 @@
// The host can be just a command line app that opens a window, or a full blown debugger
// interface.
bool Host_RendererHasFocus();
void Host_ConnectWiimote(int wm_idx, bool connect);
bool Host_GetKeyState(int keycode);
void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height);
void Host_Message(int Id);
void Host_UpdateMainFrame();
void Host_UpdateTitle(const char* title);
void Host_NotifyMapLoaded();
void Host_RequestRenderWindowSize(int width, int height);
void Host_SetWaitCursor(bool enable);
void Host_SetWiiMoteConnectionState(int _State);
void Host_ShowJitResults(unsigned int address);
void Host_SysMessage(const char *fmt, ...);
void Host_UpdateBreakPointView();
void Host_UpdateDisasmDialog();
void Host_UpdateLogDisplay();
void Host_UpdateMemoryView();
void Host_NotifyMapLoaded();
void Host_UpdateBreakPointView();
void Host_ShowJitResults(unsigned int address);
void Host_SetDebugMode(bool enable);
void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height);
void Host_RequestRenderWindowSize(int width, int height);
bool Host_RendererHasFocus();
void Host_SetWaitCursor(bool enable);
void Host_UpdateMainFrame();
void Host_UpdateStatusBar(const char* _pText, int Filed = 0);
void Host_SysMessage(const char *fmt, ...);
void Host_SetWiiMoteConnectionState(int _State);
void Host_ConnectWiimote(int wm_idx, bool connect);
void Host_UpdateTitle(const char* title);
#endif

View File

@ -564,11 +564,14 @@ void Host_UpdateBreakPointView()
}
}
void Host_UpdateMemoryView()
{}
void Host_SetDebugMode(bool)
{}
bool Host_GetKeyState(int keycode)
{
#ifdef _WIN32
return GetAsyncKeyState(keycode);
#else
return wxGetKeyState(wxKeyCode(keycode));
#endif
}
void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height)
{

View File

@ -76,9 +76,7 @@ void Host_UpdateMainFrame()
void Host_UpdateBreakPointView(){}
void Host_UpdateMemoryView(){}
void Host_SetDebugMode(bool){}
bool Host_GetKeyState(int keycode){}
void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height)
{

View File

@ -146,27 +146,3 @@ int main(int argc, char* argv[])
}
return 0;
}
// Pretend that we are a host so we can link to core.... urgh.
//==============================================================
void Host_UpdateMainFrame(){}
void Host_UpdateDisasmDialog(){}
void Host_UpdateLogDisplay(){}
void Host_UpdateMemoryView(){}
void Host_NotifyMapLoaded(){}
void Host_ShowJitResults(unsigned int address){}
void Host_UpdateBreakPointView(){}
void Host_SetDebugMode(bool enable){}
void Host_SetWaitCursor(bool enable){}
void Host_UpdateStatusBar(const char* _pText, int Filed = 0){}
void Host_SysMessage(const char *fmt, ...){}
void Host_SetWiiMoteConnectionState(int _State){}
void Host_UpdateLeds(int bits){}
void Host_UpdateSpeakerStatus(int index, int bits){}
void Host_UpdateStatus(){}
void Host_Message(int){}