Files
ReWindow/src/types/key.cpp
Redacted abff453347
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m39s
Refactor to better support more rendering apis
2025-01-26 00:17:48 -05:00

42 lines
1.1 KiB
C++

#include <ReWindow/types/Key.h>
//std::vector<Key> Key::keyboard = {};
std::vector<Key> Key::GetKeyboard() { return keyboard; }
Key::Key(const char* charcode, X11Scancode scancode, WindowsScancode sc)
: Mnemonic(charcode), x11ScanCode(scancode), winScanCode(sc)
{
//TODO doing this is what crashes the program.
keyboard.push_back(*this);
}
bool Key::operator==(const Key &rhs) const {
//This is not a good workaround.
return (this->x11ScanCode == rhs.x11ScanCode);
}
bool Key::operator<(const Key &rhs) const {
return (this->Mnemonic < rhs.Mnemonic);
}
Key GetKeyFromX11Scancode(X11Scancode code) {
for (const auto& key : Key::GetKeyboard())
if (key.x11ScanCode == code)
return key;
std::cout << "Unavaliable Scancode: " + std::to_string((int)code) << std::endl;
return Keys::Space;
}
Key GetKeyFromWindowsScancode(WindowsScancode code) {
for (const auto& key : Key::GetKeyboard())
if (key.winScanCode == code)
return key;
std::cout << "Unavaliable Scancode: " + std::to_string((int) code) << std::endl;
return Keys::Space;
}