Exemplo n.º 1
0
static void update_work_func(struct work_struct *work)
{
	struct kp *kp = container_of(work, struct kp, work_update);
	int i;
	int tmp = 1;
	long int tmpx, tmpy;

#if HOT
	report_hot_key(kp);
#endif

	/*******************************************************************************/
	//report joystick
	if (key_param[0] == 0 || key_param[1] < 0 || key_param[2] < 0) {
		scan_left_joystick(kp);
#if VERTICAL
		js_report(kp, kp->js_value[0], 0); //left
		js_report(kp, kp->js_value[1], 1); //left
#else
		js_report(kp, kp->js_value[1], 0); //left
		js_report(kp, kp->js_value[0], 1); //left
#endif
		input_sync(kp->input_joystick);
	}
	if (key_param[0] == 0) {
		scan_right_joystick(kp);
		js_report(kp, kp->js_value[3], 5); //right
		js_report(kp, kp->js_value[2], 2); //right
		input_sync(kp->input_joystick);
	} else if (key_param[0] == 1 && (key_param[21] < 0 || key_param[22] < 0)) {
		scan_right_joystick(kp);
		js_report(kp, kp->js_value[3], 5); //right
		js_report(kp, kp->js_value[2], 2); //right
		input_sync(kp->input_joystick);
	} else if (key_param[0] == 2 && (key_param[20] < 0 || key_param[21] < 0)) {
		scan_right_joystick(kp);
		js_report(kp, kp->js_value[3], 5); //right
		js_report(kp, kp->js_value[2], 2); //right
		input_sync(kp->input_joystick);
	}
	if (key_param[0] == 0) {
		report_joystick_key(kp);
		input_sync(kp->input_joystick);
	}
	if (key_param[0] == 0) {
		js_report(kp, brake, 3); //brake
		js_report(kp, gas, 4); //gas
#if DPAD_AXIS
		js_report(kp, hatx, 6); //hatx
		js_report(kp, haty, 7); //haty
#endif
		input_sync(kp->input_joystick);
	}
	//end
	/*******************************************************************************/


	/*******************************************************************************/
	//report key mapping
	//left joystick
	if ((key_param[0] == 1 || key_param[0] == 2) && key_param[1] >= 0 && key_param[2] >= 0) {
		scan_left_joystick_touchmapping(kp);
		if ((kp->key_valid[0] == 1) || (kp->key_valid[1] == 1)) {
			kp->stick_flag[0] = 1;
			if(kp->left_center_count < CENTER_TRY) {
				if(kp->left_center_count == 0)
					vtouch_report(kp, key_param[1], key_param[2], 0);
				if(kp->left_center_count == 1)
					vtouch_report(kp, key_param[1] + 1, key_param[2], 0);
				if(kp->left_center_count == 2)
					vtouch_report(kp, key_param[1], key_param[2] + 1, 0);
				if(kp->left_center_count == 3)
					vtouch_report(kp, key_param[1] - 1, key_param[2], 0);
				if(kp->left_center_count == 4)
					vtouch_report(kp, key_param[1], key_param[2] - 1, 0);
				kp->left_center_count++;
			} else {
				tmpx = key_param[1] + (kp->key_value[0] - HALF_ADC_MAX) * (long int)key_param[3] / HALF_ADC_MAX;
				tmpy = key_param[2] + (kp->key_value[1] - HALF_ADC_MAX) * (long int)key_param[3] / HALF_ADC_MAX;
				vtouch_report(kp, tmpx, tmpy, 0);
			}
		} else if (kp->stick_flag[0] == 1) {
			kp->stick_flag[0] = 0;
			kp->left_center_count = 0;
		}
	} else if (key_param[0] == 1 || key_param[0] == 2) {
		kp->stick_flag[0] = 0;
		kp->left_center_count = 0;
	}


	//right joystick
	if (key_param[0] == 1 && key_param[21] >= 0 && key_param[22] >= 0) { //mode 1
		scan_right_joystick_touchmapping(kp);
		if ((kp->key_valid[2] == 1) || (kp->key_valid[3] == 1)) {
			kp->stick_flag[1] = 1;
			if(!kp->right_center_count) {
				vtouch_report(kp, VIEW_CENTREX, VIEW_CENTREY, 1);
				kp->right_center_count = 1;
			} else {
				view_move(kp);
				vtouch_report(kp, kp->key_value[2], kp->key_value[3], 1);
			}
		} else if (kp->stick_flag[1] == 1) {
			kp->stick_flag[1] = 0;
			kp->right_center_count = 0;
			kp->view_oldx = VIEW_CENTREX;
			kp->view_oldy = VIEW_CENTREY;
		}
	} else if (key_param[0] == 2 && key_param[20] >= 0 && key_param[21] >= 0) { //mode 2
		scan_right_joystick_touchmapping(kp);
		if ((kp->key_valid[2] == 1) || (kp->key_valid[3] == 1)) {
			kp->stick_flag[1] = 1;
			if(kp->right_center_count < CENTER_TRY) {
				if(kp->right_center_count == 0)
					vtouch_report(kp, key_param[20], key_param[21], 1);
				if(kp->right_center_count == 1)
					vtouch_report(kp, key_param[20] + 1, key_param[21], 1);
				if(kp->right_center_count == 2)
					vtouch_report(kp, key_param[20], key_param[21] + 1, 1);
				if(kp->right_center_count == 3)
					vtouch_report(kp, key_param[20] - 1, key_param[21], 1);
				if(kp->right_center_count == 4)
					vtouch_report(kp, key_param[20], key_param[21] - 1, 1);
				kp->right_center_count++;
			} else {
				tmpx = key_param[20] +  (kp->key_value[2] - HALF_ADC_MAX) * (long int)key_param[22] / HALF_ADC_MAX;
				tmpy = key_param[21] +  (kp->key_value[3] - HALF_ADC_MAX) * (long int)key_param[22] / HALF_ADC_MAX;
				vtouch_report(kp, tmpx, tmpy, 1);
			}
		} else if (kp->stick_flag[1] == 1) {
			kp->stick_flag[1] = 0;
			kp->right_center_count = 0;
		}
	} else if (key_param[0] == 1 || key_param[0] == 2) {
		kp->stick_flag[1] = 0;
		kp->right_center_count = 0;
	}
	//end
	
	if ((key_param[0] == 1 || key_param[0] == 2)) {
		report_keytouch_key(kp);
		input_sync(kp->input_keytouch);
		if (release && (kp->stick_flag[0] == 0) && (kp->stick_flag[1] ==0)) {
			for (i = 0; i < keynum; i++) {
				tmp = (tmp * gamekeys[i].flag);
			}
			if (tmp)
				keytouch_release(kp);
		}
	}
	/*******************************************************************************/
}
Exemplo n.º 2
0
static void kp_work(struct kp *kp)
{
	int i, code;
	int tmp = 1;


	/*******************************************************************************/
	//add for adc keys(channel 4)
	//report VOL+, VOL-, start, select
	scan_android_key(kp);
	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_joystick, kp->cur_keycode[i], 0);
				kp->cur_keycode[i] = code;
			} else if (kp->cur_keycode_status[i] == 1) {
				//printk("key %d up(force)\n", kp->cur_keycode[i]);
				input_report_key(kp->input_joystick, 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_joystick, code, 1);
				kp->cur_keycode[i] = code;
			}
		}
	}
	//end
	/*******************************************************************************/
	

	/*******************************************************************************/
	//report joystick
	if (key_param[0] == 0 || key_param[1] < 0 || key_param[2] < 0) {
		scan_left_joystick(kp);
		js_report(kp, kp->js_value[2], 0); //left
		js_report(kp, kp->js_value[3], 1); //left
		input_sync(kp->input_joystick);
	}
	if (key_param[0] == 0) {
		scan_right_joystick(kp);
		js_report(kp, kp->js_value[0], 5); //right
		js_report(kp, kp->js_value[1], 2); //right
		input_sync(kp->input_joystick);
	} else if (key_param[0] == 1 && (key_param[21] < 0 || key_param[22] < 0)) {
		scan_right_joystick(kp);
		js_report(kp, kp->js_value[0], 5); //right
		js_report(kp, kp->js_value[1], 2); //right
		input_sync(kp->input_joystick);
	} else if (key_param[0] == 2 && (key_param[20] < 0 || key_param[21] < 0)) {
		scan_right_joystick(kp);
		js_report(kp, kp->js_value[0], 5); //right
		js_report(kp, kp->js_value[1], 2); //right
		input_sync(kp->input_joystick);
	}
	if (key_param[0] == 0) {
		report_joystick_key(kp);
		input_sync(kp->input_joystick);
	}
	//end
	/*******************************************************************************/


	/*******************************************************************************/
	//report key mapping
	//left joystick
	if ((key_param[0] == 1 || key_param[0] == 2) && key_param[1] >= 0 && key_param[2] >= 0) {
		scan_left_joystick_touchmapping(kp);
		if ((kp->key_valid[2] == 1) || (kp->key_valid[3] == 1)) {
			kp->circle_flag[0] = 1;
			if(second0 < CENTER_TRY) {
				if(second0 == 0)
					keytouch_report(kp, key_param[1], key_param[2], 0);
				if(second0 == 1)
					keytouch_report(kp, key_param[1] + 1, key_param[2], 0);
				if(second0 == 2)
					keytouch_report(kp, key_param[1], key_param[2] + 1, 0);
				if(second0 == 3)
					keytouch_report(kp, key_param[1] - 1, key_param[2], 0);
				if(second0 == 4)
					keytouch_report(kp, key_param[1], key_param[2] - 1, 0);
				second0++;
			} else {
				keytouch_report(kp, key_param[1] +  (512 - kp->key_value[2]) * key_param[3] / 512, 
						key_param[2] +  (512 - kp->key_value[3]) * key_param[3] / 512, 0);
			}
		} else if (kp->circle_flag[0] == 1) {
			kp->circle_flag[0] = 0;
			second0 = 0;
		}
	} else if (key_param[0] == 1 || key_param[0] == 2) {
		kp->circle_flag[0] = 0;
		second0 = 0;
	}


	//right joystick
	if (key_param[0] == 1 && key_param[21] >= 0 && key_param[22] >= 0) { //mode 1
		scan_right_joystick_touchmapping(kp);
		if ((kp->key_valid[0] == 1) || (kp->key_valid[1] == 1)) {
			kp->circle_flag[1] = 1;
			if(!second1) {
				keytouch_report(kp, key_param[21], key_param[22], 1);
				second1 = 1;
			} else {
				circle_move(kp);
				keytouch_report(kp, kp->key_value[1], kp->key_value[0], 1);
			}
		} else if (kp->circle_flag[1] == 1) {
			kp->circle_flag[1] = 0;
			second1 = 0;
			kp->old_x = key_param[21];
			kp->old_y = key_param[22];
		}
	} else if (key_param[0] == 2 && key_param[20] >= 0 && key_param[21] >= 0) { //mode 2
		scan_right_joystick_touchmapping(kp);
		if ((kp->key_valid[0] == 1) || (kp->key_valid[1] == 1)) {
			kp->circle_flag[1] = 1;
			if(second1 < CENTER_TRY) {
				if(second1 == 0)
					keytouch_report(kp, key_param[20], key_param[21], 1);
				if(second1 == 1)
					keytouch_report(kp, key_param[20] + 1, key_param[21], 1);
				if(second1 == 2)
					keytouch_report(kp, key_param[20], key_param[21] + 1, 1);
				if(second1 == 3)
					keytouch_report(kp, key_param[20] - 1, key_param[21], 1);
				if(second1 == 4)
					keytouch_report(kp, key_param[20], key_param[21] - 1, 1);
				second1++;
			} else {
				keytouch_report(kp, key_param[20] +  (512 - kp->key_value[1]) * key_param[22] / 512, 
						key_param[21] +  (kp->key_value[0] - 512) * key_param[22] / 512, 1);
			}
		} else if (kp->circle_flag[1] == 1) {
			kp->circle_flag[1] = 0;
			second1 = 0;
		}
	} else if (key_param[0] == 1 || key_param[0] == 2) {
		kp->circle_flag[1] = 0;
		second1 = 0;
	}
	//end
	
	if ((key_param[0] == 1 || key_param[0] == 2)) {
		report_keytouch_key(kp);
		input_sync(kp->input_keytouch);
		if (release && (kp->circle_flag[0] == 0) && (kp->circle_flag[1] ==0)) {
			for (i = 0; i < key_flag_num; i++) {
				tmp = (tmp * gamekeys[i].flag);
			}
			if (tmp)
				keytouch_release(kp);
		}
	}
	/*******************************************************************************/
}