static int ui_key_repeater(void *arg) { uint16_t last_key = keyp; uint8_t cnt = 0; for(;;) { if ((keyp == KEY_ERROR || (last_key != keyp))) { thread_exit(0); return 0; } else { thread_sleep(10); cnt++; if(cnt > 50) { cnt=0; break; } } } while((keyp != KEY_ERROR) && (last_key == keyp) && (keys_get_state(keys[keyp])!=0)) { ui_handle_keydown(); thread_sleep(100); } thread_exit(0); return 0; }
int ui_key_listener_thread(void *arg) { for (;;) { for(uint16_t i = 0; i < sizeof(keys)/sizeof(uint16_t); i++) { if (keys_get_state(keys[i]) != 0) { keyp = i; ui_handle_keydown(); thread_resume(thread_create("ui_key_repeater", &ui_key_repeater, NULL, DEFAULT_PRIORITY, 4096)); while (keys_get_state(keys[keyp]) !=0) thread_sleep(1); ui_handle_keyup(); keyp = KEY_ERROR; } } } thread_exit(0); return 0; }
void target_init(void) { struct flash_info *flash_info; unsigned start_block; unsigned blocks_per_plen = 1; //blocks per partition length unsigned nand_num_blocks; keys_init(); keypad_init(); uint16_t keys[] = {KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_SOFT1, KEY_SEND, KEY_CLEAR, KEY_BACK, KEY_HOME}; for(unsigned i=0; i< sizeof(keys)/sizeof(uint16_t); i++) if (keys_get_state(keys[i]) != 0) { display_init(); display_lk_version(); //dprintf(ALWAYS,"key %d pressed\n", i); break; } dprintf(INFO, "htcleo_init\n"); if(get_boot_reason()==2) // booting for offmode charging, start recovery so kernel will charge phone { boot_into_recovery = 1; //dprintf(INFO, "reboot needed... \n"); //reboot(0); } dprintf(ALWAYS, "load address %x\n", load_address); dprintf(INFO, "flash init\n"); flash_init(); flash_info = flash_get_info(); ASSERT(flash_info); ASSERT(flash_info->num_blocks); nand_num_blocks = flash_info->num_blocks; ptable_init(&flash_ptable); if( strcmp(board_part_list[0].name,"PTABLE-BLK")==0 ) blocks_per_plen =1 ; else if( strcmp(board_part_list[0].name,"PTABLE-MB")==0 ) blocks_per_plen = (1024*1024)/flash_info->block_size; else panic("Invalid partition table\n"); start_block = HTCLEO_FLASH_OFFSET; for (unsigned i = 1; i < num_parts; i++) { struct ptentry *ptn = &board_part_list[i]; if( IS_PART_EMPTY(ptn) ) break; int len = ((ptn->length) * blocks_per_plen); if( ptn->start == 0 ) ptn->start = start_block; else if( ptn->start < start_block) panic("Partition %s start %x < %x\n", ptn->name, ptn->start, start_block); if(ptn->length == 0) { unsigned length_for_prt = 0; if( i<num_parts && !IS_PART_EMPTY((&board_part_list[i+1])) && board_part_list[i+1].start!=0) { length_for_prt = board_part_list[i+1].start - ptn->start; } else { for (unsigned j = i+1; j < num_parts; j++) { struct ptentry *temp_ptn = &board_part_list[j]; if( IS_PART_EMPTY(temp_ptn) ) break; if( temp_ptn->length==0 ) panic("partition %s and %s have variable length\n", ptn->name, temp_ptn->name); length_for_prt += ((temp_ptn->length) * blocks_per_plen); } } len = (nand_num_blocks - 1 - 186 - 4) - (ptn->start + length_for_prt); ASSERT(len >= 0); } start_block = ptn->start + len; ptable_add(&flash_ptable, ptn->name, ptn->start, len, ptn->flags, TYPE_APPS_PARTITION, PERM_WRITEABLE); } htcleo_ptable_dump(&flash_ptable); flash_set_ptable(&flash_ptable); }