forked from shadps4-emu/shadPS4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dear ImGui Implementation (shadps4-emu#598)
* added imgui as dependency * imgui renderer/basic input implementation * imgui: add layers system Add video info layer to show fps. Press F10 to toggle it. * imgui: add custom imgui config * imgui: gamepad capture, stopping propagation * imgui: changed config & log file path to use portable dir * videoout: render blank frame when video output is closed required to render imgui even when game has no video output - fixed merge compile-error
- Loading branch information
1 parent
f1becb2
commit 035cb3e
Showing
23 changed files
with
2,386 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule dear_imgui
added at
636cd4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#pragma once | ||
|
||
// WARNING: All includes from this file must be relative to allow Dear_ImGui project to compile | ||
// without having this project include paths. | ||
|
||
#include <cstdint> | ||
|
||
extern void assert_fail_debug_msg(const char* msg); | ||
|
||
#define ImDrawIdx std::uint32_t | ||
|
||
#define IM_STRINGIZE(x) IM_STRINGIZE2(x) | ||
#define IM_STRINGIZE2(x) #x | ||
#define IM_ASSERT(_EXPR) \ | ||
([&]() { \ | ||
if (!(_EXPR)) [[unlikely]] { \ | ||
assert_fail_debug_msg(#_EXPR " at " __FILE__ ":" IM_STRINGIZE(__LINE__)); \ | ||
} \ | ||
}()) | ||
|
||
#define IMGUI_USE_WCHAR32 | ||
#define IMGUI_ENABLE_STB_TRUETYPE | ||
#define IMGUI_DEFINE_MATH_OPERATORS | ||
|
||
#define IM_VEC2_CLASS_EXTRA \ | ||
constexpr ImVec2(float _v) : x(_v), y(_v) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#pragma once | ||
|
||
namespace ImGui { | ||
|
||
class Layer { | ||
public: | ||
virtual ~Layer() = default; | ||
static void AddLayer(Layer* layer); | ||
static void RemoveLayer(Layer* layer); | ||
|
||
virtual void Draw() = 0; | ||
|
||
virtual bool ShouldGrabGamepad() { | ||
return false; | ||
} | ||
}; | ||
|
||
} // namespace ImGui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#include <imgui.h> | ||
#include "video_info.h" | ||
|
||
void ImGui::Layers::VideoInfo::Draw() { | ||
const ImGuiIO& io = GetIO(); | ||
|
||
m_show = IsKeyPressed(ImGuiKey_F10, false) ^ m_show; | ||
|
||
if (m_show && Begin("Video Info")) { | ||
Text("Frame time: %.3f ms (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); | ||
End(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#pragma once | ||
|
||
#include "imgui/imgui_layer.h" | ||
|
||
namespace Vulkan { | ||
class RendererVulkan; | ||
} | ||
namespace ImGui::Layers { | ||
|
||
class VideoInfo : public Layer { | ||
bool m_show = false; | ||
::Vulkan::RendererVulkan* renderer{}; | ||
|
||
public: | ||
explicit VideoInfo(::Vulkan::RendererVulkan* renderer) : renderer(renderer) {} | ||
|
||
void Draw() override; | ||
}; | ||
|
||
} // namespace ImGui::Layers |
Oops, something went wrong.