From: bernie Date: Sat, 3 Jun 2006 13:57:36 +0000 (+0000) Subject: Make keyboard repeat mask run-time configurable. X-Git-Tag: 1.0.0~582 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=e5ca19aeea55effdbd3c8439d035db3c063208e0;p=bertos.git Make keyboard repeat mask run-time configurable. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@659 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/drv/kbd.c b/drv/kbd.c index a051edc7..4dabd3b3 100755 --- a/drv/kbd.c +++ b/drv/kbd.c @@ -17,6 +17,9 @@ /*#* *#* $Log$ + *#* Revision 1.7 2006/06/03 13:57:36 bernie + *#* Make keyboard repeat mask run-time configurable. + *#* *#* Revision 1.6 2006/03/20 17:50:17 bernie *#* Add FreeRTOS and Observers support. *#* @@ -79,6 +82,7 @@ static enum { KS_IDLE, KS_REPDELAY, KS_REPEAT } kbd_rptStatus; static volatile keymask_t kbd_buf; /*!< Single entry keyboard buffer */ static volatile keymask_t kbd_cnt; /*!< Number of keypress events in \c kbd_buf */ +static keymask_t kbd_rpt_mask; /**< Mask of repeatable keys. */ #if CONFIG_KBD_POLL == KBD_POLL_SOFTINT static Timer kbd_timer; /*!< Keyboard softtimer */ @@ -326,27 +330,35 @@ static keymask_t kbd_debHandlerFunc(keymask_t key) } #ifdef K_LNG_MASK -/*! - * Handle long pression keys +/** + * Handle long pression keys. */ static keymask_t kbd_lngHandlerFunc(keymask_t key) { - static ticks_t stop; + static ticks_t start; ticks_t now = timer_clock(); if (key & K_LNG_MASK) { - if (now - stop > 0) - key &= K_LNG_MASK; - else - key &= ~K_LNG_MASK; + if (now - start > ms_to_ticks(KBD_LNG_DELAY)) + key |= K_LONG; } else - stop = now + ms_to_ticks(KBD_LNG_DELAY); + start = now; return key; } #endif +/** + * Set current mask of repeatable keys. + */ +keymask_t kbd_setRepeatMask(keymask_t mask) +{ + keymask_t oldmask = kbd_rpt_mask; + ATOMIC(kbd_rpt_mask = mask); + return oldmask; +} + /*! * Handle keyboard repeat */ @@ -363,7 +375,7 @@ static keymask_t kbd_rptHandlerFunc(keymask_t key) switch (kbd_rptStatus) { case KS_IDLE: - if (key & K_RPT_MASK) + if (key & kbd_rpt_mask) { repeat_time = now; kbd_rptStatus = KS_REPDELAY; @@ -371,11 +383,11 @@ static keymask_t kbd_rptHandlerFunc(keymask_t key) break; case KS_REPDELAY: - if (key & K_RPT_MASK) + if (key & kbd_rpt_mask) { if (now - repeat_time > ms_to_ticks(KBD_REPEAT_DELAY)) { - key = (key & K_RPT_MASK) | K_REPEAT; + key = (key & kbd_rpt_mask) | K_REPEAT; repeat_time = now; repeat_rate = ms_to_ticks(KBD_REPEAT_RATE); kbd_rptStatus = KS_REPEAT; @@ -388,12 +400,12 @@ static keymask_t kbd_rptHandlerFunc(keymask_t key) break; case KS_REPEAT: - if (key & K_RPT_MASK) + if (key & kbd_rpt_mask) { if (now - repeat_time > repeat_rate) { /* Enqueue a new event in the buffer */ - key = (key & K_RPT_MASK) | K_REPEAT; + key = (key & kbd_rpt_mask) | K_REPEAT; repeat_time = now; /* Repeat rate acceleration */ diff --git a/drv/kbd.h b/drv/kbd.h index 307cf5e2..b9a253c3 100755 --- a/drv/kbd.h +++ b/drv/kbd.h @@ -16,6 +16,9 @@ /*#* *#* $Log$ + *#* Revision 1.5 2006/06/03 13:57:36 bernie + *#* Make keyboard repeat mask run-time configurable. + *#* *#* Revision 1.4 2006/03/20 17:50:17 bernie *#* Add FreeRTOS and Observers support. *#* @@ -68,6 +71,7 @@ keymask_t kbd_get(void); keymask_t kbd_get_timeout(mtime_t timeout); void kbd_addHandler(struct KbdHandler *handler); void kbd_remHandler(struct KbdHandler *handler); +keymask_t kbd_setRepeatMask(keymask_t mask); #if CONFIG_KBD_OBSERVER struct Subject;