Use CPad functions to check key states in script loader

This commit is contained in:
Sergeanur 2021-07-08 03:37:14 +03:00
parent 79c010f082
commit 72f6780905
2 changed files with 6 additions and 19 deletions

View File

@ -2208,21 +2208,16 @@ void CRunningScript::Init()
int scriptToLoad = 0; int scriptToLoad = 0;
const char *scriptfile = "main.scm"; const char *scriptfile = "main.scm";
#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: scriptfile = "main.scm"; break; case 0: scriptfile = "main.scm"; break;
case 1: scriptfile = "freeroam_miami.scm"; break; case 1: scriptfile = "freeroam_miami.scm"; break;

View File

@ -4558,19 +4558,11 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u
#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;
} }
#elif defined _WIN32
if (GetAsyncKeyState('R') & 0x8000) {
scriptToLoad = 1;
DoSettingsBeforeStartingAGame();
return;
}
#endif
} }
#endif #endif