fix inquire event conflict

pull/8/head
0x1abin 9 years ago
parent bec8586522
commit 13841d0836

@ -80,6 +80,8 @@ void button_handler(struct Button* handle)
handle->ticks = 0; handle->ticks = 0;
handle->repeat = 1; handle->repeat = 1;
handle->state = 1; handle->state = 1;
} else {
handle->event = (uint8_t)NONE_PRESS;
} }
break; break;
@ -103,22 +105,19 @@ void button_handler(struct Button* handle)
EVENT_CB(PRESS_DOWN); EVENT_CB(PRESS_DOWN);
handle->repeat++; handle->repeat++;
if(handle->repeat == 2) { if(handle->repeat == 2) {
handle->event = (uint8_t)DOUBLE_CLICK;
EVENT_CB(DOUBLE_CLICK); // repeat hit EVENT_CB(DOUBLE_CLICK); // repeat hit
} else {
handle->event = (uint8_t)PRESS_REPEAT;
} }
EVENT_CB(PRESS_REPEAT); // repeat hit EVENT_CB(PRESS_REPEAT); // repeat hit
handle->ticks = 0; handle->ticks = 0;
handle->state = 3; handle->state = 3;
} else if(handle->ticks > SHORT_TICKS) { } else if(handle->ticks > SHORT_TICKS) { //released timeout
if(handle->repeat == 1) { if(handle->repeat == 1) {
handle->event = (uint8_t)SINGLE_CLICK; handle->event = (uint8_t)SINGLE_CLICK;
EVENT_CB(SINGLE_CLICK); EVENT_CB(SINGLE_CLICK);
} else if(handle->repeat == 2) {
handle->event = (uint8_t)DOUBLE_CLICK;
} }
handle->state = 0; handle->state = 0;
handle->event = (uint8_t)NONE_PRESS;
} }
break; break;
@ -131,7 +130,6 @@ void button_handler(struct Button* handle)
handle->state = 2; //repeat press handle->state = 2; //repeat press
} else { } else {
handle->state = 0; handle->state = 0;
handle->event = (uint8_t)NONE_PRESS;
} }
} }
break; break;
@ -146,7 +144,6 @@ void button_handler(struct Button* handle)
handle->event = (uint8_t)PRESS_UP; handle->event = (uint8_t)PRESS_UP;
EVENT_CB(PRESS_UP); EVENT_CB(PRESS_UP);
handle->state = 0; //reset handle->state = 0; //reset
handle->event = (uint8_t)NONE_PRESS;
} }
break; break;
} }

Loading…
Cancel
Save