Exemple #1
0
/**
 * ir_keydown() - generates input event for a key press
 * @dev:        the struct input_dev descriptor of the device
 * @scancode:   the scancode that we're seeking
 * @toggle:     the toggle value (protocol dependent, if the protocol doesn't
 *              support toggle values, this should be set to zero)
 *
 * This routine is used by the input routines when a key is pressed at the
 * IR. It gets the keycode for a scancode and reports an input event via
 * input_report_key().
 */
void ir_keydown(struct input_dev *dev, int scancode, u8 toggle)
{
	unsigned long flags;
	struct ir_input_dev *ir = input_get_drvdata(dev);

	u32 keycode = ir_g_keycode_from_table(dev, scancode);

	spin_lock_irqsave(&ir->keylock, flags);

	input_event(dev, EV_MSC, MSC_SCAN, scancode);

	/* Repeat event? */
	if (ir->keypressed &&
	    ir->last_scancode == scancode &&
	    ir->last_toggle == toggle)
		goto set_timer;

	/* Release old keypress */
	ir_keyup(ir);

	ir->last_scancode = scancode;
	ir->last_toggle = toggle;
	ir->last_keycode = keycode;


	if (keycode == KEY_RESERVED)
		goto out;


	/* Register a keypress */
	ir->keypressed = true;
	IR_dprintk(1, "%s: key down event, key 0x%04x, scancode 0x%04x\n",
		   dev->name, keycode, scancode);
	input_report_key(dev, ir->last_keycode, 1);
	input_sync(dev);

set_timer:
	ir->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT);
	mod_timer(&ir->timer_keyup, ir->keyup_jiffies);
out:
	spin_unlock_irqrestore(&ir->keylock, flags);
}
static irqreturn_t mfld_pb_isr(int irq, void *dev_id)
{
	struct input_dev *input = dev_id;
	int ret;
	u8 pbstat;

	ret = intel_msic_reg_read(INTEL_MSIC_PBSTATUS, &pbstat);
	dev_dbg(input->dev.parent, "PB_INT status= %d\n", pbstat);

	if (ret < 0) {
		dev_err(input->dev.parent, "Read error %d while reading"
			       " MSIC_PB_STATUS\n", ret);
	} else {
		input_event(input, EV_KEY, KEY_POWER,
			       !(pbstat & MSIC_PB_LEVEL));
		input_sync(input);
	}

	return IRQ_HANDLED;
}
static void __pmic8xxx_kp_scan_matrix(struct pmic8xxx_kp *kp, u16 *new_state,
					 u16 *old_state)
{
	int row, col, code;

	for (row = 0; row < kp->pdata->num_rows; row++) {
		int bits_changed = new_state[row] ^ old_state[row];

		if (!bits_changed)
			continue;

		for (col = 0; col < kp->pdata->num_cols; col++) {
			if (!(bits_changed & (1 << col)))
				continue;

#ifndef CONFIG_PRODUCT_SHIP
			printk(KERN_ERR "key [%d:%d] %s\n", row, col,
					!(new_state[row] & (1 << col)) ?
					"pressed" : "released");
#else
			dev_dbg(kp->dev, "key [%d:%d] %s\n", row, col,
					!(new_state[row] & (1 << col)) ?
					"pressed" : "released");
#endif


			code = MATRIX_SCAN_CODE(row, col, PM8XXX_ROW_SHIFT);

			input_event(kp->input, EV_MSC, MSC_SCAN, code);
			input_report_key(kp->input,
					kp->keycodes[code],
					!(new_state[row] & (1 << col)));

			input_sync(kp->input);
#if CONFIG_SEC_DEBUG
			sec_debug_check_crash_key(kp->keycodes[code],
					!(new_state[row] & (1 << col)));
#endif
		}
	}
}
static int __pmic8058_kp_scan_matrix(struct pmic8058_kp *kp, u16 *new_state,
					 u16 *old_state)
{
	int row, col, code;

	for (row = 0; row < kp->pdata->num_rows; row++) {
		int bits_changed = new_state[row] ^ old_state[row];

		if (!bits_changed)
			continue;

		for (col = 0; col < kp->pdata->num_cols; col++) {
			if (!(bits_changed & (1 << col)))
				continue;

			dev_dbg(kp->dev, "key [%d:%d] %s\n", row, col,
					!(new_state[row] & (1 << col)) ?
					"pressed" : "released");

			code = MATRIX_SCAN_CODE(row, col, PM8058_ROW_SHIFT);

/* in order to avoid reporting unvalid codes to input system, we should check the key's value not the index */
/* report the event only if the key is in the map.  */
#ifdef CONFIG_HUAWEI_KERNEL	
            if (kp->keycodes[code])
            {
#endif	
			input_event(kp->input, EV_MSC, MSC_SCAN, code);
			input_report_key(kp->input,
					kp->keycodes[code],
					!(new_state[row] & (1 << col)));

			input_sync(kp->input);
#ifdef CONFIG_HUAWEI_KERNEL		
            }
#endif	
		}
	}

	return 0;
}
static irqreturn_t pmic8058_volume_down_irq(int irq, void *data)
{

	struct pmic8xxx_kp *kp = data;
	static int pre_down_key_state = -1;
	int key_state = 1;
	int code;

	if (!gpio_get_value_cansleep(PM8058_GPIO_PM_TO_SYS(
					PMIC_GPIO_VOLUME_DOWNKEY)))
		key_state = 0;

	code = MATRIX_SCAN_CODE((voldown_matrix>>8),
				(voldown_matrix&0xFF), PM8058_ROW_SHIFT);


	if (pre_down_key_state == key_state && pre_down_key_state != -1 &&
			key_state == 0) {
		key_state = 1;

	#ifndef CONFIG_PRODUCT_SHIP
	printk(KERN_INFO "%s : Fix key state\n", __func__);
	#endif
	}

	pre_down_key_state = key_state;

    #ifndef CONFIG_PRODUCT_SHIP
	printk(KERN_ERR "%s : keycode [%d] %s\n", __func__, kp->keycodes[code],
			!key_state ? "pressed" : "released");
    #endif
	input_event(kp->input, EV_MSC, MSC_SCAN, code);
	input_report_key(kp->input, kp->keycodes[code], !key_state);
	input_sync(kp->input);

#if CONFIG_SEC_DEBUG
	sec_debug_check_crash_key(KEY_VOLUMEDOWN, !key_state);
#endif

	return IRQ_HANDLED;
}
Exemple #6
0
/**
 * input_mt_sync_frame() - synchronize mt frame
 * @dev: input device with allocated MT slots
 *
 * Close the frame and prepare the internal state for a new one.
 * Depending on the flags, marks unused slots as inactive and performs
 * pointer emulation.
 */
void input_mt_sync_frame(struct input_dev *dev)
{
	struct input_mt *mt = dev->mt;
	struct input_mt_slot *s;

	if (!mt)
		return;

	if (mt->flags & INPUT_MT_DROP_UNUSED) {
		for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
			if (input_mt_is_used(mt, s))
				continue;
			input_mt_slot(dev, s - mt->slots);
			input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
		}
	}

	input_mt_report_pointer_emulation(dev, (mt->flags & INPUT_MT_POINTER));

	mt->frame++;
}
static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
{
	struct gpio_button_data *bdata = dev_id;
	const struct gpio_keys_button *button;
	struct input_dev *input;
	unsigned int type;
	int state;

	BUG_ON(!bdata);
	BUG_ON(!bdata->button);
	BUG_ON(irq != bdata->irq);

	button = bdata->button;
	input = bdata->input;
	state = (gpio_keys_getval(button->gpio) ? 1 : 0) ^ button->active_low;

	if (bdata->ddata->force_trigger && !state) {
		type = button->type ?: EV_KEY;
		input_event(input, type, button->code, !state);
		bdata->ddata->force_trigger = 0;
	}
Exemple #8
0
static
void alsa_seqmidi_read(alsa_midi_t *m, jack_nframes_t nframes)
{
	alsa_seqmidi_t *self = (alsa_seqmidi_t*) m;
	int res;
	snd_seq_event_t *event;
	struct process_info info;

	if (!self->keep_walking)
		return;

	set_process_info(&info, self, PORT_INPUT, nframes);
	jack_process(self, &info);

	while ((res = snd_seq_event_input(self->seq, &event))>0) {
		if (event->source.client == SND_SEQ_CLIENT_SYSTEM)
			port_event(self, event);
		else
			input_event(self, event, &info);
	}
}
void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
		      u32 ir_key, u32 ir_raw)
{
	u32 keycode = IR_KEYCODE(ir->ir_codes, ir_key);

	if (ir->keypressed && ir->keycode != keycode) {
		ir->keypressed = 0;
		ir_input_key_event(dev,ir);
	}
	if (!ir->keypressed) {
		ir->ir_key  = ir_key;
		ir->ir_raw  = ir_raw;
		ir->keycode = keycode;
		ir->keypressed = 1;
		ir_input_key_event(dev,ir);
	}
#if 0
	/* maybe do something like this ??? */
	input_event(a, EV_IR, ir->ir_type, ir->ir_raw);
#endif
}
Exemple #10
0
static void wake_presspwr(struct work_struct * wake_presspwr_work) {
	if (!mutex_trylock(&pwrkeyworklock))
                return;
	input_event(wake_pwrdev, EV_KEY, KEY_POWER, 1);
	input_event(wake_pwrdev, EV_SYN, 0, 0);
	msleep(PWRKEY_DUR);
	input_event(wake_pwrdev, EV_KEY, KEY_POWER, 0);
	input_event(wake_pwrdev, EV_SYN, 0, 0);

	msleep(PWRKEY_DUR * 16);
	wakefunc_triggered = true;
	pwrkey_pressed = true;

	input_event(wake_pwrdev, EV_KEY, KEY_POWER, 1);
	input_event(wake_pwrdev, EV_SYN, 0, 0);
	msleep(PWRKEY_DUR);
	input_event(wake_pwrdev, EV_KEY, KEY_POWER, 0);
	input_event(wake_pwrdev, EV_SYN, 0, 0);
	msleep(PWRKEY_DUR);
        mutex_unlock(&pwrkeyworklock);
	
	return;
}
Exemple #11
0
/* Interrupt handler */
static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)
{
	struct omap4_keypad *keypad_data = dev_id;
	struct input_dev *input_dev = keypad_data->input;
	unsigned char key_state[ARRAY_SIZE(keypad_data->key_state)];
	unsigned int col, row, code, changed;
	u32 *new_state = (u32 *) key_state;

	*new_state = __raw_readl(keypad_data->base + OMAP4_KBD_FULLCODE31_0);
	*(new_state + 1) = __raw_readl(keypad_data->base
						+ OMAP4_KBD_FULLCODE63_32);

	for (row = 0; row < keypad_data->rows; row++) {
		changed = key_state[row] ^ keypad_data->key_state[row];
		if (!changed)
			continue;

		for (col = 0; col < keypad_data->cols; col++) {
			if (changed & (1 << col)) {
				code = MATRIX_SCAN_CODE(row, col,
						keypad_data->row_shift);
				input_event(input_dev, EV_MSC, MSC_SCAN, code);
				input_report_key(input_dev,
						 keypad_data->keymap[code],
						 key_state[row] & (1 << col));
			}
		}
	}

	input_sync(input_dev);

	memcpy(keypad_data->key_state, key_state,
		sizeof(keypad_data->key_state));

	/* clear pending interrupts */
	__raw_writel(__raw_readl(keypad_data->base + OMAP4_KBD_IRQSTATUS),
			keypad_data->base + OMAP4_KBD_IRQSTATUS);

	return IRQ_HANDLED;
}
static void ske_keypad_read_data(struct ske_keypad *keypad)
{
	struct input_dev *input = keypad->input;
	u16 status;
	int col = 0, row = 0, code;
	int ske_asr, ske_ris, key_pressed, i;

	/*
	 * Read the auto scan registers
	 *
	 * Each SKE_ASRx (x=0 to x=3) contains two row values.
	 * lower byte contains row value for column 2*x,
	 * upper byte contains row value for column 2*x + 1
	 */
	for (i = 0; i < SKE_NUM_ASRX_REGISTERS; i++) {
		ske_asr = readl(keypad->reg_base + SKE_ASR0 + (4 * i));
		if (!ske_asr)
			continue;

		/* now that ASRx is zero, find out the column x and row y*/
		if (ske_asr & 0xff) {
			col = i * 2;
			status = ske_asr & 0xff;
		} else {
			col = (i * 2) + 1;
			status = (ske_asr & 0xff00) >> 8;
		}

		/* find out the row */
		row = __ffs(status);

		code = MATRIX_SCAN_CODE(row, col, SKE_KEYPAD_ROW_SHIFT);
		ske_ris = readl(keypad->reg_base + SKE_RIS);
		key_pressed = ske_ris & SKE_KPRISA;

		input_event(input, EV_MSC, MSC_SCAN, code);
		input_report_key(input, keypad->keymap[code], key_pressed);
		input_sync(input);
	}
}
static void __pmic8xxx_kp_scan_matrix(struct pmic8xxx_kp *kp, u16 *new_state,
					 u16 *old_state)
{
	int row, col, code;

	for (row = 0; row < kp->pdata->num_rows; row++) {
		int bits_changed = new_state[row] ^ old_state[row];

		if (!bits_changed)
			continue;

		for (col = 0; col < kp->pdata->num_cols; col++) {
			if (!(bits_changed & (1 << col)))
				continue;

			dev_dbg(kp->dev, "key [%d:%d] %s\n", row, col,
					!(new_state[row] & (1 << col)) ?
					"pressed" : "released");
#if defined(CONFIG_MACH_APQ8064_GKKT)||defined(CONFIG_MACH_APQ8064_GKU) || defined(CONFIG_MACH_APQ8064_GKSK)
			if(!row && !col)
				pr_info("[key] Volume Down %s\n",!(new_state[row] & (1 << col)) ? "pressed" : "released");
			else if(!row && col)
				pr_info("[key] Volume Up %s\n",!(new_state[row] & (1 << col)) ? "pressed" : "released");
			else if(row && !col)
				pr_info("[key] Quick Memo %s\n",!(new_state[row] & (1 << col)) ? "pressed" : "released");
			else
				pr_info("[key] Home %s\n",!(new_state[row] & (1 << col)) ? "pressed" : "released");
#endif

			code = MATRIX_SCAN_CODE(row, col, PM8XXX_ROW_SHIFT);

			input_event(kp->input, EV_MSC, MSC_SCAN, code);
			input_report_key(kp->input,
					kp->keycodes[code],
					!(new_state[row] & (1 << col)));

			input_sync(kp->input);
		}
	}
}
static void flip_cover_work(struct work_struct *work)
{
	bool first;
	struct gpio_keys_drvdata *ddata =
		container_of(work, struct gpio_keys_drvdata,
				flip_cover_dwork.work);

	first = gpio_get_value(ddata->gpio_flip_cover);

	printk(KERN_DEBUG "keys:%s #1 : %d\n",
		__func__, first);

	if(ddata->flip_cover != first) {
		ddata->flip_cover = first;
		input_report_switch(ddata->input,
			SW_FLIP, ddata->flip_cover);
		input_sync(ddata->input);
	if (ddata->flip_cover == 0 && cover_pm == 1) {
		pr_info("%s: flip cover closed. Going to sleep ...\n", __func__);
	        input_event(powerkey_device, EV_KEY, KEY_POWER, 1);
	        input_event(powerkey_device, EV_SYN, 0, 0);
	        msleep(100);

	        input_event(powerkey_device, EV_KEY, KEY_POWER, 0);
	        input_event(powerkey_device, EV_SYN, 0, 0);
	}
	if (ddata->flip_cover == 1 && cover_pm == 1) {
		pr_info("%s: flip cover opened. Waking up ...\n", __func__);
	        input_event(powerkey_device, EV_KEY, KEY_POWER, 1);
	        input_event(powerkey_device, EV_SYN, 0, 0);
	        msleep(500);

	        input_event(powerkey_device, EV_KEY, KEY_POWER, 0);
	        input_event(powerkey_device, EV_SYN, 0, 0);
	}
	}
}
int msm_sensors_input_report_value(int event, int code, int value)
{
	switch (event) {

	case EV_ABS:
		input_report_abs(sensors_input_dev, code, value);
		break;

	case EV_REL:
		input_report_rel(sensors_input_dev, code, value);
		break;

	case EV_MSC:
		input_event(sensors_input_dev, EV_MSC, code, value);
		break;

	default:
		return -1;
	}

	return 0;
}
Exemple #16
0
static void virtinput_recv_events(struct virtqueue *vq)
{
	struct virtio_input *vi = vq->vdev->priv;
	struct virtio_input_event *event;
	unsigned long flags;
	unsigned int len;

	spin_lock_irqsave(&vi->lock, flags);
	if (vi->ready) {
		while ((event = virtqueue_get_buf(vi->evt, &len)) != NULL) {
			spin_unlock_irqrestore(&vi->lock, flags);
			input_event(vi->idev,
				    le16_to_cpu(event->type),
				    le16_to_cpu(event->code),
				    le32_to_cpu(event->value));
			spin_lock_irqsave(&vi->lock, flags);
			virtinput_queue_evtbuf(vi, event);
		}
		virtqueue_kick(vq);
	}
	spin_unlock_irqrestore(&vi->lock, flags);
}
Exemple #17
0
static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id)
{
	struct mpr121_touchkey *mpr121 = dev_id;
	struct i2c_client *client = mpr121->client;
	struct input_dev *input = mpr121->input_dev;
	unsigned int key_num, key_val, pressed;
	int reg;

	reg = i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_1_ADDR);
	if (reg < 0) {
		dev_err(&client->dev, "i2c read error [%d]\n", reg);
		goto out;
	}

	reg <<= 8;
	reg |= i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_0_ADDR);
	if (reg < 0) {
		dev_err(&client->dev, "i2c read error [%d]\n", reg);
		goto out;
	}

	reg &= TOUCH_STATUS_MASK;
	/* use old press bit to figure out which bit changed */
	key_num = ffs(reg ^ mpr121->statusbits) - 1;
	pressed = reg & (1 << key_num);
	mpr121->statusbits = reg;

	key_val = mpr121->keycodes[key_num];

	input_event(input, EV_MSC, MSC_SCAN, key_num);
	input_report_key(input, key_val, pressed);
	input_sync(input);

	dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val,
		pressed ? "pressed" : "released");

out:
	return IRQ_HANDLED;
}
static bool samsung_keypad_report(struct samsung_keypad *keypad,
				  unsigned int *row_state)
{
	struct input_dev *input_dev = keypad->input_dev;
	unsigned int changed;
	unsigned int pressed;
	unsigned int key_down = 0;
	unsigned int val;
	unsigned int col, row;

	for (col = 0; col < keypad->cols; col++) {
		changed = row_state[col] ^ keypad->row_state[col];
		key_down |= row_state[col];
		if (!changed)
			continue;

		for (row = 0; row < keypad->rows; row++) {
			if (!(changed & (1 << row)))
				continue;

			pressed = row_state[col] & (1 << row);

			dev_dbg(&keypad->input_dev->dev,
				"key %s, row: %d, col: %d\n",
				pressed ? "pressed" : "released", row, col);

			val = MATRIX_SCAN_CODE(row, col, keypad->row_shift);

			input_event(input_dev, EV_MSC, MSC_SCAN, val);
			input_report_key(input_dev,
					keypad->keycodes[val], pressed);
		}
		input_sync(keypad->input_dev);
	}

	memcpy(keypad->row_state, row_state, sizeof(keypad->row_state));

	return key_down;
}
static void tca6416_keys_work_func(struct work_struct *workstruct)
{
	struct delayed_work *delay_work =
		container_of(workstruct, struct delayed_work, work);
	struct tca6416_keypad_chip *chip =
		container_of(delay_work, struct tca6416_keypad_chip, dwork);
	struct tca6416_drv_data *ddata = chip->drv_data;
	uint16_t reg_val,val;
	int ret,i,pin_index;

	ret = tca6416_read_reg(chip, TCA6416_INPUT, &reg_val);
	reg_val &= chip->pinmask;

	/* Figure out which lines have changed */
	val = reg_val ^ (chip->reg_input );
	chip->reg_input = reg_val;

	for(i=0,pin_index=0; i < 16; i++){
		if ( val & ( 1 << i)  ){
		struct tca6416_button_data * tca_button = &ddata->data[pin_index];
		struct gpio_keys_button * button = tca_button->button;
		struct input_dev *input = tca_button->input;
		unsigned int type = button->type ?: EV_KEY;
		int state = ((reg_val & (1 << i)) ? 1 : 0) ^ button->active_low;

			input_event(input, type, button->code, !!state);
			input_sync(input);
		}

		if(chip->pinmask & (1 << i))
			pin_index++;
	}

	if(chip->use_polling)
		schedule_delayed_work(&chip->dwork, msecs_to_jiffies(100));
	else
		enable_irq(chip->irqnum);

}
static void __pmic8xxx_kp_scan_matrix(struct pmic8xxx_kp *kp, u16 *new_state,
					 u16 *old_state)
{
	int row, col, code;

	for (row = 0; row < kp->pdata->num_rows; row++) {
		int bits_changed = new_state[row] ^ old_state[row];

		if (!bits_changed)
			continue;

		for (col = 0; col < kp->pdata->num_cols; col++) {
			if (!(bits_changed & (1 << col)))
				continue;

			dev_dbg(kp->dev, "key [%d:%d] %s\n", row, col,
					!(new_state[row] & (1 << col)) ?
					"pressed" : "released");

			code = MATRIX_SCAN_CODE(row, col, PM8XXX_ROW_SHIFT);

			/*reduce invalid input event*/
#ifdef CONFIG_HUAWEI_KERNEL	
            if (kp->keycodes[code])
            {
#endif	
				input_event(kp->input, EV_MSC, MSC_SCAN, code);
				input_report_key(kp->input,
						kp->keycodes[code],
						!(new_state[row] & (1 << col)));
				/* use mmi_keystate save the key state */
	       		mmi_keystate[kp->keycodes[code]] = (!(new_state[row]&(1<<col)))? MMI_KEY_DOWN :MMI_KEY_UP ;
				input_sync(kp->input);
#ifdef CONFIG_HUAWEI_KERNEL		
             }
#endif	
		}
	}
}
Exemple #21
0
static void
poll_joystick( int which )
{
  js_data_struct *joystick;
  double position;
  int fire, buttons;
  input_event_t event;
  size_t i;

  joystick = &jsd[which];

  if( JSUpdate( joystick ) != JSGotEvent ) return;

  position = JSGetAxisCoeffNZ( joystick, 0 );
  do_axis( which, position, INPUT_JOYSTICK_LEFT, INPUT_JOYSTICK_RIGHT );

  position = JSGetAxisCoeffNZ( joystick, 1 );
  do_axis( which, position, INPUT_JOYSTICK_UP,   INPUT_JOYSTICK_DOWN  );

  event.types.joystick.which = which;

  buttons = joystick->total_buttons;
  if( buttons > 10 ) buttons = 10;	/* We support 'only' 10 fire buttons */

  for( i = 0; i < buttons; i++ ) {

    fire = JSGetButtonState( joystick, i );
    if( fire == JSButtonStateOn ) {
      event.type = INPUT_EVENT_JOYSTICK_PRESS;
    } else {
      event.type = INPUT_EVENT_JOYSTICK_RELEASE;
    }

    event.types.joystick.button = INPUT_JOYSTICK_FIRE_1 + i;
  }

  input_event( &event );
}
Exemple #22
0
/**
 * sparse_keymap_report_entry - report event corresponding to given key entry
 * @dev: Input device for which event should be reported
 * @ke: key entry describing event
 * @value: Value that should be reported (ignored by %KE_SW entries)
 * @autorelease: Signals whether release event should be emitted for %KE_KEY
 *	entries right after reporting press event, ignored by all other
 *	entries
 *
 * This function is used to report input event described by given
 * &struct key_entry.
 */
void sparse_keymap_report_entry(struct input_dev *dev, const struct key_entry *ke,
				unsigned int value, bool autorelease)
{
	switch (ke->type) {
	case KE_KEY:
		input_event(dev, EV_MSC, MSC_SCAN, ke->code);
		input_report_key(dev, ke->keycode, value);
		input_sync(dev);
		if (value && autorelease) {
			input_report_key(dev, ke->keycode, 0);
			input_sync(dev);
		}
		break;

	case KE_SW:
		value = ke->sw.value;
		/* fall through */

	case KE_VSW:
		input_report_switch(dev, ke->sw.code, value);
		break;
	}
}
Exemple #23
0
static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
{
	struct gpio_button_data *bdata = dev_id;
	struct gpio_keys_button *button;
	struct input_dev *input;
	unsigned int type;
	int state;

	BUG_ON(!bdata);
	pr_info("%s:%d. irq = %d, key_pressed = %d, gpio = %d.\n", __FUNCTION__, __LINE__, bdata->irq, bdata->key_pressed, bdata->button->gpio);

	BUG_ON(!bdata->button);
	BUG_ON(irq != bdata->irq);

	button = bdata->button;
	input = bdata->input;
	state = (gpio_keys_getval(button->gpio) ? 1 : 0) ^ button->active_low;

	if (bdata->ddata->force_trigger && !state) {
		type = button->type ?: EV_KEY;
		input_event(input, type, button->code, !state);
		bdata->ddata->force_trigger = 0;
	}
Exemple #24
0
static int apple_event(struct hid_device *hdev, struct hid_field *field,
		struct hid_usage *usage, __s32 value)
{
	struct apple_sc *asc = hid_get_drvdata(hdev);

	if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
			!usage->type)
		return 0;

	if ((asc->quirks & APPLE_INVERT_HWHEEL) &&
			usage->code == REL_HWHEEL) {
		input_event(field->hidinput->input, usage->type, usage->code,
				-value);
		return 1;
	}

	if ((asc->quirks & APPLE_HAS_FN) &&
			hidinput_apple_event(hdev, field->hidinput->input,
				usage, value))
		return 1;

	return 0;
}
static int icade_event(struct hid_device *hdev, struct hid_field *field,
		struct hid_usage *usage, __s32 value)
{
	const struct icade_key *trans;

	if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
			!usage->type)
		return 0;

	/* We ignore the fake key up, and act only on key down */
	if (!value)
		return 1;

	trans = icade_find_translation(usage->hid & HID_USAGE);

	if (!trans)
		return 1;

	input_event(field->hidinput->input, usage->type,
			trans->to, trans->press);

	return 1;
}
static void gpio_keys_report_event(struct gpio_button_data *bdata)
{
	struct gpio_keys_button *button = bdata->button;
	struct input_dev *input = bdata->input;
	unsigned int type = button->type ?: EV_KEY;
	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;

	GPIOKEYS_INFO("type = %d, code = %d, state = %d\n", type, button->code, state);
	input_event(input, type, button->code, !!state);
	input_sync(input);
	if ((type == EV_SW) && (ASUSGetProjectID() == 102)){
		if (state == 0)
			asusec_close_keyboard();
		else
			asusec_open_keyboard();
	}
	else if ((type == EV_SW) && (ASUSGetProjectID() == 101)){
		if (state == 1){
			GPIOKEYS_INFO("call asusec_dock_resume\n");
				asusec_dock_resume();
		}
	}
}
Exemple #27
0
static void imx_imx_snvs_check_for_events(struct timer_list *t)
{
	struct pwrkey_drv_data *pdata = from_timer(pdata, t, check_timer);
	struct input_dev *input = pdata->input;
	u32 state;

	regmap_read(pdata->snvs, SNVS_HPSR_REG, &state);
	state = state & SNVS_HPSR_BTN ? 1 : 0;

	/* only report new event if status changed */
	if (state ^ pdata->keystate) {
		pdata->keystate = state;
		input_event(input, EV_KEY, pdata->keycode, state);
		input_sync(input);
		pm_relax(pdata->input->dev.parent);
	}

	/* repeat check if pressed long */
	if (state) {
		mod_timer(&pdata->check_timer,
			  jiffies + msecs_to_jiffies(REPEAT_INTERVAL));
	}
}
void
win32joystick_buttonevent( int which_joystick, int button_down,
                           unsigned int wParam )
{
  input_event_t event;
  int button = 0;

 /* FIXME: buttons higher than 4 are not catched through window messages.
    We should use DirectInput. Polling with JoyGetPosEx would take
    up to 8 milliseconds in analog joysticks (digital joysticks just
    a few clock cycles) */
  if( wParam & JOY_BUTTON1CHG ) button = INPUT_JOYSTICK_FIRE_1;
  else if( wParam & JOY_BUTTON2CHG ) button = INPUT_JOYSTICK_FIRE_2;
  else if( wParam & JOY_BUTTON3CHG ) button = INPUT_JOYSTICK_FIRE_3;
  else if( wParam & JOY_BUTTON4CHG ) button = INPUT_JOYSTICK_FIRE_4;
  else return; /* Fuse for Windows supports up to 4 joystick buttons */

  event.types.joystick.which = which_joystick; 
  event.type = button_down
               ? INPUT_EVENT_JOYSTICK_PRESS : INPUT_EVENT_JOYSTICK_RELEASE;
  event.types.joystick.button = button;
  input_event( &event );
}
Exemple #29
0
static irqreturn_t jornada720_kbd_interrupt(int irq, void *dev_id)
{
	struct platform_device *pdev = dev_id;
	struct jornadakbd *jornadakbd = platform_get_drvdata(pdev);
	struct input_dev *input = jornadakbd->input;
	u8 count, kbd_data, scan_code;

	/* startup ssp with spinlock */
	jornada_ssp_start();

	if (jornada_ssp_inout(GETSCANKEYCODE) != TXDUMMY) {
		printk(KERN_DEBUG
			"jornada720_kbd: "
			"GetKeycode command failed with ETIMEDOUT, "
			"flushed bus\n");
	} else {
		/* How many keycodes are waiting for us? */
		count = jornada_ssp_byte(TXDUMMY);

		/* Lets drag them out one at a time */
		while (count--) {
			/* Exchange TxDummy for location (keymap[kbddata]) */
			kbd_data = jornada_ssp_byte(TXDUMMY);
			scan_code = kbd_data & 0x7f;

			input_event(input, EV_MSC, MSC_SCAN, scan_code);
			input_report_key(input, jornadakbd->keymap[scan_code],
					 !(kbd_data & 0x80));
			input_sync(input);
		}
	}

	/* release spinlock and turn off ssp */
	jornada_ssp_end();

	return IRQ_HANDLED;
};
Exemple #30
0
static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
		struct hid_usage *usage, __s32 value)
{
	struct apple_sc *asc = hid_get_drvdata(hid);
	const struct apple_key_translation *trans, *table;

	if (usage->code == KEY_FN) {
		asc->fn_on = !!value;
		input_event(input, usage->type, usage->code, value);
		return 1;
	}

	if (fnmode) {
		int do_translate;

		if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
				hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
			table = macbookair_fn_keys;
		else if (hid->product < 0x21d || hid->product >= 0x300)
			table = powerbook_fn_keys;
		else
			table = apple_fn_keys;

		trans = apple_find_translation (table, usage->code);

		if (trans) {
			if (test_bit(usage->code, asc->pressed_fn))
				do_translate = 1;
			else if (trans->flags & APPLE_FLAG_FKEY)
				do_translate = (fnmode == 2 && asc->fn_on) ||
					(fnmode == 1 && !asc->fn_on);
			else
				do_translate = asc->fn_on;

			if (do_translate) {
				if (value)
					se