Use CPad functions to check key states in script loader

This commit is contained in:
Sergeanur 2021-07-08 03:24:47 +03:00
parent f9a2f1daf7
commit 47f153fe76
2 changed files with 6 additions and 24 deletions

View file

@ -1769,21 +1769,16 @@ void CRunningScript::Init()
#ifdef USE_DEBUG_SCRIPT_LOADER #ifdef USE_DEBUG_SCRIPT_LOADER
int scriptToLoad = 0; int scriptToLoad = 0;
#ifdef _WIN32
extern "C" __declspec(dllimport) short __stdcall GetAsyncKeyState(int);
#endif
int open_script() int open_script()
{ {
// glfwGetKey doesn't work because of CGame::Initialise is blocking // glfwGetKey doesn't work because of CGame::Initialise is blocking
#ifdef _WIN32 CPad::UpdatePads();
if (GetAsyncKeyState('G') & 0x8000) if (CPad::GetPad(0)->GetChar('G'))
scriptToLoad = 0; scriptToLoad = 0;
if (GetAsyncKeyState('R') & 0x8000) if (CPad::GetPad(0)->GetChar('R'))
scriptToLoad = 1; scriptToLoad = 1;
if (GetAsyncKeyState('D') & 0x8000) if (CPad::GetPad(0)->GetChar('D'))
scriptToLoad = 2; scriptToLoad = 2;
#endif
switch (scriptToLoad) { switch (scriptToLoad) {
case 0: return CFileMgr::OpenFile("main.scm", "rb"); case 0: return CFileMgr::OpenFile("main.scm", "rb");
case 1: return CFileMgr::OpenFile("main_freeroam.scm", "rb"); case 1: return CFileMgr::OpenFile("main_freeroam.scm", "rb");

View file

@ -4290,29 +4290,16 @@ CMenuManager::ProcessButtonPresses(void)
#ifdef USE_DEBUG_SCRIPT_LOADER #ifdef USE_DEBUG_SCRIPT_LOADER
if (m_nCurrScreen == MENUPAGE_START_MENU || m_nCurrScreen == MENUPAGE_NEW_GAME || m_nCurrScreen == MENUPAGE_NEW_GAME_RELOAD) { if (m_nCurrScreen == MENUPAGE_START_MENU || m_nCurrScreen == MENUPAGE_NEW_GAME || m_nCurrScreen == MENUPAGE_NEW_GAME_RELOAD) {
#ifdef RW_GL3 if (CPad::GetPad(0)->GetChar('R')) {
if (glfwGetKey(PSGLOBAL(window), GLFW_KEY_R) == GLFW_PRESS) {
scriptToLoad = 1; scriptToLoad = 1;
DoSettingsBeforeStartingAGame(); DoSettingsBeforeStartingAGame();
return; return;
} }
if (glfwGetKey(PSGLOBAL(window), GLFW_KEY_D) == GLFW_PRESS) { if (CPad::GetPad(0)->GetChar('D')) {
scriptToLoad = 2; scriptToLoad = 2;
DoSettingsBeforeStartingAGame(); DoSettingsBeforeStartingAGame();
return; return;
} }
#elif defined _WIN32
if (GetAsyncKeyState('R') & 0x8000) {
scriptToLoad = 1;
DoSettingsBeforeStartingAGame();
return;
}
if (GetAsyncKeyState('D') & 0x8000) {
scriptToLoad = 2;
DoSettingsBeforeStartingAGame();
return;
}
#endif
} }
#endif #endif