Frontend: Clear focus after loading/saving state

This commit is contained in:
Connor McLaughlin 2019-10-27 13:44:48 +10:00
parent 4181b8c6b5
commit 83b67b3c4c
3 changed files with 16 additions and 3 deletions

View file

@ -180,8 +180,8 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
{
static constexpr unsigned int mapping[][2] = {{SDL_CONTROLLER_BUTTON_A, ImGuiNavInput_Activate},
{SDL_CONTROLLER_BUTTON_B, ImGuiNavInput_Cancel},
{SDL_CONTROLLER_BUTTON_X, ImGuiNavInput_Input},
{SDL_CONTROLLER_BUTTON_Y, ImGuiNavInput_Menu},
{SDL_CONTROLLER_BUTTON_Y, ImGuiNavInput_Input},
// {SDL_CONTROLLER_BUTTON_X, ImGuiNavInput_Menu},
{SDL_CONTROLLER_BUTTON_LEFTSHOULDER, ImGuiNavInput_FocusPrev},
{SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, ImGuiNavInput_FocusNext},
{SDL_CONTROLLER_BUTTON_DPAD_UP, ImGuiNavInput_DpadUp},

View file

@ -405,7 +405,7 @@ static void HandleSDLControllerAxisEventForController(const SDL_Event* ev, Digit
{
// Log_DevPrintf("axis %d %d", ev->caxis.axis, ev->caxis.value);
static constexpr int deadzone = 5000;
static constexpr int deadzone = 8192;
const bool negative = (ev->caxis.value < 0);
const bool active = (std::abs(ev->caxis.value) >= deadzone);
@ -583,6 +583,11 @@ void SDLInterface::HandleSDLKeyEvent(const SDL_Event* event)
}
}
void SDLInterface::ClearImGuiFocus()
{
ImGui::SetWindowFocus(nullptr);
}
void SDLInterface::Render()
{
DrawImGui();
@ -1091,6 +1096,8 @@ void SDLInterface::DoStartDisc()
AddOSDMessage(SmallString::FromFormat("Starting disc from '%s'...", path));
if (!InitializeSystem(path, nullptr))
return;
ClearImGuiFocus();
}
void SDLInterface::DoStartBIOS()
@ -1100,6 +1107,8 @@ void SDLInterface::DoStartBIOS()
AddOSDMessage("Starting BIOS...");
if (!InitializeSystem(nullptr, nullptr))
return;
ClearImGuiFocus();
}
void SDLInterface::DoLoadState(u32 index)
@ -1112,12 +1121,14 @@ void SDLInterface::DoLoadState(u32 index)
m_last_internal_frame_number = m_system->GetInternalFrameNumber();
m_last_global_tick_counter = m_system->GetGlobalTickCounter();
m_fps_timer.Reset();
ClearImGuiFocus();
}
void SDLInterface::DoSaveState(u32 index)
{
Assert(m_system);
SaveState(GetSaveStateFilename(index));
ClearImGuiFocus();
}
void SDLInterface::Run()

View file

@ -75,6 +75,8 @@ private:
void HandleSDLEvent(const SDL_Event* event);
void HandleSDLKeyEvent(const SDL_Event* event);
void ClearImGuiFocus();
void Render();
void RenderDisplay();
void DrawMainMenuBar();