看了内核中input_Programming.txt 文档修改了一个按键中断程序。
--------------------------------------------------------------------------
static struct input_dev *button_dev;
static irqreturn_t button_interrupt(int irq ,void *dev_id)
{
input_event(button_dev, EV_KEY, KEY_1, inb(S3C2410_GPG(0)) & 1);
input_sync(button_dev);
//printk( "on--\n"); //测试中断可以进入
return IRQ_HANDLED;
}
static int __init button_init(void)
{
...
if (request_irq(IRQ_EINT8, button_interrupt, IRQ_TYPE_EDGE_BOTH, "inputbutton", button_dev)) {
printk(KERN_ERR "button.c: Can't allocate irq \n");
return -EBUSY;
}
button_dev = input_allocate_device();
if (!button_dev) {
printk(KERN_ERR "button.c: Not enough memory\n");
error = -ENOMEM;
goto err_free_irq;
}
button_dev->evbit[0] = BIT_MASK(EV_KEY);
button_dev->keybit[BIT_WORD(KEY_1)] = BIT_MASK(KEY_1); //事件响应KEY_1 码
button_dev->name = DEVICE_NAME;
button_dev->id.bustype = BUS_RS232;
button_dev->id.vendor = 0xDEED;
button_dev->id.product = 0xBEEF;
button_dev->id.version = 1010;
error = input_register_device(button_dev);
if (error) {
printk(KERN_ERR "button.c: Failed to register device\n");
goto err_free_dev;
}
return 0;
err_free_dev:
input_free_device(button_dev);
err_free_irq:
free_irq(IRQ_EINT8, button_interrupt);
return error;
}
static void __exit button_exit(void)
{
input_unregister_device(button_dev);
free_irq(IRQ_EINT8, button_interrupt);
}
module_init(button_init);
module_exit(button_exit);
--------------------------------------------------------------------------
我使用input_report_key()向input子系统 提交了一个键值码KEY_1(代表数字“2”) 。cat /proc/bus/input/devices 中已经显示
------------------------------------------
I: Bus=0013 Vendor=deed Product=beef Version=03f2
N: Name="Input_button"
P: Phys=
S: Sysfs=/devices/virtual/input/input1
U: Uniq=
H: Handlers=kbd event1
B: EV=3
B: KEY=4
------------------------------------------
但利用cat /dev/input/event1 进行按键测试时显示的是乱码。
请问是不是不能这样捕获键值。
怎样才能正确获得我提交的键值码? 等待。。。。。 |