35 if (!motherBoard)
return;
39 auto matrix = keyboard.
getKeys();
41 ImGui::SetNextWindowSize({640, 200}, ImGuiCond_FirstUseEver);
50 static constexpr std::array keys = {
150 for (
const auto& key : keys) {
151 maxXY = max(maxXY, key.pos + key.size);
153 gl::vec2 available = ImGui::GetContentRegionAvail();
154 float scale = min_component(available / maxXY);
156 gl::vec2 origin = ImGui::GetCursorPos();
158 const auto& key = keys[i];
159 auto row = key.matrixPos.getRow();
160 auto column = key.matrixPos.getColumn();
161 auto mask = 1 << column;
162 bool active = !(matrix[row] & mask);
164 ImGui::SetCursorPos(origin + scale * key.pos);
165 im::StyleColor(ImGuiCol_Button, getColor(active ? imColor::KEY_ACTIVE : imColor::KEY_NOT_ACTIVE), [&]{
166 ImGui::Button(key.label, scale * key.size);
169 if (ImGui::IsItemActivated()) {
172 if (ImGui::IsItemDeactivated()) {
175 if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
void paint(MSXMotherBoard *motherBoard) override
void loadLine(std::string_view name, zstring_view value) override
void save(ImGuiTextBuffer &buf) override
std::optional< TclObject > execute(TclObject command)
A position (row, column) in a keyboard matrix.
std::span< const uint8_t, KeyMatrixPosition::NUM_ROWS > getKeys() const
Returns a pointer to the current KeyBoard matrix.
MSXDevice * findDevice(std::string_view name)
Find a MSXDevice by name.
const Keyboard & getKeyboard() const
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
void Window(const char *name, bool *p_open, ImGuiWindowFlags flags, std::invocable<> auto next)
void ID_for_range(int count, std::invocable< int > auto next)
This file implemented 3 utility functions:
bool loadOnePersistent(std::string_view name, zstring_view value, C &c, const std::tuple< Elements... > &tup)
void savePersistent(ImGuiTextBuffer &buf, C &c, const std::tuple< Elements... > &tup)
TclObject makeTclList(Args &&... args)