mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-22 04:24:44 +00:00
imgui: rework gamepad navigation
This commit is contained in:
parent
e9218c1395
commit
dd65ee3683
7 changed files with 9 additions and 37 deletions
|
@ -31,10 +31,6 @@ public:
|
|||
void Finish();
|
||||
|
||||
void Draw() override;
|
||||
|
||||
bool ShouldGrabGamepad() override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}; // namespace Libraries::NpTrophy
|
|
@ -39,11 +39,6 @@ Error PS4_SYSV_ABI sceMsgDialogGetResult(DialogResult* result) {
|
|||
if (result == nullptr) {
|
||||
return Error::ARG_NULL;
|
||||
}
|
||||
for (const auto v : result->reserved) {
|
||||
if (v != 0) {
|
||||
return Error::PARAM_INVALID;
|
||||
}
|
||||
}
|
||||
*result = g_result;
|
||||
return Error::OK;
|
||||
}
|
||||
|
|
|
@ -266,11 +266,13 @@ void MsgDialogUi::Draw() {
|
|||
|
||||
CentralizeWindow();
|
||||
SetNextWindowSize(window_size);
|
||||
SetNextWindowFocus();
|
||||
SetNextWindowCollapsed(false);
|
||||
if (first_render || !io.NavActive) {
|
||||
SetNextWindowFocus();
|
||||
}
|
||||
KeepNavHighlight();
|
||||
// Hack to allow every dialog to have a unique window
|
||||
if (Begin("Message Dialog##MessageDialog", nullptr, ImGuiWindowFlags_NoSavedSettings)) {
|
||||
if (Begin("Message Dialog##MessageDialog", nullptr,
|
||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings)) {
|
||||
switch (state->GetMode()) {
|
||||
case MsgDialogMode::USER_MSG:
|
||||
DrawUser();
|
||||
|
|
|
@ -174,10 +174,6 @@ public:
|
|||
void SetProgressBarValue(u32 value, bool increment);
|
||||
|
||||
void Draw() override;
|
||||
|
||||
bool ShouldGrabGamepad() override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// Utility function to show a message dialog
|
||||
|
|
|
@ -12,10 +12,6 @@ public:
|
|||
static void RemoveLayer(Layer* layer);
|
||||
|
||||
virtual void Draw() = 0;
|
||||
|
||||
virtual bool ShouldGrabGamepad() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ImGui
|
|
@ -10,7 +10,7 @@ void ImGui::Layers::VideoInfo::Draw() {
|
|||
m_show = IsKeyPressed(ImGuiKey_F10, false) ^ m_show;
|
||||
|
||||
if (m_show) {
|
||||
if (Begin("Video Info")) {
|
||||
if (Begin("Video Info", 0, ImGuiWindowFlags_NoNav)) {
|
||||
Text("Frame time: %.3f ms (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||
}
|
||||
End();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "imgui_core.h"
|
||||
#include "imgui_impl_sdl3.h"
|
||||
#include "imgui_impl_vulkan.h"
|
||||
#include "imgui_internal.h"
|
||||
#include "sdl_window.h"
|
||||
#include "texture_manager.h"
|
||||
#include "video_core/renderer_vulkan/renderer_vulkan.h"
|
||||
|
@ -97,24 +98,19 @@ void Shutdown(const vk::Device& device) {
|
|||
bool ProcessEvent(SDL_Event* event) {
|
||||
Sdl::ProcessEvent(event);
|
||||
switch (event->type) {
|
||||
// Don't block release/up events
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
case SDL_EVENT_MOUSE_WHEEL:
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
return GetIO().WantCaptureMouse;
|
||||
case SDL_EVENT_TEXT_INPUT:
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
return GetIO().WantCaptureKeyboard;
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||
case SDL_EVENT_GAMEPAD_ADDED:
|
||||
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_UP:
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
|
||||
return (GetIO().BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
|
||||
return GetIO().NavActive;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -138,17 +134,8 @@ void NewFrame() {
|
|||
Sdl::NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
bool capture_gamepad = false;
|
||||
for (auto* layer : layers) {
|
||||
layer->Draw();
|
||||
if (layer->ShouldGrabGamepad()) {
|
||||
capture_gamepad = true;
|
||||
}
|
||||
}
|
||||
if (capture_gamepad) {
|
||||
GetIO().BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||
} else {
|
||||
GetIO().BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue