12 if (!manager || !manager->
backend())
return;
16 ImGui::TextColored(ImVec4(1.0f, 0.8f, 0.2f, 1.0f),
23 ImGui::TextWrapped(
"Configure keyboard bindings for SNES controller emulation. "
24 "Click a button and press a key to rebind.");
27 auto RenderKeyBind = [&](
const char* label,
int* key) {
28 ImGui::Text(
"%s:", label);
32 const char* key_name = SDL_GetKeyName(*key);
34 if (ImGui::Button(key_name, ImVec2(120, 0))) {
35 ImGui::OpenPopup(
"Rebind");
38 if (ImGui::BeginPopup(
"Rebind")) {
39 ImGui::Text(
"Press any key...");
44 if (SDL_PollEvent(&event) && event.type == SDL_KEYDOWN) {
45 if (event.key.keysym.sym != SDLK_UNKNOWN && event.key.keysym.sym != SDLK_ESCAPE) {
46 *key =
event.key.keysym.sym;
47 ImGui::CloseCurrentPopup();
51 if (ImGui::Button(
"Cancel", ImVec2(-1, 0))) {
52 ImGui::CloseCurrentPopup();
61 if (ImGui::CollapsingHeader(
"Face Buttons", ImGuiTreeNodeFlags_DefaultOpen)) {
62 RenderKeyBind(
"A Button", &config.key_a);
63 RenderKeyBind(
"B Button", &config.key_b);
64 RenderKeyBind(
"X Button", &config.key_x);
65 RenderKeyBind(
"Y Button", &config.key_y);
69 if (ImGui::CollapsingHeader(
"D-Pad", ImGuiTreeNodeFlags_DefaultOpen)) {
70 RenderKeyBind(
"Up", &config.key_up);
71 RenderKeyBind(
"Down", &config.key_down);
72 RenderKeyBind(
"Left", &config.key_left);
73 RenderKeyBind(
"Right", &config.key_right);
77 if (ImGui::CollapsingHeader(
"Shoulder Buttons")) {
78 RenderKeyBind(
"L Button", &config.key_l);
79 RenderKeyBind(
"R Button", &config.key_r);
83 if (ImGui::CollapsingHeader(
"Start/Select")) {
84 RenderKeyBind(
"Start", &config.key_start);
85 RenderKeyBind(
"Select", &config.key_select);
92 ImGui::Checkbox(
"Continuous Polling", &config.continuous_polling);
93 if (ImGui::IsItemHovered()) {
94 ImGui::SetTooltip(
"Recommended: ON for games (detects held buttons)\nOFF for event-based input");
100 if (ImGui::Button(
"Apply Changes", ImVec2(-1, 30))) {
107 if (ImGui::Button(
"Reset to Defaults", ImVec2(-1, 30))) {
114 ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1.0f),
115 "Default Bindings:");
116 ImGui::BulletText(
"A/B/X/Y: X/Z/S/A");
117 ImGui::BulletText(
"L/R: D/C");
118 ImGui::BulletText(
"D-Pad: Arrow Keys");
119 ImGui::BulletText(
"Start/Select: Enter/RShift");