*
*/
keymask_t kbd_peek(void)
+{
+ return kbd_peekMask((keymask_t)0xFFFFFFFFFFFFFFFFULL);
+}
+
+
+keymask_t kbd_peekMask(keymask_t mask)
{
keymask_t key = 0;
/* Extract an event from the keyboard buffer */
IRQ_DISABLE;
- if (kbd_cnt)
+ if (kbd_cnt && (kbd_buf & mask))
{
- --kbd_cnt;
- key = kbd_buf;
+ key = kbd_buf & mask;
+ kbd_buf &= ~mask;
+ if (!kbd_buf)
+ --kbd_cnt;
}
IRQ_ENABLE;
* \note This function is \b not interrupt safe!
*/
keymask_t kbd_get(void)
+{
+ return kbd_getMask((keymask_t)0xFFFFFFFFFFFFFFFFULL);
+}
+
+keymask_t kbd_getMask(keymask_t mask)
{
keymask_t key;
#if CONFIG_KBD_POLL == KBD_POLL_SOFTINT
- event_wait(&key_pressed);
- key = kbd_peek();
+ do
+ {
+ event_wait(&key_pressed);
+ key = kbd_peekMask(mask);
+ }
+ while (!key);
#else
- while (!(key = kbd_peek()))
+ while (!(key = kbd_peekMask(mask)))
cpu_relax();
#endif
void kbd_init(void);
keymask_t kbd_peek(void);
+keymask_t kbd_peekMask(keymask_t mask);
keymask_t kbd_get(void);
+keymask_t kbd_getMask(keymask_t mask);
keymask_t kbd_get_timeout(mtime_t timeout);
void kbd_addHandler(struct KbdHandler *handler);
void kbd_remHandler(struct KbdHandler *handler);