Filling out an Input Struct #1036
-
So I'm trying to convert a gui editor to a terminal one. The editor logic is like a black box that consumes the keyboards input state ( enum class InputKey {
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z,
SPACE,
GRAVE_ACCENT,
TILDE,
ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, ZERO,
MINUS, EQUAL,
EXCLAMATION_POINT, AT_SIGN, NUMBER_SIGN, DOLLAR_SIGN, PERCENT_SIGN,
CARET, AMPERSAND, ASTERISK, LEFT_PARENTHESIS, RIGHT_PARENTHESIS,
UNDERSCORE, PLUS,
LEFT_SQUARE_BRACKET, RIGHT_SQUARE_BRACKET,
LEFT_CURLY_BRACKET, RIGHT_CURLY_BRACKET,
COMMA, PERIOD, LESS_THAN, GREATER_THAN,
CAPS_LOCK, ESCAPE, ENTER, TAB, BACKSPACE, INSERT, DELETE,
RIGHT, LEFT, UP, DOWN,
SLASH, QUESTION_MARK, BACKSLASH, PIPE,
COLON, SEMICOLON, SINGLE_QUOTE, DOUBLE_QUOTE,
LEFT_SHIFT, RIGHT_SHIFT,
LEFT_CONTROL, RIGHT_CONTROL,
LEFT_ALT, RIGHT_ALT,
LEFT_SUPER, RIGHT_SUPER,
FUNCTION_KEY, MENU_KEY,
LEFT_MOUSE_BUTTON, RIGHT_MOUSE_BUTTON, MIDDLE_MOUSE_BUTTON,
SCROLL_UP, SCROLL_DOWN,
DUMMY
};
struct InputKeyState {
std::unordered_map<InputKey, bool> input_key_to_is_pressed;
std::unordered_map<InputKey, bool> input_key_to_is_pressed_prev;
std::unordered_map<InputKey, bool> input_key_to_just_pressed;
}; Now I'm in the context of component |= CatchEvent([&](Event event) {
...
} which occurs when an event occurs, I looked at the definition of event here: struct Event {
...
// --- Arrow ---
static const Event ArrowLeft;
static const Event ArrowRight;
static const Event ArrowUp;
static const Event ArrowDown;
static const Event ArrowLeftCtrl;
static const Event ArrowRightCtrl;
static const Event ArrowUpCtrl;
static const Event ArrowDownCtrl;
// --- Other ---
static const Event Backspace;
static const Event Delete;
static const Event Return;
static const Event Escape;
static const Event Tab;
static const Event TabReverse;
// --- Navigation keys ---
static const Event Insert;
static const Event Home;
static const Event End;
static const Event PageUp;
static const Event PageDown;
// --- Function keys ---
static const Event F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12;
// --- Control keys ---
static const Event a, A, CtrlA, AltA, CtrlAltA;
static const Event b, B, CtrlB, AltB, CtrlAltB;
static const Event c, C, CtrlC, AltC, CtrlAltC;
static const Event d, D, CtrlD, AltD, CtrlAltD;
static const Event e, E, CtrlE, AltE, CtrlAltE;
static const Event f, F, CtrlF, AltF, CtrlAltF;
static const Event g, G, CtrlG, AltG, CtrlAltG;
static const Event h, H, CtrlH, AltH, CtrlAltH;
static const Event i, I, CtrlI, AltI, CtrlAltI;
static const Event j, J, CtrlJ, AltJ, CtrlAltJ;
static const Event k, K, CtrlK, AltK, CtrlAltK;
static const Event l, L, CtrlL, AltL, CtrlAltL;
static const Event m, M, CtrlM, AltM, CtrlAltM;
static const Event n, N, CtrlN, AltN, CtrlAltN;
static const Event o, O, CtrlO, AltO, CtrlAltO;
static const Event p, P, CtrlP, AltP, CtrlAltP;
static const Event q, Q, CtrlQ, AltQ, CtrlAltQ;
static const Event r, R, CtrlR, AltR, CtrlAltR;
static const Event s, S, CtrlS, AltS, CtrlAltS;
static const Event t, T, CtrlT, AltT, CtrlAltT;
static const Event u, U, CtrlU, AltU, CtrlAltU;
static const Event v, V, CtrlV, AltV, CtrlAltV;
static const Event w, W, CtrlW, AltW, CtrlAltW;
static const Event x, X, CtrlX, AltX, CtrlAltX;
static const Event y, Y, CtrlY, AltY, CtrlAltY;
static const Event z, Z, CtrlZ, AltZ, CtrlAltZ;
...
}; Which looks okay, but I don't really see how I can isolate the pressing of the key It seems like alot of those modifiers are baked into a specific key like this |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
@ArthurSonzogni any ideas for this? Still haven't been able to figure it out |
Beta Was this translation helpful? Give feedback.
Sorry, the terminal API doesn't doesn't expose a single "shift" key. It always comes combined with another key.
I guess you will have to decombine manually to recover what you need.