/* Update the keyboard status; this will handle debounce handling as well as queueing keypresses for later usage. The key press queue uses 16-bit words so that we can store "special" keys as such. This needs to be called fairly periodically if you're expecting keyboard input. */ static void kbd_check_poll(maple_frame_t *frm) { kbd_state_t *state; kbd_cond_t *cond; int i, p; state = (kbd_state_t *)frm->dev->status; cond = (kbd_cond_t *)&state->cond; /* Check the shift state */ state->shift_keys = cond->modifiers; /* Process all pressed keys */ for (i=0; i<6; i++) { if (cond->keys[i] != 0) { p = state->matrix[cond->keys[i]]; state->matrix[cond->keys[i]] = 2; /* 2 == currently pressed */ if (p == 0) kbd_enqueue(state, cond->keys[i]); } } /* Now normalize the key matrix */ for (i=0; i<256; i++) { if (state->matrix[i] == 1) state->matrix[i] = 0; else if (state->matrix[i] == 2) state->matrix[i] = 1; else if (state->matrix[i] != 0) { assert_msg(0, "invalid key matrix array detected"); } } }
void kd_enqsc( Scancode sc) { kd_event ev; ev.type = KEYBD_EVENT; ev.time = time; ev.value.sc = sc; kbd_enqueue(&ev); }