Пример #1
0
static void g19_raw_event_process_input(struct hid_device *hdev,
                                        struct gcommon_data *gdata,
                                        u8 *raw_data)
{
	struct input_dev *idev = gdata->input_dev;
	struct ginput_data *input_data = &gdata->input_data;
	int scancode;
	int value;
	int i;
	int mask;

	/*
	 * We'll check for the M* keys being pressed before processing
	 * the remainder of the key data. That way the new keymap will
	 * be loaded if there is a keymap switch.
	 */
	if (unlikely(input_data->keymap_switching)) {
		if (input_data->curkeymap != 0 && raw_data[2] & 0x10)
			ginput_set_keymap_index(gdata, 0);
		else if (input_data->curkeymap != 1 && raw_data[2] & 0x20)
			ginput_set_keymap_index(gdata, 1);
		else if (input_data->curkeymap != 2 && raw_data[2] & 0x40)
			ginput_set_keymap_index(gdata, 2);
	}
	raw_data[3] &= 0xBF; /* bit 6 is always on */

	for (i = 0, mask = 0x01; i < 8; i++, mask <<= 1) {
		/* Keys G1 through G8 */
		scancode = i;
		value = raw_data[1] & mask;
		ginput_handle_key_event(gdata, scancode, value);

		/* Keys G9 through G12, M1 through MR */
		scancode = i + 8;
		value = raw_data[2] & mask;
		ginput_handle_key_event(gdata, scancode, value);

		/* Keys G17 through G22 */
		scancode = i + 16;
		value = raw_data[3] & mask;
		ginput_handle_key_event(gdata, scancode, value);
	}

	input_sync(idev);
}
Пример #2
0
static void g19_ep1_urb_completion(struct urb *urb)
{
	/* don't process unlinked or failed urbs */
	if (likely(urb->status == 0)) {
		struct hid_device *hdev = urb->context;
		struct gcommon_data *gdata = hid_get_gdata(hdev);
		struct g19_data *g19data = gdata->data;
		int i;

		for (i = 0; i < 8; i++)
			ginput_handle_key_event(gdata, 24+i, g19data->ep1keys[0]&(1<<i));

		input_sync(gdata->input_dev);

		usb_submit_urb(urb, GFP_ATOMIC);
	}
}
Пример #3
0
static void g15_raw_event_process_input(struct hid_device *hdev,
					struct gcommon_data *gdata,
					u8 *raw_data)
{
	struct input_dev *idev = gdata->input_dev;
        struct ginput_data *input_data = &gdata->input_data;
	int scancode;
	int value;
	int i;
	int mask;

	/*
	 * We'll check for the M* keys being pressed before processing
	 * the remainder of the key data. That way the new keymap will
	 * be loaded if there is a keymap switch.
	 */
	if (unlikely(input_data->keymap_switching)) {
		if (input_data->curkeymap != 0 && raw_data[5] & 0x01)
			ginput_set_keymap_index(gdata, 0);
		else if (input_data->curkeymap != 1 && raw_data[6] & 0x02)
			ginput_set_keymap_index(gdata, 1);
		else if (input_data->curkeymap != 2 && raw_data[7] & 0x04)
			ginput_set_keymap_index(gdata, 2);
	}

	raw_data[4] &= 0xFE; /* This bit turns on and off at random */

	for (i = 0, mask = 0x01; i < 8; i++, mask <<= 1) {
		scancode = i;
		value = raw_data[1] & mask;
		ginput_handle_key_event(gdata, scancode, value);

		scancode = i + 8;
		value = raw_data[2] & mask;
		ginput_handle_key_event(gdata, scancode, value);

		scancode = i + 16;
		value = raw_data[3] & mask;
		ginput_handle_key_event(gdata, scancode, value);

		scancode = i + 24;
		value = raw_data[4] & mask;
		ginput_handle_key_event(gdata, scancode, value);

		scancode = i + 32;
		value = raw_data[5] & mask;
		ginput_handle_key_event(gdata, scancode, value);

		scancode = i + 40;
		value = raw_data[6] & mask;
		ginput_handle_key_event(gdata, scancode, value);

		scancode = i + 48;
		value = raw_data[7] & mask;
		ginput_handle_key_event(gdata, scancode, value);

		scancode = i + 56;
		value = raw_data[8] & mask;
		ginput_handle_key_event(gdata, scancode, value);
	}

	input_sync(idev);
}