|
|
@@ -8,6 +8,7 @@
|
|
|
* 2023-07-03 smartmx the first version, Multi-Function Button Dectection with Section Definition.
|
|
|
* 2023-07-15 smartmx add skip function, to reduce calling of scan functions.
|
|
|
* 2023-07-22 smartmx add MFBD_MBTN_MULTICLICK_LONG_EVT and MFBD_MBTN_CONTINUE_LONG_COUNT option.
|
|
|
+ * 2023-08-10 smartmx improve performance.
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
@@ -15,6 +16,9 @@
|
|
|
|
|
|
#if MFBD_USE_SECTION_DEFINITION
|
|
|
|
|
|
+#define MFBD_BTN_IN_FUC (_pbtn_info->btn)
|
|
|
+#define MFBD_BTN_INFO_IN_FUC (_pbtn_info)
|
|
|
+
|
|
|
#if MFBD_PARAMS_SAME_IN_GROUP
|
|
|
|
|
|
/* filter_time */
|
|
|
@@ -60,48 +64,51 @@ void mfbd_tbtn_scan(const mfbd_group_t *_pbtn_group, const mfbd_tbtn_info_t *_pb
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
- if (_pbtn_group->is_btn_down_func(_pbtn_info->btn_index) != MFBD_BTN_STATE_UP)
|
|
|
+ if (_pbtn_group->is_btn_down_func(MFBD_BTN_INFO_IN_FUC->btn_index) != MFBD_BTN_STATE_UP)
|
|
|
{
|
|
|
- if (_pbtn_info->btn->filter_count < (MFBD_FILTER_TIME_IN_FUC))
|
|
|
- {
|
|
|
- _pbtn_info->btn->filter_count = (MFBD_FILTER_TIME_IN_FUC);
|
|
|
- }
|
|
|
- else if (_pbtn_info->btn->filter_count < ((MFBD_FILTER_TIME_IN_FUC) * 2))
|
|
|
- {
|
|
|
- _pbtn_info->btn->filter_count++;
|
|
|
- }
|
|
|
- else
|
|
|
+ if(MFBD_BTN_IN_FUC->filter_count >= ((MFBD_FILTER_TIME_IN_FUC) * 2))
|
|
|
{
|
|
|
/* it means the button is down for over filter_time. */
|
|
|
- if (_pbtn_info->btn->state == MFBD_BTN_STATE_UP)
|
|
|
+ if (MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_UP)
|
|
|
{
|
|
|
- if (_pbtn_info->btn_down_code > 0)
|
|
|
+ if (MFBD_BTN_INFO_IN_FUC->btn_down_code > 0)
|
|
|
{
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_down_code);
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_down_code);
|
|
|
}
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_DOWN;
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_DOWN;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (_pbtn_info->btn->filter_count > (MFBD_FILTER_TIME_IN_FUC))
|
|
|
+ else if(MFBD_BTN_IN_FUC->filter_count >= (MFBD_FILTER_TIME_IN_FUC))
|
|
|
{
|
|
|
- _pbtn_info->btn->filter_count = (MFBD_FILTER_TIME_IN_FUC);
|
|
|
+ MFBD_BTN_IN_FUC->filter_count++;
|
|
|
}
|
|
|
- else if (_pbtn_info->btn->filter_count != 0)
|
|
|
+ else
|
|
|
{
|
|
|
- _pbtn_info->btn->filter_count--;
|
|
|
+ MFBD_BTN_IN_FUC->filter_count = (MFBD_FILTER_TIME_IN_FUC);
|
|
|
}
|
|
|
- else
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->filter_count == 0)
|
|
|
{
|
|
|
- if (_pbtn_info->btn->state != MFBD_BTN_STATE_UP)
|
|
|
+ if (MFBD_BTN_IN_FUC->state != MFBD_BTN_STATE_UP)
|
|
|
{
|
|
|
- if (_pbtn_info->btn_up_code > 0)
|
|
|
+ if (MFBD_BTN_INFO_IN_FUC->btn_up_code > 0)
|
|
|
{
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_up_code);
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_up_code);
|
|
|
}
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_UP;
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_UP;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->filter_count > (MFBD_FILTER_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->filter_count = (MFBD_FILTER_TIME_IN_FUC);
|
|
|
+ }
|
|
|
+ else if (MFBD_BTN_IN_FUC->filter_count != 0)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->filter_count--;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -126,8 +133,8 @@ void mfbd_tbtn_reset(const mfbd_tbtn_info_t *_pbtn_info_start, const mfbd_tbtn_i
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
- _pbtn_info->btn->filter_count = 0;
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_UP;
|
|
|
+ MFBD_BTN_IN_FUC->filter_count = 0;
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_UP;
|
|
|
|
|
|
_pbtn_info++;
|
|
|
}
|
|
|
@@ -156,82 +163,104 @@ void mfbd_nbtn_scan(const mfbd_group_t *_pbtn_group, const mfbd_nbtn_info_t *_pb
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
- if (_pbtn_group->is_btn_down_func(_pbtn_info->btn_index) != MFBD_BTN_STATE_UP)
|
|
|
+ if (_pbtn_group->is_btn_down_func(MFBD_BTN_INFO_IN_FUC->btn_index) != MFBD_BTN_STATE_UP)
|
|
|
{
|
|
|
- if (_pbtn_info->btn->filter_count < (MFBD_FILTER_TIME_IN_FUC))
|
|
|
- {
|
|
|
- _pbtn_info->btn->filter_count = (MFBD_FILTER_TIME_IN_FUC);
|
|
|
+ if(MFBD_BTN_IN_FUC->filter_count >= ((MFBD_FILTER_TIME_IN_FUC) * 2))
|
|
|
+ {
|
|
|
+ /* it means the button is down for over filter_time. */
|
|
|
+ if (MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_LONG)
|
|
|
+ {
|
|
|
+ /* MFBD_BTN_STATE_LONG */
|
|
|
+ if (MFBD_BTN_IN_FUC->repeat_count > 0)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count++;
|
|
|
+ if (MFBD_BTN_IN_FUC->repeat_count > (MFBD_REPEAT_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ /* repeat event has happened, reset repeat_count to 1. */
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = 1;
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_down_code);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_DOWN)
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->long_count > 0)
|
|
|
+ {
|
|
|
+ /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
+ if (MFBD_BTN_IN_FUC->long_count <= (MFBD_LONG_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->long_count++;
|
|
|
+ if (MFBD_BTN_IN_FUC->long_count > (MFBD_LONG_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ /* it means the button is down for over long_time. */
|
|
|
+ if (((MFBD_REPEAT_TIME_IN_FUC) > 0) && (MFBD_BTN_INFO_IN_FUC->btn_down_code != 0))
|
|
|
+ {
|
|
|
+ /* repeat event is enabled in this btn. */
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* repeat event is disabled in this btn. */
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = 0;
|
|
|
+ }
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_long_code);
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_LONG;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* MFBD_BTN_STATE_UP */
|
|
|
+ /* clear long_count. */
|
|
|
+ if (((MFBD_LONG_TIME_IN_FUC) > 0) && (MFBD_BTN_INFO_IN_FUC->btn_long_code != 0))
|
|
|
+ {
|
|
|
+ /* long event is enabled in this btn. */
|
|
|
+ MFBD_BTN_IN_FUC->long_count = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* long event is disabled in this btn. */
|
|
|
+ MFBD_BTN_IN_FUC->long_count = 0;
|
|
|
+ }
|
|
|
+ if (MFBD_BTN_INFO_IN_FUC->btn_down_code > 0)
|
|
|
+ {
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_down_code);
|
|
|
+ }
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_DOWN;
|
|
|
+ }
|
|
|
}
|
|
|
- else if (_pbtn_info->btn->filter_count < ((MFBD_FILTER_TIME_IN_FUC) * 2))
|
|
|
+ else if(MFBD_BTN_IN_FUC->filter_count >= (MFBD_FILTER_TIME_IN_FUC))
|
|
|
{
|
|
|
- _pbtn_info->btn->filter_count++;
|
|
|
+ MFBD_BTN_IN_FUC->filter_count++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- /* it means the button is down for over filter_time. */
|
|
|
- if (_pbtn_info->btn->state == MFBD_BTN_STATE_UP)
|
|
|
- {
|
|
|
- /* clear long_count. */
|
|
|
- _pbtn_info->btn->long_count = 0;
|
|
|
- if (_pbtn_info->btn_down_code > 0)
|
|
|
- {
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_down_code);
|
|
|
- }
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_DOWN;
|
|
|
- }
|
|
|
- else if(_pbtn_info->btn->state == MFBD_BTN_STATE_DOWN)
|
|
|
- {
|
|
|
- if (((MFBD_LONG_TIME_IN_FUC) > 0) && (_pbtn_info->btn_long_code != 0))
|
|
|
- {
|
|
|
- /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
- if (_pbtn_info->btn->long_count < (MFBD_LONG_TIME_IN_FUC))
|
|
|
- {
|
|
|
- _pbtn_info->btn->long_count++;
|
|
|
- if (_pbtn_info->btn->long_count >= (MFBD_LONG_TIME_IN_FUC))
|
|
|
- {
|
|
|
- /* it means the button is down for over long_time. */
|
|
|
- _pbtn_info->btn->repeat_count = 0; /* long event has happened, clear repeat_count. */
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_long_code);
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_LONG;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- /* MFBD_BTN_STATE_LONG */
|
|
|
- if (((MFBD_REPEAT_TIME_IN_FUC) > 0) && (_pbtn_info->btn_down_code != 0))
|
|
|
- {
|
|
|
- _pbtn_info->btn->repeat_count++;
|
|
|
- if (_pbtn_info->btn->repeat_count >= (MFBD_REPEAT_TIME_IN_FUC))
|
|
|
- {
|
|
|
- /* repeat event has happened, clear repeat_count. */
|
|
|
- _pbtn_info->btn->repeat_count = 0;
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_down_code);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ MFBD_BTN_IN_FUC->filter_count = (MFBD_FILTER_TIME_IN_FUC);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (_pbtn_info->btn->filter_count > (MFBD_FILTER_TIME_IN_FUC))
|
|
|
+ if (MFBD_BTN_IN_FUC->filter_count == 0)
|
|
|
{
|
|
|
- _pbtn_info->btn->filter_count = (MFBD_FILTER_TIME_IN_FUC);
|
|
|
- }
|
|
|
- else if (_pbtn_info->btn->filter_count != 0)
|
|
|
- {
|
|
|
- _pbtn_info->btn->filter_count--;
|
|
|
+ if (MFBD_BTN_IN_FUC->state != MFBD_BTN_STATE_UP)
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_INFO_IN_FUC->btn_up_code > 0)
|
|
|
+ {
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_up_code);
|
|
|
+ }
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_UP;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (_pbtn_info->btn->state != MFBD_BTN_STATE_UP)
|
|
|
+ if (MFBD_BTN_IN_FUC->filter_count > (MFBD_FILTER_TIME_IN_FUC))
|
|
|
{
|
|
|
- if (_pbtn_info->btn_up_code > 0)
|
|
|
- {
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_up_code);
|
|
|
- }
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_UP;
|
|
|
+ MFBD_BTN_IN_FUC->filter_count = (MFBD_FILTER_TIME_IN_FUC);
|
|
|
+ }
|
|
|
+ else if (MFBD_BTN_IN_FUC->filter_count != 0)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->filter_count--;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -257,35 +286,31 @@ void mfbd_nbtn_skip(const mfbd_group_t *_pbtn_group, const mfbd_nbtn_info_t *_pb
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
- if(_pbtn_info->btn->state == MFBD_BTN_STATE_DOWN)
|
|
|
+ if(MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_DOWN)
|
|
|
{
|
|
|
- if (((MFBD_LONG_TIME_IN_FUC) > 0) && (_pbtn_info->btn_long_code != 0))
|
|
|
+ if ((MFBD_BTN_IN_FUC->long_count > 0) && (MFBD_BTN_IN_FUC->long_count < (MFBD_LONG_TIME_IN_FUC)))
|
|
|
{
|
|
|
- /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
- if (_pbtn_info->btn->long_count < (MFBD_LONG_TIME_IN_FUC))
|
|
|
+ if(((MFBD_LONG_TIME_IN_FUC) - MFBD_BTN_IN_FUC->long_count) > times)
|
|
|
{
|
|
|
- if(((MFBD_LONG_TIME_IN_FUC) - 1 - _pbtn_info->btn->long_count) > times)
|
|
|
- {
|
|
|
- _pbtn_info->btn->long_count = _pbtn_info->btn->long_count + times;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _pbtn_info->btn->long_count = MFBD_LONG_TIME_IN_FUC - 1;
|
|
|
- }
|
|
|
+ MFBD_BTN_IN_FUC->long_count = MFBD_BTN_IN_FUC->long_count + times;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->long_count = MFBD_LONG_TIME_IN_FUC;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if(_pbtn_info->btn->state == MFBD_BTN_STATE_LONG)
|
|
|
+ else if(MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_LONG)
|
|
|
{
|
|
|
- if (((MFBD_REPEAT_TIME_IN_FUC) > 0) && (_pbtn_info->btn_down_code != 0))
|
|
|
+ if ((MFBD_BTN_IN_FUC->repeat_count > 0) && (MFBD_BTN_IN_FUC->repeat_count < (MFBD_REPEAT_TIME_IN_FUC)))
|
|
|
{
|
|
|
- if(((MFBD_REPEAT_TIME_IN_FUC) - 1 - _pbtn_info->btn->repeat_count) > times)
|
|
|
+ if(((MFBD_REPEAT_TIME_IN_FUC) - MFBD_BTN_IN_FUC->repeat_count) > times)
|
|
|
{
|
|
|
- _pbtn_info->btn->repeat_count = _pbtn_info->btn->repeat_count + times;
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = MFBD_BTN_IN_FUC->repeat_count + times;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- _pbtn_info->btn->repeat_count = MFBD_REPEAT_TIME_IN_FUC - 1;
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = MFBD_REPEAT_TIME_IN_FUC;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -310,10 +335,10 @@ void mfbd_nbtn_reset(const mfbd_nbtn_info_t *_pbtn_info_start, const mfbd_nbtn_i
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
- _pbtn_info->btn->filter_count = 0;
|
|
|
- _pbtn_info->btn->long_count = 0;
|
|
|
- _pbtn_info->btn->repeat_count = 0;
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_UP;
|
|
|
+ MFBD_BTN_IN_FUC->filter_count = 0;
|
|
|
+ MFBD_BTN_IN_FUC->long_count = 0;
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = 0;
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_UP;
|
|
|
|
|
|
_pbtn_info++;
|
|
|
}
|
|
|
@@ -343,195 +368,225 @@ void mfbd_mbtn_scan(const mfbd_group_t *_pbtn_group, const mfbd_mbtn_info_t *_pb
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (_pbtn_group->is_btn_down_func(_pbtn_info->btn_index) != MFBD_BTN_STATE_UP)
|
|
|
- {
|
|
|
- if (_pbtn_info->btn->filter_count < (MFBD_FILTER_TIME_IN_FUC))
|
|
|
- {
|
|
|
- _pbtn_info->btn->filter_count = (MFBD_FILTER_TIME_IN_FUC);
|
|
|
- }
|
|
|
- else if (_pbtn_info->btn->filter_count < ((MFBD_FILTER_TIME_IN_FUC) * 2))
|
|
|
- {
|
|
|
- _pbtn_info->btn->filter_count++;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- /* it means the button is down for over filter_time. */
|
|
|
- if (_pbtn_info->btn->state == MFBD_BTN_STATE_UP)
|
|
|
- {
|
|
|
- /* clear long_count. */
|
|
|
- _pbtn_info->btn->long_count = 0;
|
|
|
- if (_pbtn_info->btn_down_code[_pbtn_info->btn->multiclick_state] > 0)
|
|
|
- {
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_down_code[_pbtn_info->btn->multiclick_state]);
|
|
|
- }
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_DOWN;
|
|
|
- }
|
|
|
-#if MFBD_MBTN_CONTINUE_LONG_COUNT
|
|
|
-#if MFBD_MBTN_MULTICLICK_LONG_EVT
|
|
|
- else if(_pbtn_info->btn->state == MFBD_BTN_STATE_DOWN)
|
|
|
- {
|
|
|
- if (((MFBD_LONG_TIME_IN_FUC) > 0) && (_pbtn_info->btn_long_code != 0))
|
|
|
- {
|
|
|
- /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
- if (_pbtn_info->btn->long_count < (MFBD_LONG_TIME_IN_FUC))
|
|
|
- {
|
|
|
- _pbtn_info->btn->long_count++;
|
|
|
- if (_pbtn_info->btn->long_count >= (MFBD_LONG_TIME_IN_FUC))
|
|
|
- {
|
|
|
- /* it means the button is down for over long_time. */
|
|
|
- _pbtn_info->btn->repeat_count = 0; /* long event has happened, clear repeat_count. */
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_long_code);
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_LONG;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- /* MFBD_BTN_STATE_LONG */
|
|
|
- if (((MFBD_REPEAT_TIME_IN_FUC) > 0) && (_pbtn_info->btn_down_code[_pbtn_info->btn->multiclick_state] != 0))
|
|
|
- {
|
|
|
- _pbtn_info->btn->repeat_count++;
|
|
|
- if (_pbtn_info->btn->repeat_count >= (MFBD_REPEAT_TIME_IN_FUC))
|
|
|
- {
|
|
|
- /* repeat event has happened, clear repeat_count. */
|
|
|
- _pbtn_info->btn->repeat_count = 0;
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_down_code[_pbtn_info->btn->multiclick_state]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-#else
|
|
|
- else if(_pbtn_info->btn->state == MFBD_BTN_STATE_DOWN)
|
|
|
- {
|
|
|
- if (((MFBD_LONG_TIME_IN_FUC) > 0) && (_pbtn_info->btn_long_code != 0))
|
|
|
- {
|
|
|
- /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
- if (_pbtn_info->btn->long_count < (MFBD_LONG_TIME_IN_FUC))
|
|
|
- {
|
|
|
- _pbtn_info->btn->long_count++;
|
|
|
- if (_pbtn_info->btn->long_count >= (MFBD_LONG_TIME_IN_FUC))
|
|
|
- {
|
|
|
- /* it means the button is down for over long_time. */
|
|
|
- if (_pbtn_info->btn->multiclick_state == 0)
|
|
|
- {
|
|
|
- _pbtn_info->btn->repeat_count = 0; /* long event has happened, clear repeat_count. */
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_long_code);
|
|
|
- }
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_LONG;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- /* MFBD_BTN_STATE_LONG */
|
|
|
- /* we don't support repeat event here.*/
|
|
|
- }
|
|
|
-#endif /* MFBD_MBTN_MULTICLICK_LONG_EVT */
|
|
|
-#else
|
|
|
- else if(_pbtn_info->btn->state == MFBD_BTN_STATE_DOWN)
|
|
|
- {
|
|
|
- if (_pbtn_info->btn->multiclick_state == 0)
|
|
|
- {
|
|
|
- if (((MFBD_LONG_TIME_IN_FUC) > 0) && (_pbtn_info->btn_long_code != 0))
|
|
|
- {
|
|
|
- /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
- if (_pbtn_info->btn->long_count < (MFBD_LONG_TIME_IN_FUC))
|
|
|
- {
|
|
|
- _pbtn_info->btn->long_count++;
|
|
|
- if (_pbtn_info->btn->long_count >= (MFBD_LONG_TIME_IN_FUC))
|
|
|
- {
|
|
|
- /* it means the button is down for over long_time. */
|
|
|
- _pbtn_info->btn->repeat_count = 0; /* long event has happened, clear repeat_count. */
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_long_code);
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_LONG;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- /* MFBD_BTN_STATE_LONG */
|
|
|
- if (((MFBD_REPEAT_TIME_IN_FUC) > 0) && (_pbtn_info->btn_down_code[0] != 0))
|
|
|
- {
|
|
|
- _pbtn_info->btn->repeat_count++;
|
|
|
- if (_pbtn_info->btn->repeat_count >= (MFBD_REPEAT_TIME_IN_FUC))
|
|
|
- {
|
|
|
- /* repeat event has happened, clear repeat_count. */
|
|
|
- _pbtn_info->btn->repeat_count = 0;
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_down_code[0]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-#endif /* MFBD_MBTN_CONTINUE_LONG_COUNT */
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (_pbtn_info->btn->filter_count > (MFBD_FILTER_TIME_IN_FUC))
|
|
|
- {
|
|
|
- _pbtn_info->btn->filter_count = (MFBD_FILTER_TIME_IN_FUC);
|
|
|
- }
|
|
|
- else if (_pbtn_info->btn->filter_count != 0)
|
|
|
- {
|
|
|
- _pbtn_info->btn->filter_count--;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (_pbtn_info->btn->state != MFBD_BTN_STATE_UP)
|
|
|
- {
|
|
|
-#if MFBD_MULTICLICK_STATE_AUTO_RESET
|
|
|
- /* if multiclick_state is not 0 and less than max_multiclick_state, inc multiclick_state */
|
|
|
- if (((MFBD_MULTICLICK_TIME_IN_FUC) != 0)
|
|
|
- && (_pbtn_info->btn->multiclick_state < _pbtn_info->max_multiclick_state)
|
|
|
-#if (MFBD_MBTN_CONTINUE_LONG_COUNT==0)
|
|
|
- && (_pbtn_info->btn->state == MFBD_BTN_STATE_DOWN)
|
|
|
-#endif /* (MFBD_MBTN_CONTINUE_LONG_COUNT==0) */
|
|
|
- )
|
|
|
- {
|
|
|
- _pbtn_info->btn->multiclick_state++;
|
|
|
- _pbtn_info->btn->multiclick_count = 0;
|
|
|
- }
|
|
|
-#else
|
|
|
- /* if multiclick_state is not 0 and less than max_multiclick_state, inc multiclick_state */
|
|
|
- if (((MFBD_MULTICLICK_TIME_IN_FUC) != 0)
|
|
|
-#if (MFBD_MBTN_CONTINUE_LONG_COUNT==0)
|
|
|
- && (_pbtn_info->btn->state == MFBD_BTN_STATE_DOWN)
|
|
|
-#endif /* (MFBD_MBTN_CONTINUE_LONG_COUNT==0) */
|
|
|
- )
|
|
|
- {
|
|
|
- if(_pbtn_info->btn->multiclick_state < _pbtn_info->max_multiclick_state)
|
|
|
- {
|
|
|
- _pbtn_info->btn->multiclick_state++;
|
|
|
- }
|
|
|
- _pbtn_info->btn->multiclick_count = 0;
|
|
|
- }
|
|
|
-#endif /* MFBD_MULTICLICK_STATE_AUTO_RESET */
|
|
|
- else
|
|
|
- {
|
|
|
- /* over max multi-click times or (long event and repeat event) happened, reset to 0. */
|
|
|
- _pbtn_info->btn->multiclick_state = 0;
|
|
|
- }
|
|
|
- if (_pbtn_info->btn_up_code > 0)
|
|
|
- {
|
|
|
- _pbtn_group->btn_value_report(_pbtn_info->btn_up_code);
|
|
|
- }
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_UP;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (_pbtn_info->btn->multiclick_state != 0)
|
|
|
- {
|
|
|
- _pbtn_info->btn->multiclick_count++;
|
|
|
- if (_pbtn_info->btn->multiclick_count >= (MFBD_MULTICLICK_TIME_IN_FUC))
|
|
|
- {
|
|
|
- _pbtn_info->btn->multiclick_state = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ if (_pbtn_group->is_btn_down_func(MFBD_BTN_INFO_IN_FUC->btn_index) != MFBD_BTN_STATE_UP)
|
|
|
+ {
|
|
|
+ if(MFBD_BTN_IN_FUC->filter_count >= ((MFBD_FILTER_TIME_IN_FUC) * 2))
|
|
|
+ {
|
|
|
+ /* it means the button is down for over filter_time. */
|
|
|
+ #if MFBD_MBTN_CONTINUE_LONG_COUNT
|
|
|
+ #if MFBD_MBTN_MULTICLICK_LONG_EVT
|
|
|
+ if (MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_LONG)
|
|
|
+ {
|
|
|
+ /* MFBD_BTN_STATE_LONG */
|
|
|
+ if (MFBD_BTN_IN_FUC->repeat_count > 0)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count++;
|
|
|
+ if (MFBD_BTN_IN_FUC->repeat_count > (MFBD_REPEAT_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ /* repeat event has happened, clear repeat_count. */
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = 1;
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_down_code[MFBD_BTN_IN_FUC->multiclick_state]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_DOWN)
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->long_count > 0)
|
|
|
+ {
|
|
|
+ /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
+ if (MFBD_BTN_IN_FUC->long_count <= (MFBD_LONG_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->long_count++;
|
|
|
+ if (MFBD_BTN_IN_FUC->long_count > (MFBD_LONG_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ /* it means the button is down for over long_time. */
|
|
|
+ if (((MFBD_REPEAT_TIME_IN_FUC) > 0) && (MFBD_BTN_INFO_IN_FUC->btn_down_code[MFBD_BTN_IN_FUC->multiclick_state] != 0))
|
|
|
+ {
|
|
|
+ /* repeat event is enabled in this btn. */
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* repeat event is disabled in this btn. */
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = 0;
|
|
|
+ }
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_long_code);
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_LONG;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #else
|
|
|
+ if (MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_LONG)
|
|
|
+ {
|
|
|
+ /* we don't support repeat event here.*/
|
|
|
+ }
|
|
|
+ else if (MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_DOWN)
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->long_count > 0)
|
|
|
+ {
|
|
|
+ /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
+ if (MFBD_BTN_IN_FUC->long_count <= (MFBD_LONG_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->long_count++;
|
|
|
+ if (MFBD_BTN_IN_FUC->long_count > (MFBD_LONG_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ /* it means the button is down for over long_time. */
|
|
|
+ if (MFBD_BTN_IN_FUC->multiclick_state == 0)
|
|
|
+ {
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_long_code);
|
|
|
+ }
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_LONG;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endif /* MFBD_MBTN_MULTICLICK_LONG_EVT */
|
|
|
+ #else
|
|
|
+ if (MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_LONG)
|
|
|
+ {
|
|
|
+ /* MFBD_BTN_STATE_LONG */
|
|
|
+ if (MFBD_BTN_IN_FUC->repeat_count > 0)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count++;
|
|
|
+ if (MFBD_BTN_IN_FUC->repeat_count > (MFBD_REPEAT_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ /* repeat event has happened, clear repeat_count. */
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = 1;
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_down_code[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_DOWN)
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->multiclick_state == 0)
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->long_count > 0)
|
|
|
+ {
|
|
|
+ /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
+ if (MFBD_BTN_IN_FUC->long_count <= (MFBD_LONG_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->long_count++;
|
|
|
+ if (MFBD_BTN_IN_FUC->long_count > (MFBD_LONG_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ /* it means the button is down for over long_time. */
|
|
|
+ if (((MFBD_REPEAT_TIME_IN_FUC) > 0) && (MFBD_BTN_INFO_IN_FUC->btn_down_code[0] != 0))
|
|
|
+ {
|
|
|
+ /* repeat event is enabled in this btn. */
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* repeat event is disabled in this btn. */
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = 0;
|
|
|
+ }
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_long_code);
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_LONG;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endif /* MFBD_MBTN_CONTINUE_LONG_COUNT */
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* MFBD_BTN_STATE_UP */
|
|
|
+ /* clear long_count. */
|
|
|
+ if (((MFBD_LONG_TIME_IN_FUC) > 0) && (MFBD_BTN_INFO_IN_FUC->btn_long_code != 0))
|
|
|
+ {
|
|
|
+ /* long event is enabled in this btn. */
|
|
|
+ MFBD_BTN_IN_FUC->long_count = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* long event is disabled in this btn. */
|
|
|
+ MFBD_BTN_IN_FUC->long_count = 0;
|
|
|
+ }
|
|
|
+ if (MFBD_BTN_INFO_IN_FUC->btn_down_code[MFBD_BTN_IN_FUC->multiclick_state] > 0)
|
|
|
+ {
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_down_code[MFBD_BTN_IN_FUC->multiclick_state]);
|
|
|
+ }
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_DOWN;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(MFBD_BTN_IN_FUC->filter_count >= (MFBD_FILTER_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->filter_count++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->filter_count = (MFBD_FILTER_TIME_IN_FUC);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->filter_count == 0)
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->state != MFBD_BTN_STATE_UP)
|
|
|
+ {
|
|
|
+ #if MFBD_MULTICLICK_STATE_AUTO_RESET
|
|
|
+ /* if multiclick_state is not 0 and less than max_multiclick_state, inc multiclick_state */
|
|
|
+ if (((MFBD_MULTICLICK_TIME_IN_FUC) != 0)
|
|
|
+ && (MFBD_BTN_IN_FUC->multiclick_state < MFBD_BTN_INFO_IN_FUC->max_multiclick_state)
|
|
|
+ #if (MFBD_MBTN_CONTINUE_LONG_COUNT==0)
|
|
|
+ && (MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_DOWN)
|
|
|
+ #endif /* (MFBD_MBTN_CONTINUE_LONG_COUNT==0) */
|
|
|
+ )
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->multiclick_state++;
|
|
|
+ MFBD_BTN_IN_FUC->multiclick_count = 0;
|
|
|
+ }
|
|
|
+ #else
|
|
|
+ /* if multiclick_state is not 0 and less than max_multiclick_state, inc multiclick_state */
|
|
|
+ if (((MFBD_MULTICLICK_TIME_IN_FUC) != 0)
|
|
|
+ #if (MFBD_MBTN_CONTINUE_LONG_COUNT==0)
|
|
|
+ && (MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_DOWN)
|
|
|
+ #endif /* (MFBD_MBTN_CONTINUE_LONG_COUNT==0) */
|
|
|
+ )
|
|
|
+ {
|
|
|
+ if(MFBD_BTN_IN_FUC->multiclick_state < MFBD_BTN_INFO_IN_FUC->max_multiclick_state)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->multiclick_state++;
|
|
|
+ }
|
|
|
+ MFBD_BTN_IN_FUC->multiclick_count = 0;
|
|
|
+ }
|
|
|
+ #endif /* MFBD_MULTICLICK_STATE_AUTO_RESET */
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* over max multi-click times or (long event and repeat event) happened, reset to 0. */
|
|
|
+ MFBD_BTN_IN_FUC->multiclick_state = 0;
|
|
|
+ }
|
|
|
+ if (MFBD_BTN_INFO_IN_FUC->btn_up_code > 0)
|
|
|
+ {
|
|
|
+ _pbtn_group->btn_value_report(MFBD_BTN_INFO_IN_FUC->btn_up_code);
|
|
|
+ }
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_UP;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->multiclick_state != 0)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->multiclick_count++;
|
|
|
+ if (MFBD_BTN_IN_FUC->multiclick_count >= (MFBD_MULTICLICK_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->multiclick_state = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->filter_count > (MFBD_FILTER_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->filter_count = (MFBD_FILTER_TIME_IN_FUC);
|
|
|
+ }
|
|
|
+ else if (MFBD_BTN_IN_FUC->filter_count != 0)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->filter_count--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
_pbtn_info++;
|
|
|
}
|
|
|
}
|
|
|
@@ -549,121 +604,108 @@ void mfbd_mbtn_skip(const mfbd_group_t *_pbtn_group, const mfbd_mbtn_info_t *_pb
|
|
|
const mfbd_mbtn_info_t *_pbtn_info = _pbtn_info_start;
|
|
|
while (1)
|
|
|
{
|
|
|
- if(_pbtn_info->btn->state == MFBD_BTN_STATE_UP)
|
|
|
- {
|
|
|
- if (_pbtn_info->btn->multiclick_state != 0)
|
|
|
- {
|
|
|
- if (_pbtn_info->btn->multiclick_count < (MFBD_MULTICLICK_TIME_IN_FUC))
|
|
|
- {
|
|
|
- if(((MFBD_MULTICLICK_TIME_IN_FUC) - _pbtn_info->btn->multiclick_count) > times)
|
|
|
- {
|
|
|
- _pbtn_info->btn->multiclick_count = _pbtn_info->btn->multiclick_count + times;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _pbtn_info->btn->multiclick_state = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ if(MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_UP)
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->multiclick_state != 0)
|
|
|
+ {
|
|
|
+ if (MFBD_BTN_IN_FUC->multiclick_count < (MFBD_MULTICLICK_TIME_IN_FUC))
|
|
|
+ {
|
|
|
+ if(((MFBD_MULTICLICK_TIME_IN_FUC) - MFBD_BTN_IN_FUC->multiclick_count) > times)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->multiclick_count = MFBD_BTN_IN_FUC->multiclick_count + times;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->multiclick_state = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
#if MFBD_MBTN_CONTINUE_LONG_COUNT
|
|
|
#if MFBD_MBTN_MULTICLICK_LONG_EVT
|
|
|
- else if(_pbtn_info->btn->state == MFBD_BTN_STATE_DOWN)
|
|
|
- {
|
|
|
- if (((MFBD_LONG_TIME_IN_FUC) > 0) && (_pbtn_info->btn_long_code != 0))
|
|
|
- {
|
|
|
- /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
- if (_pbtn_info->btn->long_count < (MFBD_LONG_TIME_IN_FUC))
|
|
|
- {
|
|
|
- if(((MFBD_LONG_TIME_IN_FUC) - 1 - _pbtn_info->btn->long_count) > times)
|
|
|
- {
|
|
|
- _pbtn_info->btn->long_count = _pbtn_info->btn->long_count + times;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _pbtn_info->btn->long_count = MFBD_LONG_TIME_IN_FUC - 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- /* MFBD_BTN_STATE_LONG, if(_pbtn_info->btn->state == MFBD_BTN_STATE_LONG) */
|
|
|
- if (((MFBD_REPEAT_TIME_IN_FUC) > 0) && (_pbtn_info->btn_down_code[_pbtn_info->btn->multiclick_state] != 0))
|
|
|
- {
|
|
|
- if(((MFBD_REPEAT_TIME_IN_FUC) - 1 - _pbtn_info->btn->repeat_count) > times)
|
|
|
- {
|
|
|
- _pbtn_info->btn->repeat_count = _pbtn_info->btn->repeat_count + times;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _pbtn_info->btn->repeat_count = MFBD_REPEAT_TIME_IN_FUC - 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ else if(MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_DOWN)
|
|
|
+ {
|
|
|
+ if ((MFBD_BTN_IN_FUC->long_count > 0) && (MFBD_BTN_IN_FUC->long_count < (MFBD_LONG_TIME_IN_FUC)))
|
|
|
+ {
|
|
|
+ if(((MFBD_LONG_TIME_IN_FUC) - MFBD_BTN_IN_FUC->long_count) > times)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->long_count = MFBD_BTN_IN_FUC->long_count + times;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->long_count = MFBD_LONG_TIME_IN_FUC;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* MFBD_BTN_STATE_LONG, if(MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_LONG) */
|
|
|
+ if ((MFBD_BTN_IN_FUC->repeat_count > 0) && (MFBD_BTN_IN_FUC->repeat_count < (MFBD_REPEAT_TIME_IN_FUC)))
|
|
|
+ {
|
|
|
+ if(((MFBD_REPEAT_TIME_IN_FUC) - MFBD_BTN_IN_FUC->repeat_count) > times)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = MFBD_BTN_IN_FUC->repeat_count + times;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = MFBD_REPEAT_TIME_IN_FUC;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
#else
|
|
|
- else if(_pbtn_info->btn->state == MFBD_BTN_STATE_DOWN)
|
|
|
- {
|
|
|
- if (((MFBD_LONG_TIME_IN_FUC) > 0) && (_pbtn_info->btn_long_code != 0))
|
|
|
- {
|
|
|
- /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
- if (_pbtn_info->btn->long_count < (MFBD_LONG_TIME_IN_FUC))
|
|
|
- {
|
|
|
- if(((MFBD_LONG_TIME_IN_FUC) - 1 - _pbtn_info->btn->long_count) > times)
|
|
|
- {
|
|
|
- _pbtn_info->btn->long_count = _pbtn_info->btn->long_count + times;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _pbtn_info->btn->long_count = MFBD_LONG_TIME_IN_FUC - 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- /* MFBD_BTN_STATE_LONG, if(_pbtn_info->btn->state == MFBD_BTN_STATE_LONG) */
|
|
|
- /* we don't support repeat event here.*/
|
|
|
- }
|
|
|
+ else if(MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_DOWN)
|
|
|
+ {
|
|
|
+ if ((MFBD_BTN_IN_FUC->long_count > 0) && (MFBD_BTN_IN_FUC->long_count < (MFBD_LONG_TIME_IN_FUC)))
|
|
|
+ {
|
|
|
+ /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
+ if(((MFBD_LONG_TIME_IN_FUC) - MFBD_BTN_IN_FUC->long_count) > times)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->long_count = MFBD_BTN_IN_FUC->long_count + times;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->long_count = MFBD_LONG_TIME_IN_FUC;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* MFBD_BTN_STATE_LONG, if(MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_LONG) */
|
|
|
+ /* we don't support repeat event here.*/
|
|
|
+ }
|
|
|
#endif /* MFBD_MBTN_MULTICLICK_LONG_EVT */
|
|
|
#else
|
|
|
- else if(_pbtn_info->btn->state == MFBD_BTN_STATE_DOWN)
|
|
|
- {
|
|
|
- if (_pbtn_info->btn->multiclick_state == 0)
|
|
|
- {
|
|
|
- if (((MFBD_LONG_TIME_IN_FUC) > 0) && (_pbtn_info->btn_long_code != 0))
|
|
|
- {
|
|
|
- /* if long_time is 0 or long_code is 0, disable long and repeat check. */
|
|
|
- if (_pbtn_info->btn->long_count < (MFBD_LONG_TIME_IN_FUC))
|
|
|
- {
|
|
|
- if(((MFBD_LONG_TIME_IN_FUC) - 1 - _pbtn_info->btn->long_count) > times)
|
|
|
- {
|
|
|
- _pbtn_info->btn->long_count = _pbtn_info->btn->long_count + times;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _pbtn_info->btn->long_count = MFBD_LONG_TIME_IN_FUC - 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- /* MFBD_BTN_STATE_LONG, if(_pbtn_info->btn->state == MFBD_BTN_STATE_LONG) */
|
|
|
- if (((MFBD_REPEAT_TIME_IN_FUC) > 0) && (_pbtn_info->btn_down_code[0] != 0))
|
|
|
- {
|
|
|
- if(((MFBD_REPEAT_TIME_IN_FUC) - 1 - _pbtn_info->btn->repeat_count) > times)
|
|
|
- {
|
|
|
- _pbtn_info->btn->repeat_count = _pbtn_info->btn->repeat_count + times;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _pbtn_info->btn->repeat_count = MFBD_REPEAT_TIME_IN_FUC - 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ else if(MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_DOWN)
|
|
|
+ {
|
|
|
+ if ((MFBD_BTN_IN_FUC->long_count > 0) && (MFBD_BTN_IN_FUC->long_count < (MFBD_LONG_TIME_IN_FUC)))
|
|
|
+ {
|
|
|
+ if(((MFBD_LONG_TIME_IN_FUC) - MFBD_BTN_IN_FUC->long_count) > times)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->long_count = MFBD_BTN_IN_FUC->long_count + times;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->long_count = MFBD_LONG_TIME_IN_FUC;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ /* MFBD_BTN_STATE_LONG, if(MFBD_BTN_IN_FUC->state == MFBD_BTN_STATE_LONG) */
|
|
|
+ if ((MFBD_BTN_IN_FUC->repeat_count > 0) && (MFBD_BTN_IN_FUC->repeat_count < (MFBD_REPEAT_TIME_IN_FUC)))
|
|
|
+ {
|
|
|
+ if(((MFBD_REPEAT_TIME_IN_FUC) - MFBD_BTN_IN_FUC->repeat_count) > times)
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = MFBD_BTN_IN_FUC->repeat_count + times;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = MFBD_REPEAT_TIME_IN_FUC;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
#endif /* MFBD_MBTN_CONTINUE_LONG_COUNT */
|
|
|
+
|
|
|
_pbtn_info++;
|
|
|
}
|
|
|
}
|
|
|
@@ -685,12 +727,12 @@ void mfbd_mbtn_reset(const mfbd_mbtn_info_t *_pbtn_info_start, const mfbd_mbtn_i
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
- _pbtn_info->btn->filter_count = 0;
|
|
|
- _pbtn_info->btn->long_count = 0;
|
|
|
- _pbtn_info->btn->multiclick_count = 0;
|
|
|
- _pbtn_info->btn->multiclick_state = 0;
|
|
|
- _pbtn_info->btn->repeat_count = 0;
|
|
|
- _pbtn_info->btn->state = MFBD_BTN_STATE_UP;
|
|
|
+ MFBD_BTN_IN_FUC->filter_count = 0;
|
|
|
+ MFBD_BTN_IN_FUC->long_count = 0;
|
|
|
+ MFBD_BTN_IN_FUC->multiclick_count = 0;
|
|
|
+ MFBD_BTN_IN_FUC->multiclick_state = 0;
|
|
|
+ MFBD_BTN_IN_FUC->repeat_count = 0;
|
|
|
+ MFBD_BTN_IN_FUC->state = MFBD_BTN_STATE_UP;
|
|
|
|
|
|
_pbtn_info++;
|
|
|
}
|