工厂模式下按侧键上下键很容易按一下跳2下
工厂模式的话,没有区分按键的down和up,所以修改的话,要先保存此次按键的键值,然后只做一次加或者减的动作。
int longpressed = 0;
int pre_key=KEY_RESERVED;
LOGD(TAG "%s %p\n", __FUNCTION__, iv);
ui_clear_key_queue();
itemview_start_menu(iv, selected);
itemview_redraw(iv);
while (chosen_item < 0 && !exit) {
if (key==BTN_TOUCH || !ui_key_pressed(key) || !longpressed) {
key = ui_wait_key();
count = 10;
pre_key=KEY_RESERVED;
longpressed = 0;
}
switch (key) {
case UI_KEY_BACK:
LOGD(TAG "KEY:BACK\n");
exit = true;
break;
case UI_KEY_UP:
case UI_KEY_VOLUP:
LOGD(TAG "KEY:UP\n");
if(pre_key !=key)
{
pre_key = key;
--selected;
selected = itemview_menu_select(iv, selected);
}
break;
case UI_KEY_DOWN:
case UI_KEY_VOLDOWN:
LOGD(TAG "KEYOWN\n");
if((pre_key !=key))
{
pre_key = key;
++selected;
selected = itemview_menu_select(iv, selected);
}
break;
C:\Documents and Settings\Administrator\桌面
修改如图片所示就OK了,驱动木问题,是factory的调用上需要延时下