static void kp_work(struct kp *kp) { int code = kp_search_key(kp); if ((!code) && (!kp->cur_keycode)) { return; } else if (code != kp->tmp_code) { kp->tmp_code = code; kp->count = 0; } else if(++kp->count == 2) { if (kp->cur_keycode != code) { if (code) { printk("key %d down\n", code); input_report_key(kp->input, code, 1); // if (kp->led_control && (code!=KEY_PAGEUP) && (code!=KEY_PAGEDOWN)){ // kp->led_control_param[0] = 1; // kp->led_control_param[1] = code; // timer_count = kp->led_control(kp->led_control_param); // } } else { printk("key %d up\n", kp->cur_keycode); input_report_key(kp->input, kp->cur_keycode, 0); // if (kp->led_control){ // kp->led_control_param[0] = 2; // kp->led_control_param[1] = code; // timer_count = kp->led_control(kp->led_control_param); // } } kp->cur_keycode = code; } } }
static void kp_work(struct kp *kp) { int code = kp_search_key(kp); if (code) { kp->poll_period = POLL_PERIOD_WHEN_KEY_DOWN; } if ((!code) && (!kp->report_code)) { if (kp->poll_period < POLL_PERIOD_WHEN_KEY_UP) kp->poll_period++; return; } else if (code != kp->code) { kp->code = code; kp->count = 0; } else if (kp->count < KEY_JITTER_COUNT) { kp->count++; } else { if (kp->report_code != code) { if (!code) { /* key up */ printk("key %d up\n", kp->report_code); input_report_key(kp->input, kp->report_code, 0); input_sync(kp->input); } else if (!kp->report_code) { /* key down */ printk("key %d down\n", code); input_report_key(kp->input, code, 1); input_sync(kp->input); } else { /* another key down when 1st key still pressing */ printk("key %d up(f)\n", kp->report_code); input_report_key(kp->input, kp->report_code, 0); printk("key %d down(f)\n", code); input_report_key(kp->input, code, 1); input_sync(kp->input); } kp->report_code = code; } } }
static void kp_work(struct kp *kp) { int i, code; kp_search_key(kp); //add for adc keys(channel 4) //start, select i = 4; code = kp->key_code[i]; if ((!code) && (!kp->cur_keycode[i])) { ; } else if (code != kp->tmp_code[i]) { kp->tmp_code[i] = code; kp->count[i] = 0; } else if(++kp->count[i] == 2) { if (kp->cur_keycode[i] != code) { if (!code) { kp->cur_keycode_status[i] = 0; //printk("key %d up\n", kp->cur_keycode[i]); input_report_key(kp->input, kp->cur_keycode[i], 0); kp->cur_keycode[i] = code; } else if (kp->cur_keycode_status[i] == 1) { //printk("--------------------------- error cur = %d new code = %d -------------------------\n", kp->cur_keycode[i], code); //printk("key %d up(force)\n", kp->cur_keycode[i]); input_report_key(kp->input, kp->cur_keycode[i], 0); kp->cur_keycode_status[i] = 0; kp->count[i] = 0; } else { kp->cur_keycode_status[i] = 1; //printk("key %d down\n", code); input_report_key(kp->input, code, 1); kp->cur_keycode[i] = code; } } } //end if (key_param[0]) { //circle 0 if ((kp->key_valid[2] == 1) || (kp->key_valid[3] == 1)) { kp->circle_flag[0] = 1; if(second0 < CENTER_TRY) { if(second0 == 0) key_report(kp, key_param[1], key_param[2], 0); if(second0 == 1) key_report(kp, key_param[1] + 1, key_param[2], 0); if(second0 == 2) key_report(kp, key_param[1], key_param[2] + 1, 0); if(second0 == 3) key_report(kp, key_param[1] - 1, key_param[2], 0); if(second0 == 4) key_report(kp, key_param[1], key_param[2] - 1, 0); second0++; } else { key_report(kp, key_param[1] + (kp->key_value[2] - 512) * key_param[3] / 512, key_param[2] + (kp->key_value[3] - 512) * key_param[3] / 512, 0); } } else if (kp->circle_flag[0] == 1) { kp->circle_flag[0] = 0; second0 = 0; } scan_keys(kp); input_sync(kp->input); if (release && (kp->circle_flag[0] == 0) \ && kp->flaga && kp->flagb && kp->flagx && kp->flagy && kp->flagl && kp->flagr) { release = 0; input_report_key(kp->input, BTN_TOUCH, 0); input_report_abs(kp->input, ABS_MT_TOUCH_MAJOR, 0); input_report_abs(kp->input, ABS_MT_WIDTH_MAJOR, 0); input_mt_sync(kp->input); input_sync(kp->input); //printk("-------------- release all point -----------------\n"); } } else { //left,right,up,down for (i=2; i<kp->chan_num; i++) { code = kp->key_code[i]; if (!code && !kp->cur_keycode[i]) { continue; } else if (code != kp->tmp_code[i]) { kp->tmp_code[i] = code; kp->count[i] = 0; } else if(++kp->count[i] == 2) { if (kp->cur_keycode[i] != code) { if (!code) { kp->cur_keycode_status[i] = 0; //printk("key %d up\n", kp->cur_keycode[i]); input_report_key(kp->input, kp->cur_keycode[i], 0); kp->cur_keycode[i] = code; } else if (kp->cur_keycode_status[i] == 1) { //printk("--------------------------- error cur = %d new code = %d -------------------------\n", kp->cur_keycode[i], code); //printk("key %d up(force)\n", kp->cur_keycode[i]); input_report_key(kp->input, kp->cur_keycode[i], 0); kp->cur_keycode_status[i] = 0; kp->count[i] = 0; } else { kp->cur_keycode_status[i] = 1; //printk("key %d down\n", code); input_report_key(kp->input, code, 1); kp->cur_keycode[i] = code; } } } } scan_keys(kp); input_sync(kp->input); } }