mirror of
https://github.com/encounter/aurora.git
synced 2026-07-09 18:19:33 -07:00
Revert "Enable gamepad support in ImGui"
This reverts commit 7784b6fc95.
This commit is contained in:
+2
-22
@@ -6,8 +6,6 @@
|
||||
#include <array>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "../../imgui.hpp"
|
||||
|
||||
static const int32_t k_mappingsFileVersion = 3;
|
||||
|
||||
static std::array<PADButtonMapping, PAD_BUTTON_COUNT> g_defaultButtons{{
|
||||
@@ -212,28 +210,10 @@ static Sint16 _get_axis_value(aurora::input::GameController* controller, PADAxis
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t clear_status(PADStatus* status) {
|
||||
uint32_t rumbleSupport = 0;
|
||||
for (uint32_t i = 0; i < PAD_CHANMAX; ++i) {
|
||||
memset(&status[i], 0, sizeof(PADStatus));
|
||||
const auto controller = aurora::input::get_controller_for_player(i);
|
||||
if (controller == nullptr) {
|
||||
status[i].err = PAD_ERR_NO_CONTROLLER;
|
||||
continue;
|
||||
}
|
||||
|
||||
status[i].err = PAD_ERR_NONE;
|
||||
if (controller->m_hasRumble) {
|
||||
rumbleSupport |= PAD_CHAN0_BIT >> i;
|
||||
}
|
||||
}
|
||||
return rumbleSupport;
|
||||
}
|
||||
|
||||
bool gBlockPAD = false;
|
||||
uint32_t PADRead(PADStatus* status) {
|
||||
if (gBlockPAD || aurora::imgui::want_capture_controller()) {
|
||||
return clear_status(status);
|
||||
if (gBlockPAD) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t rumbleSupport = 0;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <webgpu/webgpu_cpp.h>
|
||||
#include <SDL3/SDL_render.h>
|
||||
|
||||
#include "input.hpp"
|
||||
#include "internal.hpp"
|
||||
#include "webgpu/gpu.hpp"
|
||||
#include "window.hpp"
|
||||
@@ -26,27 +25,11 @@ static bool g_useSdlRenderer = false;
|
||||
|
||||
static std::vector<SDL_Texture*> g_sdlTextures;
|
||||
static std::vector<wgpu::Texture> g_wgpuTextures;
|
||||
static std::vector<SDL_Gamepad*> g_imguiGamepads;
|
||||
|
||||
static void update_gamepads() noexcept {
|
||||
g_imguiGamepads.clear();
|
||||
g_imguiGamepads.reserve(input::g_GameControllers.size());
|
||||
for (auto& [_, controller] : input::g_GameControllers) {
|
||||
if (controller.m_controller != nullptr) {
|
||||
g_imguiGamepads.push_back(controller.m_controller);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui_ImplSDL3_SetGamepadMode(ImGui_ImplSDL3_GamepadMode_Manual,
|
||||
g_imguiGamepads.empty() ? nullptr : g_imguiGamepads.data(),
|
||||
static_cast<int>(g_imguiGamepads.size()));
|
||||
}
|
||||
|
||||
void create_context() noexcept {
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
|
||||
g_imguiSettings = std::string{g_config.configPath} + "/imgui.ini";
|
||||
g_imguiLog = std::string{g_config.configPath} + "/imgui.log";
|
||||
io.IniFilename = g_imguiSettings.c_str();
|
||||
@@ -82,7 +65,6 @@ void shutdown() noexcept {
|
||||
}
|
||||
g_sdlTextures.clear();
|
||||
g_wgpuTextures.clear();
|
||||
g_imguiGamepads.clear();
|
||||
}
|
||||
|
||||
void process_event(const SDL_Event& event) noexcept {
|
||||
@@ -108,7 +90,6 @@ void new_frame(const AuroraWindowSize& size) noexcept {
|
||||
}
|
||||
ImGui_ImplWGPU_NewFrame();
|
||||
}
|
||||
update_gamepads();
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
@@ -183,16 +164,6 @@ ImTextureID add_texture(uint32_t width, uint32_t height, const uint8_t* data) no
|
||||
g_wgpuTextures.push_back(texture);
|
||||
return reinterpret_cast<ImTextureID>(textureView.MoveToCHandle());
|
||||
}
|
||||
|
||||
bool want_capture_controller() noexcept {
|
||||
if (ImGui::GetCurrentContext() != nullptr) {
|
||||
const ImGuiIO& io = ImGui::GetIO();
|
||||
return ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 &&
|
||||
(io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0 && io.NavActive) ||
|
||||
ImGui::IsKeyDown(ImGuiKey_GamepadBack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace aurora::imgui
|
||||
|
||||
// C bindings
|
||||
|
||||
@@ -18,6 +18,4 @@ void shutdown() noexcept;
|
||||
void process_event(const SDL_Event& event) noexcept;
|
||||
void new_frame(const AuroraWindowSize& size) noexcept;
|
||||
void render(const wgpu::RenderPassEncoder& pass) noexcept;
|
||||
|
||||
bool want_capture_controller() noexcept;
|
||||
} // namespace aurora::imgui
|
||||
|
||||
Reference in New Issue
Block a user