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