Exteor/include/xtr/ui/KeyboardHandler.h

51 lines
1.0 KiB
C
Raw Permalink Normal View History

2024-06-07 20:30:06 +03:00
#pragma once
namespace xtr::ui {
//! Keyboard layout handler
class Keyboard {
public:
enum class Layout : uint32_t { ENG, RUS, MATH, };
private:
Layout systemLayout{ Layout::ENG };
Layout currentLayout{ Layout::ENG };
std::set<CWnd*> indicators;
HKL russianHKL;
HKL englishHKL;
public:
~Keyboard() noexcept = default;
Keyboard(const Keyboard&) = delete;
Keyboard& operator=(const Keyboard&) = delete;
private:
Keyboard();
public:
[[nodiscard]] static Keyboard& Instance();
[[nodiscard]] static inline BOOL IsPressed(int keyID) noexcept {
return HIWORD(::GetKeyState(keyID)) != 0;
}
void SetLayout(Layout newLang);
[[nodiscard]] Layout GetLayout() const noexcept;
void ResetSystemLayout();
void ImportSystemLayout();
void RotateLayout();
void RegisterIndicator(CWnd* wnd);
void UnregisterIndicator(CWnd* wnd);
private:
[[nodiscard]] static Layout GetKeybLang();
static void SetSystemLayout(HKL newLayout) noexcept;
void UpdateIndicators();
void SetInternalLayout(Layout newLang);
};
} // namespace xtr::ui