Skip to content

Commit

Permalink
Add keyboard window with keys
Browse files Browse the repository at this point in the history
  • Loading branch information
aceiii committed Apr 7, 2024
1 parent a281dd6 commit 2cf5995
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,48 @@ bool Interface::update() {
ImGui::End();
}

if (show_keyboard) {
if (ImGui::Begin("Keyboard", &show_keyboard)) {
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(24, 18));
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4);

ImGui::Button("1");
ImGui::SameLine();
ImGui::Button("2");
ImGui::SameLine();
ImGui::Button("3");
ImGui::SameLine();
ImGui::Button("C");

ImGui::Button("4");
ImGui::SameLine();
ImGui::Button("5");
ImGui::SameLine();
ImGui::Button("6");
ImGui::SameLine();
ImGui::Button("D");

ImGui::Button("7");
ImGui::SameLine();
ImGui::Button("8");
ImGui::SameLine();
ImGui::Button("9");
ImGui::SameLine();
ImGui::Button("E");

ImGui::Button("A");
ImGui::SameLine();
ImGui::Button("0");
ImGui::SameLine();
ImGui::Button("B");
ImGui::SameLine();
ImGui::Button("F");

ImGui::PopStyleVar(2);
}
ImGui::End();
}

rlImGuiEnd();

if (show_fps) {
Expand Down Expand Up @@ -471,6 +513,7 @@ void Interface::render_main_menu() {
}
if (ImGui::BeginMenu("View")) {
ImGui::MenuItem("Emulation", nullptr, &show_emulation);
ImGui::MenuItem("Keyboard", nullptr, &show_keyboard);
ImGui::MenuItem("Screen", nullptr, &show_screen);
ImGui::MenuItem("Memory", nullptr, &show_memory);
ImGui::MenuItem("Registers", nullptr, &show_registers);
Expand Down Expand Up @@ -537,7 +580,7 @@ void Interface::load_rom(const std::string &filename) {
return;
}

in.seekg(0, in.beg);
in.seekg(0, std::ifstream::beg);
rom = {std::istreambuf_iterator<char>(in), {}};

interpreter->stop();
Expand Down
1 change: 1 addition & 0 deletions src/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ class Interface {
bool show_emulation = true;
bool show_misc = false;
bool show_instructions = true;
bool show_keyboard = true;
};

0 comments on commit 2cf5995

Please sign in to comment.