Implementing WindowsScancodes

This commit is contained in:
2024-01-05 12:47:25 -05:00
parent eed5f10413
commit 10a8105f71
3 changed files with 174 additions and 78 deletions

View File

@@ -88,19 +88,114 @@ enum class X11Scancode {
SUPER = 133,
LEFT_CTRL = 37,
ESCAPE = 9,
FUNCTION_ONE = 67,
FUNCTION_TWO = 68,
FUNCTION_THREE = 69,
FUNCTION_FOUR = 70,
FUNCTION_FIVE = 71,
FUNCTION_SIX = 72,
FUNCTION_SEVEN = 73,
FUNCTION_EIGHT = 74,
FUNCTION_NINE = 75,
FUNCTION_TEN = 76,
FUNCTION_ELEVEN = 77,
FUNCTION_TWELVE = 78,
F1 = 67,
F2 = 68,
F3 = 69,
F4 = 70,
F5 = 71,
F6 = 72,
F7 = 73,
F8 = 74,
F9 = 75,
F10 = 76,
F11 = 77,
F12 = 78,
PRINT = 107,
SCROLL_LOCK = 78,
BREAK = 127,
};
enum class WindowsScancode {
Nothing = 0,
ESCAPE = 0x01,
ONE = 0x02,
TWO = 0x03,
THREE = 0x04,
FOUR = 0x05,
FIVE = 0x06,
SIX = 0x07,
SEVEN = 0x08,
EIGHT = 0x09,
NINE = 0x0A,
ZERO = 0x0B,
MINUS = 0x0C,
EQUALS = 0x0D,
BACKSPACE = 0x0E,
TAB = 0x0F,
Q = 0x10,
W = 0x11,
E = 0x12,
R = 0x13,
T = 0x14,
Y = 0x15,
U = 0x16,
I = 0x17,
O = 0x18,
P = 0x19,
LEFT_BRACKET = 0x1A,
RIGHT_BRACKET = 0x1B,
ENTER = 0x1C,
CTRL = 0x1D,
A = 0x1E,
S = 0x1F,
D = 0x20,
F = 0x21,
G = 0x22,
H = 0x23,
J = 0x24,
K = 0x25,
L = 0x26,
SEMICOLON = 0x27,
SINGLEQUOTE = 0x28,
GRAVE = 0x29,
LEFT_SHIFT = 0x2A,
BACKSLASH = 0x2B,
Z = 0x2C,
X = 0x2D,
C = 0x2E,
V = 0x2F,
B = 0x30,
N = 0x30,
M = 0x32,
COMMA = 0x33,
PERIOD = 0x34,
SLASH = 0x35,
RIGHT_SHIFT = 0x36,
PRINTSCREEN = 0x37,
ALT = 0x38,
SPACE = 0x39,
CAPS_LOCK = 0x3A,
F1 = 0x3B,
F2 = 0x3C,
F3 = 0x3D,
F4 = 0x3E,
F5 = 0x3F,
F6 = 0x40,
F7 = 0x41,
F8 = 0x42,
F9 = 0x43,
F10 = 0x44,
NUM_LOCK = 0x45,
SCROLL_LOCK = 0x46,
HOME = 0x47,
UP_ARROW = 0x48,
LEFT_ARROW,
DOWN_ARROW,
RIGHT_ARROW,
PAGE_UP = 0x49,
NUMPAD_MINUS = 0x4A,
NUMPAD_4 = 0x4B,
NUMPAD_5 = 0x4C,
NUMPAD_6 = 0x4D,
NUMPAD_PLUS = 0x4E,
NUMPAD_ONE = 0x4F,
NUMPAD_TWO = 0x50,
NUMPAD_THREE = 0x51,
NUMPAD_ZERO = 0x52,
DELETE = 0x53,
F11 = 0x85,
F12 = 0x86, // FIX
};

View File

@@ -15,83 +15,84 @@ private:
public:
inline static std::vector<Key> GetKeyboard();
Key();
Key(char charcode, X11Scancode scancode);
Key(char charcode, X11Scancode scancode, WindowsScancode wSc);
char CharCode;
X11Scancode x11ScanCode;
WindowsScancode winScanCode;
};
namespace Keys {
static const Key Escape {'\b', X11Scancode::ESCAPE};
static const Key F1 {'\u000f', X11Scancode::FUNCTION_ONE};
static const Key F2 {'\u000f', X11Scancode::FUNCTION_TWO};
static const Key F3 {'\u000f', X11Scancode::FUNCTION_THREE};
static const Key F4 {'\u000f', X11Scancode::FUNCTION_FOUR};
static const Key F5 {'\u000f', X11Scancode::FUNCTION_FIVE};
static const Key F6 {'\u000f', X11Scancode::FUNCTION_SIX};
static const Key F7 {'\u000f', X11Scancode::FUNCTION_SEVEN};
static const Key F8 {'\u000f', X11Scancode::FUNCTION_EIGHT};
static const Key F9 {'\u000f', X11Scancode::FUNCTION_NINE};
static const Key F10 {'\u000f', X11Scancode::FUNCTION_TEN};
static const Key F11 {'\u000f', X11Scancode::FUNCTION_ELEVEN};
static const Key F12 {'\u000f', X11Scancode::FUNCTION_TWELVE};
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;
static const Key NumPad2;
static const Key NumPad3;
static const Key NumPad4;
static const Key NumPad5;
static const Key NumPad6;
static const Key NumPad7;
static const Key NumPad8;
static const Key NumPad9;
static const Key NumPad0;
static const Key NumPad1 {'\b', X11Scancode::ONE, WindowsScancode::NUMPAD_ONE};
static const Key NumPad2 {'\b', X11Scancode::ONE, WindowsScancode::NUMPAD_ONE};
static const Key NumPad3 {'\b', X11Scancode::ONE, WindowsScancode::NUMPAD_ONE};
static const Key NumPad4 {'\b', X11Scancode::ONE, WindowsScancode::NUMPAD_ONE};
static const Key NumPad5 {'\b', X11Scancode::ONE, WindowsScancode::NUMPAD_ONE};
static const Key NumPad6 {'\b', X11Scancode::ONE, WindowsScancode::NUMPAD_ONE};
static const Key NumPad7 {'\b', X11Scancode::ONE, WindowsScancode::NUMPAD_ONE};
static const Key NumPad8 {'\b', X11Scancode::ONE, WindowsScancode::NUMPAD_ONE};
static const Key NumPad9 {'\b', X11Scancode::ONE, WindowsScancode::NUMPAD_ONE};
static const Key NumPad0 {'\b', X11Scancode::ONE, WindowsScancode::NUMPAD_ONE};
static const Key Q {'Q', X11Scancode::Q};
static const Key W {'W', X11Scancode::W};
static const Key E {'E', X11Scancode::E};
static const Key R {'R', X11Scancode::R};
static const Key T {'T', X11Scancode::T};
static const Key Y {'Y', X11Scancode::Y};
static const Key U {'U', X11Scancode::U};
static const Key I {'I', X11Scancode::I};
static const Key O {'O', X11Scancode::O};
static const Key P {'P', X11Scancode::P};
static const Key A {'A', X11Scancode::A};
static const Key S {'S', X11Scancode::S};
static const Key D {'D', X11Scancode::D};
static const Key F {'F', X11Scancode::F};
static const Key G {'G', X11Scancode::G};
static const Key H {'H', X11Scancode::H};
static const Key J {'J', X11Scancode::J};
static const Key K {'K', X11Scancode::K};
static const Key L {'L', X11Scancode::L};
static const Key Semicolon {';', X11Scancode::SEMICOLON};
static const Key SingeQuote {'\'', X11Scancode::SINGLEQUOTE};
static const Key Enter {'\n', X11Scancode::RETURN};
static const Key KeyPadEnter {'\n', X11Scancode::KP_RETURN};
static const Key Minus {'-', X11Scancode::MINUS};
static const Key KeyPadMinus {'-', X11Scancode::KP_MINUS};
static const Key Equals {'=', X11Scancode::EQUALS};
static const Key Z;
static const Key X;
static const Key C;
static const Key V;
static const Key B;
static const Key N;
static const Key M;
static const Key Period;
static const Key Slash;
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 LShift;
static const Key RShift;
// TODO: Get the right character codes for these
static const Key UpArrow {'\u000a', X11Scancode::UP};
static const Key DownArrow {'\u000a', X11Scancode::DOWN};
static const Key LeftArrow {'\u000a', X11Scancode::LEFT};
static const Key RightArrow {'\u000a', X11Scancode::RIGHT};
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};
}
class GamepadButton {};

View File

@@ -23,8 +23,8 @@ Key::Key() {
keyboard.push_back(*this);
}
Key::Key(char charcode, X11Scancode scancode)
: CharCode(charcode), x11ScanCode(scancode)
Key::Key(char charcode, X11Scancode scancode, WindowsScancode sc)
: CharCode(charcode), x11ScanCode(scancode), winScanCode(sc)
{
keyboard.push_back(*this);
}