diff options
author | GiWoong Kim <giwoong.kim@samsung.com> | 2015-12-09 14:32:55 +0900 |
---|---|---|
committer | GiWoong Kim <giwoong.kim@samsung.com> | 2015-12-10 11:13:43 +0900 |
commit | 97d3187c29996b5c87cecd6cd04102510884a2b2 (patch) | |
tree | a1292c126d904e3ceb0b4da9d806a9350c51f3b7 /tizen | |
parent | 1ea27884373ee071b9eb382b7d6faf738db7a2b8 (diff) | |
download | qemu-97d3187c29996b5c87cecd6cd04102510884a2b2.tar.gz qemu-97d3187c29996b5c87cecd6cd04102510884a2b2.tar.bz2 qemu-97d3187c29996b5c87cecd6cd04102510884a2b2.zip |
hwkey: add double keycode type handling
According to real target behavior, some HW key buttons must
send a press event one more while long pressing. I named this
type of key called "double keycode key". The double keycode
key has same value for long-press and short-press keycode.
Change-Id: Ie7f227bd0836727b9b6683473dd37308a8309b3d
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
(cherry picked from commit 09ff007b6842731e2b86ba89e2d41faf31406cc6)
Diffstat (limited to 'tizen')
-rw-r--r-- | tizen/src/ui/skinkeyitem.cpp | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/tizen/src/ui/skinkeyitem.cpp b/tizen/src/ui/skinkeyitem.cpp index 6ed7a97ede..8710e6849c 100644 --- a/tizen/src/ui/skinkeyitem.cpp +++ b/tizen/src/ui/skinkeyitem.cpp @@ -37,6 +37,8 @@ extern "C" { #include "util/ui_operations.h" } +#define LONG_PRESS_TIME (1800) + SkinKeyItem::SkinKeyItem(QGraphicsItem *parent, HardwareKey *hwKey, QImage *pressedImg, bool reMasking, HoverType &hover) : QGraphicsRectItem(hwKey->getRect(), parent) @@ -56,7 +58,7 @@ SkinKeyItem::SkinKeyItem(QGraphicsItem *parent, HardwareKey *hwKey, hoverPen.setColor(Qt::transparent); longPressTimer = new QTimer(); - longPressTimer->setInterval(2 * 1000); + longPressTimer->setInterval(LONG_PRESS_TIME); longPressTimer->setSingleShot(true); connect(longPressTimer, SIGNAL(timeout()), this, SLOT(longPressHook())); @@ -82,12 +84,19 @@ void SkinKeyItem::mousePressEvent(QGraphicsSceneMouseEvent *event) target, hwKey->getRect(), LayoutForm::pressed)); } + /* HW key event */ if (hwKey->hasLongPressKeycode() == true) { - qDebug() << "dual key pressed"; - - /* long press checking first */ longPressTimer->start(); - return; + + if (hwKey->getKeycodeType().getLongPressKeycode() == + hwKey->getKeycodeType().getShortPressKeycode()) { /* double keycode key */ + qDebug() << "double key pressed"; + } else { /* dual keycode key */ + qDebug() << "dual key pressed"; + + /* do nothig */ + return; + } } const int keycode = hwKey->getKeycode(); @@ -112,16 +121,27 @@ void SkinKeyItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) const int keycode = hwKey->getKeycode(); if (hwKey->hasLongPressKeycode() == true) { - if (longPressTimer->remainingTime() <= 0) { - /* long press */ - qDebug() << "dual key released"; - return; - } else { - /* short press */ - longPressTimer->stop(); - - qDebug() << hwKey->getName() << "key short pressed:" << keycode; - do_hw_key_event(KEY_PRESSED, keycode); + if (hwKey->getKeycodeType().getLongPressKeycode() == + hwKey->getKeycodeType().getShortPressKeycode()) { /* double keycode key */ + if (longPressTimer->remainingTime() <= 0) { + // long press + qDebug() << "double key released"; + } else { + // short press + longPressTimer->stop(); + } + } else { /* dual keycode key */ + if (longPressTimer->remainingTime() <= 0) { + // long press + qDebug() << "dual key released"; + return; + } else { + // short press + longPressTimer->stop(); + + qDebug() << hwKey->getName() << "key short pressed:" << keycode; + do_hw_key_event(KEY_PRESSED, keycode); + } } } @@ -137,8 +157,12 @@ void SkinKeyItem::longPressHook() const int keycode = hwKey->getKeycodeType().getLongPressKeycode(); qDebug() << hwKey->getName() << "key long pressed:" << keycode; do_hw_key_event(KEY_PRESSED, keycode); - qDebug() << hwKey->getName() << "key released:" << keycode; - do_hw_key_event(KEY_RELEASED, keycode); + + if (hwKey->getKeycodeType().getLongPressKeycode() != + hwKey->getKeycodeType().getShortPressKeycode()) { + qDebug() << hwKey->getName() << "key released:" << keycode; + do_hw_key_event(KEY_RELEASED, keycode); + } } } |