made CharCode char* for printing the funny unicode arrows for arrow keys
This commit is contained in:
@@ -24,8 +24,8 @@ private:
|
||||
public:
|
||||
static std::vector<Key> GetKeyboard();
|
||||
Key();
|
||||
Key(char charcode, X11Scancode scancode, WindowsScancode wSc);
|
||||
char CharCode;
|
||||
Key(char* charcode, X11Scancode scancode, WindowsScancode wSc);
|
||||
char* CharCode;
|
||||
X11Scancode x11ScanCode;
|
||||
WindowsScancode winScanCode;
|
||||
bool operator==(const Key& rhs) const;
|
||||
@@ -36,101 +36,101 @@ public:
|
||||
|
||||
namespace Keys {
|
||||
// TODO: Encode both Uppercase and Lowercase version for each keymap
|
||||
static const Key Escape {'\b', X11Scancode::ESCAPE, WindowsScancode::ESCAPE};
|
||||
static const Key F1 {'\u000f', X11Scancode::F1, WindowsScancode::F1};
|
||||
static const Key F2 {'\u000f', X11Scancode::F2, WindowsScancode::F2};
|
||||
static const Key F3 {'\u000f', X11Scancode::F3, WindowsScancode::F3};
|
||||
static const Key F4 {'\u000f', X11Scancode::F4, WindowsScancode::F4};
|
||||
static const Key F5 {'\u000f', X11Scancode::F5, WindowsScancode::F5};
|
||||
static const Key F6 {'\u000f', X11Scancode::F6, WindowsScancode::F6};
|
||||
static const Key F7 {'\u000f', X11Scancode::F7, WindowsScancode::F7};
|
||||
static const Key F8 {'\u000f', X11Scancode::F8, WindowsScancode::F8};
|
||||
static const Key F9 {'\u000f', X11Scancode::F9, WindowsScancode::F9};
|
||||
static const Key F10 {'\u000f', X11Scancode::F10, WindowsScancode::F10};
|
||||
static const Key F11 {'\u000f', X11Scancode::F11, WindowsScancode::F11};
|
||||
static const Key F12 {'\u000f', X11Scancode::F12, WindowsScancode::F12};
|
||||
static const Key Escape {"\b", X11Scancode::ESCAPE, WindowsScancode::ESCAPE};
|
||||
static const Key F1 {"\u000f", X11Scancode::F1, WindowsScancode::F1};
|
||||
static const Key F2 {"\u000f", X11Scancode::F2, WindowsScancode::F2};
|
||||
static const Key F3 {"\u000f", X11Scancode::F3, WindowsScancode::F3};
|
||||
static const Key F4 {"\u000f", X11Scancode::F4, WindowsScancode::F4};
|
||||
static const Key F5 {"\u000f", X11Scancode::F5, WindowsScancode::F5};
|
||||
static const Key F6 {"\u000f", X11Scancode::F6, WindowsScancode::F6};
|
||||
static const Key F7 {"\u000f", X11Scancode::F7, WindowsScancode::F7};
|
||||
static const Key F8 {"\u000f", X11Scancode::F8, WindowsScancode::F8};
|
||||
static const Key F9 {"\u000f", X11Scancode::F9, WindowsScancode::F9};
|
||||
static const Key F10 {"\u000f", X11Scancode::F10, WindowsScancode::F10};
|
||||
static const Key F11 {"\u000f", X11Scancode::F11, WindowsScancode::F11};
|
||||
static const Key F12 {"\u000f", X11Scancode::F12, WindowsScancode::F12};
|
||||
|
||||
static const Key NumPad1 {'\b', X11Scancode::KP_1, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad2 {'\b', X11Scancode::KP_2, WindowsScancode::NUMPAD_TWO};
|
||||
static const Key NumPad3 {'\b', X11Scancode::KP_3, WindowsScancode::NUMPAD_THREE};
|
||||
static const Key NumPad4 {'\b', X11Scancode::KP_4, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad5 {'\b', X11Scancode::KP_5, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad6 {'\b', X11Scancode::KP_6, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad7 {'\b', X11Scancode::KP_7, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad8 {'\b', X11Scancode::KP_8, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad9 {'\b', X11Scancode::KP_9, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad0 {'\b', X11Scancode::KP_0, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad1 {"\b", X11Scancode::KP_1, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad2 {"\b", X11Scancode::KP_2, WindowsScancode::NUMPAD_TWO};
|
||||
static const Key NumPad3 {"\b", X11Scancode::KP_3, WindowsScancode::NUMPAD_THREE};
|
||||
static const Key NumPad4 {"\b", X11Scancode::KP_4, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad5 {"\b", X11Scancode::KP_5, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad6 {"\b", X11Scancode::KP_6, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad7 {"\b", X11Scancode::KP_7, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad8 {"\b", X11Scancode::KP_8, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad9 {"\b", X11Scancode::KP_9, WindowsScancode::NUMPAD_ONE};
|
||||
static const Key NumPad0 {"\b", X11Scancode::KP_0, WindowsScancode::NUMPAD_ONE};
|
||||
|
||||
static const Key One {'1', X11Scancode::ONE, WindowsScancode::ONE};
|
||||
static const Key Two {'2', X11Scancode::TWO, WindowsScancode::TWO};
|
||||
static const Key Three {'3', X11Scancode::THREE, WindowsScancode::THREE};
|
||||
static const Key Four {'4', X11Scancode::FOUR, WindowsScancode::FOUR};
|
||||
static const Key Five {'5', X11Scancode::FIVE, WindowsScancode::FIVE};
|
||||
static const Key Six {'6', X11Scancode::SIX, WindowsScancode::SIX};
|
||||
static const Key Seven {'7', X11Scancode::SEVEN, WindowsScancode::SEVEN};
|
||||
static const Key Eight {'8', X11Scancode::EIGHT, WindowsScancode::EIGHT};
|
||||
static const Key Nine {'9', X11Scancode::NINE, WindowsScancode::NINE};
|
||||
static const Key Zero {'0', X11Scancode::ZERO, WindowsScancode::ZERO};
|
||||
static const Key One {"1", X11Scancode::ONE, WindowsScancode::ONE};
|
||||
static const Key Two {"2", X11Scancode::TWO, WindowsScancode::TWO};
|
||||
static const Key Three {"3", X11Scancode::THREE, WindowsScancode::THREE};
|
||||
static const Key Four {"4", X11Scancode::FOUR, WindowsScancode::FOUR};
|
||||
static const Key Five {"5", X11Scancode::FIVE, WindowsScancode::FIVE};
|
||||
static const Key Six {"6", X11Scancode::SIX, WindowsScancode::SIX};
|
||||
static const Key Seven {"7", X11Scancode::SEVEN, WindowsScancode::SEVEN};
|
||||
static const Key Eight {"8", X11Scancode::EIGHT, WindowsScancode::EIGHT};
|
||||
static const Key Nine {"9", X11Scancode::NINE, WindowsScancode::NINE};
|
||||
static const Key Zero {"0", X11Scancode::ZERO, WindowsScancode::ZERO};
|
||||
|
||||
static const Key Q {'Q', X11Scancode::Q, WindowsScancode::Q};
|
||||
static const Key W {'W', X11Scancode::W, WindowsScancode::W};
|
||||
static const Key E {'E', X11Scancode::E, WindowsScancode::E};
|
||||
static const Key R {'R', X11Scancode::R, WindowsScancode::R};
|
||||
static const Key T {'T', X11Scancode::T, WindowsScancode::T};
|
||||
static const Key Y {'Y', X11Scancode::Y, WindowsScancode::Y};
|
||||
static const Key U {'U', X11Scancode::U, WindowsScancode::U};
|
||||
static const Key I {'I', X11Scancode::I, WindowsScancode::I};
|
||||
static const Key O {'O', X11Scancode::O, WindowsScancode::O};
|
||||
static const Key P {'P', X11Scancode::P, WindowsScancode::P};
|
||||
static const Key A {'A', X11Scancode::A, WindowsScancode::A};
|
||||
static const Key S {'S', X11Scancode::S, WindowsScancode::S};
|
||||
static const Key D {'D', X11Scancode::D, WindowsScancode::D};
|
||||
static const Key F {'F', X11Scancode::F, WindowsScancode::F};
|
||||
static const Key G {'G', X11Scancode::G, WindowsScancode::G};
|
||||
static const Key H {'H', X11Scancode::H, WindowsScancode::H};
|
||||
static const Key J {'J', X11Scancode::J, WindowsScancode::J};
|
||||
static const Key K {'K', X11Scancode::K, WindowsScancode::K};
|
||||
static const Key L {'L', X11Scancode::L, WindowsScancode::L};
|
||||
static const Key Semicolon {';', X11Scancode::SEMICOLON, WindowsScancode::SEMICOLON};
|
||||
static const Key SingeQuote {'\'', X11Scancode::SINGLEQUOTE, WindowsScancode::SEMICOLON};
|
||||
static const Key Enter {'\n', X11Scancode::RETURN, WindowsScancode::ENTER};
|
||||
//static const Key KeyPadEnter {'\n', X11Scancode::KP_RETURN};
|
||||
static const Key Minus {'-', X11Scancode::MINUS, WindowsScancode::MINUS};
|
||||
//static const Key KeyPadMinus {'-', X11Scancode::KP_MINUS};
|
||||
static const Key Equals {'=', X11Scancode::EQUALS, WindowsScancode::EQUALS};
|
||||
static const Key Z {'Z', X11Scancode::Z, WindowsScancode::Z};
|
||||
static const Key X {'X', X11Scancode::X, WindowsScancode::X};
|
||||
static const Key C {'C', X11Scancode::C, WindowsScancode::C};
|
||||
static const Key V {'V', X11Scancode::V, WindowsScancode::V};
|
||||
static const Key B {'B', X11Scancode::B, WindowsScancode::B};
|
||||
static const Key N {'N', X11Scancode::N, WindowsScancode::N};
|
||||
static const Key M {'M', X11Scancode::M, WindowsScancode::M};
|
||||
static const Key Period {'.', X11Scancode::PERIOD, WindowsScancode::PERIOD};
|
||||
static const Key ForwardSlash {'/', X11Scancode::SLASH, WindowsScancode::SLASH};
|
||||
static const Key BackSlash {'\\', X11Scancode::BACKSLASH, WindowsScancode::BACKSLASH};
|
||||
static const Key Q {"Q", X11Scancode::Q, WindowsScancode::Q};
|
||||
static const Key W {"W", X11Scancode::W, WindowsScancode::W};
|
||||
static const Key E {"E", X11Scancode::E, WindowsScancode::E};
|
||||
static const Key R {"R", X11Scancode::R, WindowsScancode::R};
|
||||
static const Key T {"T", X11Scancode::T, WindowsScancode::T};
|
||||
static const Key Y {"Y", X11Scancode::Y, WindowsScancode::Y};
|
||||
static const Key U {"U", X11Scancode::U, WindowsScancode::U};
|
||||
static const Key I {"I", X11Scancode::I, WindowsScancode::I};
|
||||
static const Key O {"O", X11Scancode::O, WindowsScancode::O};
|
||||
static const Key P {"P", X11Scancode::P, WindowsScancode::P};
|
||||
static const Key A {"A", X11Scancode::A, WindowsScancode::A};
|
||||
static const Key S {"S", X11Scancode::S, WindowsScancode::S};
|
||||
static const Key D {"D", X11Scancode::D, WindowsScancode::D};
|
||||
static const Key F {"F", X11Scancode::F, WindowsScancode::F};
|
||||
static const Key G {"G", X11Scancode::G, WindowsScancode::G};
|
||||
static const Key H {"H", X11Scancode::H, WindowsScancode::H};
|
||||
static const Key J {"J", X11Scancode::J, WindowsScancode::J};
|
||||
static const Key K {"K", X11Scancode::K, WindowsScancode::K};
|
||||
static const Key L {"L", X11Scancode::L, WindowsScancode::L};
|
||||
static const Key Semicolon {";", X11Scancode::SEMICOLON, WindowsScancode::SEMICOLON};
|
||||
static const Key SingeQuote {"\"", X11Scancode::SINGLEQUOTE, WindowsScancode::SEMICOLON};
|
||||
static const Key Enter {"\n", X11Scancode::RETURN, WindowsScancode::ENTER};
|
||||
//static const Key KeyPadEnter {"\n", X11Scancode::KP_RETURN};
|
||||
static const Key Minus {"-", X11Scancode::MINUS, WindowsScancode::MINUS};
|
||||
//static const Key KeyPadMinus {"-", X11Scancode::KP_MINUS};
|
||||
static const Key Equals {"=", X11Scancode::EQUALS, WindowsScancode::EQUALS};
|
||||
static const Key Z {"Z", X11Scancode::Z, WindowsScancode::Z};
|
||||
static const Key X {"X", X11Scancode::X, WindowsScancode::X};
|
||||
static const Key C {"C", X11Scancode::C, WindowsScancode::C};
|
||||
static const Key V {"V", X11Scancode::V, WindowsScancode::V};
|
||||
static const Key B {"B", X11Scancode::B, WindowsScancode::B};
|
||||
static const Key N {"N", X11Scancode::N, WindowsScancode::N};
|
||||
static const Key M {"M", X11Scancode::M, WindowsScancode::M};
|
||||
static const Key Period {".", X11Scancode::PERIOD, WindowsScancode::PERIOD};
|
||||
static const Key ForwardSlash {"/", X11Scancode::SLASH, WindowsScancode::SLASH};
|
||||
static const Key BackSlash {"\\", X11Scancode::BACKSLASH, WindowsScancode::BACKSLASH};
|
||||
|
||||
static const Key Space {' ', X11Scancode::SPACE, WindowsScancode::SPACE};
|
||||
static const Key Space {" ", X11Scancode::SPACE, WindowsScancode::SPACE};
|
||||
|
||||
static const Key LControl {'\\', X11Scancode::LEFT_CTRL, WindowsScancode::CTRL};
|
||||
static const Key RControl {'\\', X11Scancode::RIGHT_CONTROL, WindowsScancode::CTRL};
|
||||
static const Key LControl {"\\", X11Scancode::LEFT_CTRL, WindowsScancode::CTRL};
|
||||
static const Key RControl {"\\", X11Scancode::RIGHT_CONTROL, WindowsScancode::CTRL};
|
||||
|
||||
static const Key LAlt {'\\', X11Scancode::LEFT_ALT, WindowsScancode::ALT};
|
||||
static const Key RAlt {'\\', X11Scancode::RIGHT_ALT, WindowsScancode::ALT};
|
||||
static const Key LAlt {"\\", X11Scancode::LEFT_ALT, WindowsScancode::ALT};
|
||||
static const Key RAlt {"\\", X11Scancode::RIGHT_ALT, WindowsScancode::ALT};
|
||||
|
||||
static const Key LShift {'\\', X11Scancode::LEFT_SHIFT, WindowsScancode::LEFT_SHIFT};
|
||||
static const Key RShift {'\\', X11Scancode::RIGHT_SHIFT, WindowsScancode::RIGHT_SHIFT};
|
||||
static const Key LShift {"\\", X11Scancode::LEFT_SHIFT, WindowsScancode::LEFT_SHIFT};
|
||||
static const Key RShift {"\\", X11Scancode::RIGHT_SHIFT, WindowsScancode::RIGHT_SHIFT};
|
||||
|
||||
// TODO: Get the right character codes for these
|
||||
static const Key UpArrow {'\u000a', X11Scancode::UP, WindowsScancode::UP_ARROW};
|
||||
static const Key DownArrow {'\u000a', X11Scancode::DOWN, WindowsScancode::DOWN_ARROW};
|
||||
static const Key LeftArrow {'\u000a', X11Scancode::LEFT, WindowsScancode::LEFT_ARROW};
|
||||
static const Key RightArrow {'\u000a', X11Scancode::RIGHT, WindowsScancode::RIGHT_ARROW};
|
||||
static const Key UpArrow { "\u2191", X11Scancode::UP, WindowsScancode::UP_ARROW};
|
||||
static const Key DownArrow {"\u2193", X11Scancode::DOWN, WindowsScancode::DOWN_ARROW};
|
||||
static const Key LeftArrow {"\u2190", X11Scancode::LEFT, WindowsScancode::LEFT_ARROW};
|
||||
static const Key RightArrow {"\u2192", X11Scancode::RIGHT, WindowsScancode::RIGHT_ARROW};
|
||||
|
||||
static const Key Super {'\000a', X11Scancode::SUPER, WindowsScancode::Nothing};
|
||||
static const Key Backspace {'\b', X11Scancode::BACKSPACE, WindowsScancode::BACKSPACE};
|
||||
static const Key Super {"\000a", X11Scancode::SUPER, WindowsScancode::Nothing};
|
||||
static const Key Backspace {"\b", X11Scancode::BACKSPACE, WindowsScancode::BACKSPACE};
|
||||
|
||||
static const Key LeftBracket {'[', X11Scancode::OPENING_SQUARE_BRACKET, WindowsScancode::LEFT_BRACKET};
|
||||
static const Key RightBracket {']', X11Scancode::CLOSING_SQUARE_BRACKET, WindowsScancode::RIGHT_BRACKET};
|
||||
static const Key LeftBracket {"[", X11Scancode::OPENING_SQUARE_BRACKET, WindowsScancode::LEFT_BRACKET};
|
||||
static const Key RightBracket {"]", X11Scancode::CLOSING_SQUARE_BRACKET, WindowsScancode::RIGHT_BRACKET};
|
||||
}
|
||||
|
||||
class GamepadButton {};
|
||||
|
1
main.cpp
1
main.cpp
@@ -60,6 +60,7 @@ int main() {
|
||||
|
||||
window->OnKeyDownEvent += [&] (ReWindow::KeyDownEvent e)
|
||||
{
|
||||
std::cout << e.key.CharCode << std::endl;
|
||||
if (e.key == Keys::LeftArrow)
|
||||
{
|
||||
std::cout << "Left Arrow Hit" << std::endl;
|
||||
|
@@ -132,12 +132,16 @@ namespace ReWindow {
|
||||
if (xev.type == KeyRelease) {
|
||||
auto scancode = (X11Scancode) xev.xkey.keycode;
|
||||
auto key = GetKeyFromX11Scancode(scancode);
|
||||
OnKeyUpEvent(key);
|
||||
OnKeyUpEvent(key);
|
||||
liftKey (key);
|
||||
}
|
||||
|
||||
if (xev.type == KeyPress) {
|
||||
auto scancode = (X11Scancode) xev.xkey.keycode;
|
||||
auto key = GetKeyFromX11Scancode(scancode);
|
||||
OnKeyDownEvent(key);
|
||||
OnKeyDown(key);
|
||||
pressKey (key);
|
||||
//eventLog.push_back(eventData);
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ Key::Key() {
|
||||
keyboard.push_back(*this);
|
||||
}
|
||||
|
||||
Key::Key(char charcode, X11Scancode scancode, WindowsScancode sc)
|
||||
Key::Key(char* charcode, X11Scancode scancode, WindowsScancode sc)
|
||||
: CharCode(charcode), x11ScanCode(scancode), winScanCode(sc)
|
||||
{
|
||||
keyboard.push_back(*this);
|
||||
|
Reference in New Issue
Block a user