* the GNU General Public License.
*
* Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999, 2003 Bernardo Innocenti
+ * Copyright 1999, 2003 Bernie Innocenti
*
* -->
*
* \brief Keyboard driver (implementation)
*
- * \version $Id$
*
- * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Bernie Innocenti <bernie@codewiz.org>
* \author Stefano Fedrigo <aleph@develer.com>
* \author Francesco Sacchi <batt@develer.com>
*
#include <cfg/module.h>
#include <drv/timer.h>
+#include <mware/event.h>
#include <drv/kbd.h>
/** Status for keyboard repeat state machine */
static enum { KS_IDLE, KS_REPDELAY, KS_REPEAT } kbd_rptStatus;
+/** Used to notify the occurrence of a key pressed event */
+static Event key_pressed;
static volatile keymask_t kbd_buf; /**< Single entry keyboard buffer */
static volatile keymask_t kbd_cnt; /**< Number of keypress events in \c kbd_buf */
timer_add(&kbd_timer);
}
-#else
+#else
#error "Define keyboard poll method"
#endif /* CONFIG_KBD_POLL */
{
keymask_t key = 0;
-// FIXME: make it optional
+#if CONFIG_KBD_SCHED
/* Let other tasks run for a while */
extern void schedule(void);
schedule();
+#endif
/* Extract an event from the keyboard buffer */
IRQ_DISABLE;
{
keymask_t key;
- while (!(key = kbd_peek())) {}
+ #if CONFIG_KBD_POLL == KBD_POLL_SOFTINT
+ event_wait(&key_pressed);
+ key = kbd_peek();
+ #else
+ while (!(key = kbd_peek()))
+ cpu_relax();
+ #endif
return key;
}
*/
keymask_t kbd_get_timeout(mtime_t timeout)
{
- keymask_t key;
-
- ticks_t start = timer_clock();
- ticks_t stop = ms_to_ticks(timeout);
- do
- {
- if ((key = kbd_peek()))
- return key;
- }
- while (timer_clock() - start < stop);
-
- return K_TIMEOUT;
+ if (event_waitTimeout(&key_pressed, timeout))
+ return kbd_peek();
+ else
+ return K_TIMEOUT;
}
KbdHandler *node;
List *list;
- cpuflags_t flags;
+ cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
/* Choose between raw and coocked handlers list */
/* Force a single event in kbd buffer */
kbd_buf = key;
kbd_cnt = 1;
+ #if CONFIG_KBD_POLL == KBD_POLL_SOFTINT
+ event_do(&key_pressed);
+ #endif
#if CONFIG_KBD_OBSERVER
observer_notify(&kbd_subject, KBD_EVENT_KEY, &key);
#if CONFIG_KBD_POLL == KBD_POLL_SOFTINT
MOD_CHECK(timer);
+ #if CONFIG_KERN
+ MOD_CHECK(proc);
+ #endif
+
+ /* Initialize the keyboard event (key pressed) */
+ event_initGeneric(&key_pressed);
/* Add kbd handler to soft timers list */
- event_initSoftInt(&kbd_timer.expire, kbd_softint, NULL);
+ event_initSoftint(&kbd_timer.expire, kbd_softint, NULL);
timer_setDelay(&kbd_timer, ms_to_ticks(KBD_CHECK_INTERVAL));
timer_add(&kbd_timer);