diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-03-21 11:15:16 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-17 23:52:56 -0400 |
commit | 6660de568d164e4eda6617dadcb999c96e62203f (patch) | |
tree | ef86833336b7423443531afa58dc5781b4f97c2a | |
parent | a3572c34da8dacc78a629211a91cf34e9b408701 (diff) |
V4L/DVB: ir-core: add two functions to report keyup/keydown events
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/IR/ir-keytable.c | 57 | ||||
-rw-r--r-- | include/media/ir-core.h | 4 |
2 files changed, 60 insertions, 1 deletions
diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c index 73fe4bec83bc..e59290febf81 100644 --- a/drivers/media/IR/ir-keytable.c +++ b/drivers/media/IR/ir-keytable.c | |||
@@ -365,7 +365,7 @@ static int ir_setkeycode(struct input_dev *dev, | |||
365 | * | 365 | * |
366 | * This routine is used by the input routines when a key is pressed at the | 366 | * This routine is used by the input routines when a key is pressed at the |
367 | * IR. The scancode is received and needs to be converted into a keycode. | 367 | * IR. The scancode is received and needs to be converted into a keycode. |
368 | * If the key is not found, it returns KEY_UNKNOWN. Otherwise, returns the | 368 | * If the key is not found, it returns KEY_RESERVED. Otherwise, returns the |
369 | * corresponding keycode from the table. | 369 | * corresponding keycode from the table. |
370 | */ | 370 | */ |
371 | u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode) | 371 | u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode) |
@@ -392,6 +392,61 @@ u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode) | |||
392 | EXPORT_SYMBOL_GPL(ir_g_keycode_from_table); | 392 | EXPORT_SYMBOL_GPL(ir_g_keycode_from_table); |
393 | 393 | ||
394 | /** | 394 | /** |
395 | * ir_keyup() - generates input event to cleanup a key press | ||
396 | * @input_dev: the struct input_dev descriptor of the device | ||
397 | * | ||
398 | * This routine is used by the input routines when a key is pressed at the | ||
399 | * IR. It reports a keyup input event via input_report_key(). | ||
400 | */ | ||
401 | void ir_keyup(struct input_dev *dev) | ||
402 | { | ||
403 | struct ir_input_dev *ir = input_get_drvdata(dev); | ||
404 | |||
405 | if (!ir->keypressed) | ||
406 | return; | ||
407 | |||
408 | input_report_key(dev, ir->keycode, 0); | ||
409 | input_sync(dev); | ||
410 | ir->keypressed = 0; | ||
411 | } | ||
412 | EXPORT_SYMBOL_GPL(ir_keyup); | ||
413 | |||
414 | /** | ||
415 | * ir_keydown() - generates input event for a key press | ||
416 | * @input_dev: the struct input_dev descriptor of the device | ||
417 | * @scancode: the scancode that we're seeking | ||
418 | * | ||
419 | * This routine is used by the input routines when a key is pressed at the | ||
420 | * IR. It gets the keycode for a scancode and reports an input event via | ||
421 | * input_report_key(). | ||
422 | */ | ||
423 | void ir_keydown(struct input_dev *dev, int scancode) | ||
424 | { | ||
425 | struct ir_input_dev *ir = input_get_drvdata(dev); | ||
426 | |||
427 | u32 keycode = ir_g_keycode_from_table(dev, scancode); | ||
428 | |||
429 | /* If already sent a keydown, do a keyup */ | ||
430 | if (ir->keypressed) | ||
431 | ir_keyup(dev); | ||
432 | |||
433 | if (KEY_RESERVED == keycode) | ||
434 | return; | ||
435 | |||
436 | ir->keycode = keycode; | ||
437 | ir->keypressed = 1; | ||
438 | |||
439 | IR_dprintk(1, "%s: key down event, key 0x%04x, scancode 0x%04x\n", | ||
440 | dev->name, keycode, scancode); | ||
441 | |||
442 | input_report_key(dev, ir->keycode, 1); | ||
443 | input_sync(dev); | ||
444 | |||
445 | } | ||
446 | EXPORT_SYMBOL_GPL(ir_keydown); | ||
447 | |||
448 | |||
449 | /** | ||
395 | * ir_input_register() - sets the IR keycode table and add the handlers | 450 | * ir_input_register() - sets the IR keycode table and add the handlers |
396 | * for keymap table get/set | 451 | * for keymap table get/set |
397 | * @input_dev: the struct input_dev descriptor of the device | 452 | * @input_dev: the struct input_dev descriptor of the device |
diff --git a/include/media/ir-core.h b/include/media/ir-core.h index 369969d90779..198fd61f0da9 100644 --- a/include/media/ir-core.h +++ b/include/media/ir-core.h | |||
@@ -72,6 +72,10 @@ struct ir_input_dev { | |||
72 | unsigned long devno; /* device number */ | 72 | unsigned long devno; /* device number */ |
73 | const struct ir_dev_props *props; /* Device properties */ | 73 | const struct ir_dev_props *props; /* Device properties */ |
74 | struct ir_raw_event_ctrl *raw; /* for raw pulse/space events */ | 74 | struct ir_raw_event_ctrl *raw; /* for raw pulse/space events */ |
75 | |||
76 | /* key info - needed by IR keycode handlers */ | ||
77 | u32 keycode; /* linux key code */ | ||
78 | int keypressed; /* current state */ | ||
75 | }; | 79 | }; |
76 | 80 | ||
77 | #define to_ir_input_dev(_attr) container_of(_attr, struct ir_input_dev, attr) | 81 | #define to_ir_input_dev(_attr) container_of(_attr, struct ir_input_dev, attr) |