Hello, everyone.
Now I am developing some embedded applications.
For this, I made custom target board based on AM335x SK board.
In this application I use 7 gpio-keys to get user input instead of touchscreen.
These GPIO ports(GPMC_A16 to A22) are asigned to user switches instead of SW1~SW4 on AM335x SK board.
Then I modified kernel source code (arch/arm/mach-omap2/board-am335xevm.c) as follows:
static struct gpio_keys_button am335x_evm_gpio_buttons[] = {
{
.code = KEY_ENTER,
.gpio = GPIO_TO_PIN(1, 20),
.desc = "OK",
},
{
.code = KEY_LEFT,
.gpio = GPIO_TO_PIN(1, 17),
.desc = "LEFT",
},
{
.code = KEY_RIGHT,
.gpio = GPIO_TO_PIN(1, 19),
.desc = "RIGHT",
},
{
.code = KEY_UP,
.gpio = GPIO_TO_PIN(1, 16),
.desc = "UP",
},
{
.code = KEY_DOWN,
.gpio = GPIO_TO_PIN(1, 18),
.desc = "DOWN",
},
{
.code = KEY_HOME,
.gpio = GPIO_TO_PIN(1, 21),
.desc = "HOME",
},
{
.code = KEY_ESC,
.gpio = GPIO_TO_PIN(1, 22),
.desc = "BACK",
},
};
After rebuilding kernel, I identified this GPIO key driver works correctly by using evtest(http://processors.wiki.ti.com/index.php/Evtest) on the target board as follows:
root@am335x-evm:~# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: ti-tsc
/dev/input/event1: gpio-keys
Select the device event number [0-1]: 1
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio-keys"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 1 (KEY_ESC)
Event code 28 (KEY_ENTER)
Event code 102 (KEY_HOME)
Event code 103 (KEY_UP)
Event code 105 (KEY_LEFT)
Event code 106 (KEY_RIGHT)
Event code 108 (KEY_DOWN)
Properties:
Testing ... (interrupt to exit)
Event: time 1372204772.004993, type 1 (EV_KEY), code 105 (KEY_LEFT), value 0
Event: time 1372204772.004993, -------------- SYN_REPORT ------------
Event: time 1372204772.110309, type 1 (EV_KEY), code 105 (KEY_LEFT), value 1
Event: time 1372204772.110309, -------------- SYN_REPORT ------------
Event: time 1372204773.019611, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 0
Event: time 1372204773.019611, -------------- SYN_REPORT ------------
Event: time 1372204773.136554, type 1 (EV_KEY), code 106 (KEY_RIGHT), value 1
Event: time 1372204773.136554, -------------- SYN_REPORT ------------
Event: time 1372204773.722370, type 1 (EV_KEY), code 103 (KEY_UP), value 0
Event: time 1372204773.722400, -------------- SYN_REPORT ------------
Event: time 1372204773.816669, type 1 (EV_KEY), code 103 (KEY_UP), value 1
Event: time 1372204773.816669, -------------- SYN_REPORT ------------
Event: time 1372204774.203052, type 1 (EV_KEY), code 108 (KEY_DOWN), value 0
Event: time 1372204774.203052, -------------- SYN_REPORT ------------
Event: time 1372204774.315692, type 1 (EV_KEY), code 108 (KEY_DOWN), value 1
Event: time 1372204774.315692, -------------- SYN_REPORT ------------
Event: time 1372204774.745197, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0
Event: time 1372204774.745197, -------------- SYN_REPORT ------------
Event: time 1372204774.857288, type 1 (EV_KEY), code 28 (KEY_ENTER), value 1
Event: time 1372204774.857288, -------------- SYN_REPORT ------------
Event: time 1372204775.259052, type 1 (EV_KEY), code 1 (KEY_ESC), value 0
Event: time 1372204775.259052, -------------- SYN_REPORT ------------
Event: time 1372204775.375537, type 1 (EV_KEY), code 1 (KEY_ESC), value 1
Event: time 1372204775.375537, -------------- SYN_REPORT ------------
Event: time 1372204775.791034, type 1 (EV_KEY), code 102 (KEY_HOME), value 0
Event: time 1372204775.791034, -------------- SYN_REPORT ------------
Event: time 1372204775.902301, type 1 (EV_KEY), code 102 (KEY_HOME), value 1
Event: time 1372204775.902301, -------------- SYN_REPORT ------------
I think there is no problem in GPIO device driver, but GPIO key is not working in my QT GUI application on the target board.
(It's working very well on PC environment.)
Simple QT Application code for key test looks as below:
void MainWindow::keyPressEvent(QKeyEvent *event)
{
switch(event->key())
{
case Qt::Key_Return:
case Qt::Key_Enter:
break;
case Qt::Key_Left:
if (index > 0)
{
index--;
update();
repaint();
}
break;
case Qt::Key_Right:
if (index < (MaxButtonNum - 1))
{
index++;
update();
repaint();
}
break;
case Qt::Key_Up:
if (index > ColNum)
{
index -= ColNum;
update();
repaint();
}
break;
....
}
}
This is my question. What should I do to solve this problem?
Please let me have any tips, ideas, information or references.
Thanks in advance.