14 if (!manager || !manager->
backend())
19 ImGui::TextColored(ImVec4(1.0f, 0.8f, 0.2f, 1.0f),
27 "Configure keyboard bindings for SNES controller emulation. "
28 "Click a button and press a key to rebind.");
31 auto RenderKeyBind = [&](
const char* label,
int* key) {
32 ImGui::Text(
"%s:", label);
36 const char* key_name = SDL_GetKeyName(*key);
38 if (ImGui::Button(key_name, ImVec2(120, 0))) {
39 ImGui::OpenPopup(
"Rebind");
42 if (ImGui::BeginPopup(
"Rebind")) {
43 ImGui::Text(
"Press any key...");
48 if (SDL_PollEvent(&event) &&
51 if (keycode != SDLK_UNKNOWN && keycode != SDLK_ESCAPE) {
53 ImGui::CloseCurrentPopup();
57 if (ImGui::Button(
"Cancel", ImVec2(-1, 0))) {
58 ImGui::CloseCurrentPopup();
67 if (ImGui::CollapsingHeader(
"Face Buttons", ImGuiTreeNodeFlags_DefaultOpen)) {
68 RenderKeyBind(
"A Button", &config.key_a);
69 RenderKeyBind(
"B Button", &config.key_b);
70 RenderKeyBind(
"X Button", &config.key_x);
71 RenderKeyBind(
"Y Button", &config.key_y);
75 if (ImGui::CollapsingHeader(
"D-Pad", ImGuiTreeNodeFlags_DefaultOpen)) {
76 RenderKeyBind(
"Up", &config.key_up);
77 RenderKeyBind(
"Down", &config.key_down);
78 RenderKeyBind(
"Left", &config.key_left);
79 RenderKeyBind(
"Right", &config.key_right);
83 if (ImGui::CollapsingHeader(
"Shoulder Buttons")) {
84 RenderKeyBind(
"L Button", &config.key_l);
85 RenderKeyBind(
"R Button", &config.key_r);
89 if (ImGui::CollapsingHeader(
"Start/Select")) {
90 RenderKeyBind(
"Start", &config.key_start);
91 RenderKeyBind(
"Select", &config.key_select);
98 ImGui::Checkbox(
"Continuous Polling", &config.continuous_polling);
99 if (ImGui::IsItemHovered()) {
101 "Recommended: ON for games (detects held buttons)\nOFF for event-based "
106 if (ImGui::Checkbox(
"Allow input while typing in UI",
107 &config.ignore_imgui_text_input)) {
110 if (ImGui::IsItemHovered()) {
112 "When enabled, game input is not blocked by ImGui text fields.\n"
113 "Useful if emulator input is blocked while typing in other panels.");
119 if (ImGui::Button(
"Apply Changes", ImVec2(-1, 30))) {
122 if (on_config_changed) {
123 on_config_changed(config);
130 if (ImGui::Button(
"Reset to Defaults", ImVec2(-1, 30))) {
135 if (on_config_changed) {
136 on_config_changed(config);
142 ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1.0f),
"Default Bindings:");
143 ImGui::BulletText(
"A/B/X/Y: X/Z/S/A");
144 ImGui::BulletText(
"L/R: D/C");
145 ImGui::BulletText(
"D-Pad: Arrow Keys");
146 ImGui::BulletText(
"Start/Select: Enter/RShift");