MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / Poll

Method Poll

System/FTerm/input.cpp:96–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94};
95
96void InputManager::Poll(){
97 uint8_t buf[16];
98 ssize_t count = Lemon::PollKeyboard(buf, 16);
99
100 for(ssize_t i = 0; i < count; i++){
101 uint8_t code = buf[i] & 0x7F;
102 bool isPressed = !((buf[i] >> 7) & 1);
103 int key = 0;
104
105 if(keyboard.shift){
106 key = keymap_us_shift[code];
107 } else {
108 key = keymap_us[code];
109 }
110
111 switch (key)
112 {
113 case KEY_SHIFT:
114 keyboard.shift = isPressed;
115 break;
116 case KEY_CONTROL:
117 keyboard.control = isPressed;
118 break;
119 case KEY_ALT:
120 keyboard.alt = isPressed;
121 break;
122 case KEY_CAPS:
123 if(isPressed) keyboard.caps = !keyboard.caps;
124 break;
125 }
126
127 if(isPressed){
128 OnKey(key);
129 }
130 }
131}

Callers 1

mainFunction · 0.45

Calls 2

PollKeyboardFunction · 0.85
OnKeyFunction · 0.85

Tested by

no test coverage detected