#define REGION_TOP_ATTR_KEYWORD "top"
#define REGION_WIDTH_ATTR_KEYWORD "width"
#define REGION_HEIGHT_ATTR_KEYWORD "height"
+#define KEYCODE_LONGPRESS_ATTR_KEYWORD "longPress"
#define EMULATOR_UI_KEYWORD "EmulatorUI"
#define CONTROLLER_UI_KEYWORD "ControllerUI"
#include "xmllayoutparser.h"
#include "xmllayoutkeyword.h"
#include "skinpainter.h"
+#include "layout/keycodetype.h"
#include "controller/generalpurposecon.h"
/* Qt Qlayout has a minimum size */
return new DisplayType(displayRect, angle, maskImage);
}
+KeycodeType *XmlLayoutParser::parseKeycode(QXmlStreamReader &xml)
+{
+ int longPress = -1, shortPress = 0;
+
+ /* attribute */
+ longPress = xml.attributes().value(KEYCODE_LONGPRESS_ATTR_KEYWORD).toString().toInt();
+
+ shortPress = xml.readElementText().toInt();
+
+ return new KeycodeType(shortPress, longPress);
+}
+
HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml)
{
QRect keyRegion;
- int keycode = 0;
+ KeycodeType *keycodeType = NULL;
QString keyTooptip;
QString keySequence;
keyRegion = parseRegion(xml);
} else if (xml.name() == KEYCODE_KEYWORD) {
/* keycode */
- keycode = xml.readElementText().toInt();
+ keycodeType = parseKeycode(xml);
} else if (xml.name() == TOOLTIP_KEYWORD) {
/* tooltip */
keyTooptip = xml.readElementText();
token = xml.readNext();
}
- return new HardwareKey(keyName, keycode, keyRegion, keyTooptip, keySequence);
+ return new HardwareKey(keyName, keycodeType, keyRegion, keyTooptip, keySequence);
}
int XmlLayoutParser::parseKeyList(
#include <QXmlStreamReader>
#include "uiinformation.h"
+#include "layout/keycodetype.h"
#include "layout/mainform.h"
+#include "layout/controllerform.h"
#include "menu/menuitem.h"
#include "menu/advancedmenuitem.h"
#include "menu/scalemenuitem.h"
-#include "layout/controllerform.h"
+
class XmlLayoutParser
{
HoverType *parseHover(QXmlStreamReader &xml);
QRect parseRegion(QXmlStreamReader &xml);
DisplayType *parseDisplay(QXmlStreamReader &xml);
+ KeycodeType *parseKeycode(QXmlStreamReader &xml);
HardwareKey *parseKey(QXmlStreamReader &xml);
int parseKeyList(QXmlStreamReader &xml, QList<HardwareKey *> &list);
MainForm *parseMainForm(QXmlStreamReader &xml);
*
*/
+#include <QDebug>
+
#include "hwkeybutton.h"
extern "C" {
void HWKeyButton::mousePressEvent(QMouseEvent *event)
{
- qDebug("HW key button pressed : %s", qPrintable(hwKey->name));
+ const int keycode = hwKey->getKeycodeType()->getShortPressKeycode();
- do_hw_key_event(KEY_PRESSED, hwKey->keycode);
+ qDebug() << hwKey->name << "key button pressed:" << keycode;
+ do_hw_key_event(KEY_PRESSED, keycode);
QPushButton::mousePressEvent(event);
}
void HWKeyButton::mouseReleaseEvent(QMouseEvent *event)
{
- qDebug("HW key button released : %s", qPrintable(hwKey->name));
+ const int keycode = hwKey->getKeycodeType()->getShortPressKeycode();
- do_hw_key_event(KEY_RELEASED, hwKey->keycode);
+ qDebug() << hwKey->name << "key button released:" << keycode;
+ do_hw_key_event(KEY_RELEASED, keycode);
QPushButton::mouseReleaseEvent(event);
}
for (index = 0; index < hwKeyList.count(); index++) {
if (hwKeyList.at(index)->name.compare(item) == 0) {
- keyCode = hwKeyList.at(index)->keycode;
+ keyCode = hwKeyList.at(index)->
+ getKeycodeType()->getShortPressKeycode();
break;
}
}
if (index == hwKeyList.count()) {
for (index = 0; index < controllerKeyList.count(); index++) {
if (controllerKeyList.at(index)->name.compare(item) == 0) {
- keyCode = controllerKeyList.at(index)->keycode;
+ keyCode = controllerKeyList.at(index)->
+ getKeycodeType()->getShortPressKeycode();
break;
}
}
obj-$(CONFIG_QT) += controllerform.o
obj-$(CONFIG_QT) += displaytype.o
obj-$(CONFIG_QT) += hardwarekey.o
-obj-$(CONFIG_QT) += hovertype.o
\ No newline at end of file
+obj-$(CONFIG_QT) += hovertype.o
+obj-$(CONFIG_QT) += keycodetype.o
\ No newline at end of file
#include "hardwarekey.h"
-HardwareKey::HardwareKey(QString name, int keycode, QRect region, QString tooltip, QString keySequence)
+HardwareKey::HardwareKey(QString name, KeycodeType *keycodeType,
+ QRect region, QString tooltip, QString keySequence)
{
this->name = name;
- this->keycode = keycode;
+ this->keycodeType = keycodeType;
this->region = region;
this->tooltip = tooltip;
this->keySequence = keySequence;
+
+ if (keycodeType == NULL) {
+ this->keycodeType = new KeycodeType(-1, -1);
+ }
+}
+
+KeycodeType *HardwareKey::getKeycodeType()
+{
+ return keycodeType;
+}
+
+bool HardwareKey::hasLongPressKeycode()
+{
+ return (keycodeType->getLongPressKeycode() > 0);
}
HardwareKey::~HardwareKey()
{
- /* do nothing */
+ if (keycodeType != NULL) {
+ delete keycodeType;
+ }
}
#include <QWidget>
+#include "layout/keycodetype.h"
+
class HardwareKey
{
public:
- HardwareKey(QString name, int keycode, QRect region, QString tooltip, QString keySequence);
+ HardwareKey(QString name, KeycodeType *keycodeType,
+ QRect region, QString tooltip, QString keySequence);
~HardwareKey();
+ KeycodeType *getKeycodeType();
+ bool hasLongPressKeycode();
+
QString name;
- int keycode;
QRect region;
QString tooltip;
QString keySequence;
+
+private:
+ KeycodeType *keycodeType;
};
#endif // HARDWAREKEY_H
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <QDebug>
+
+#include "keycodetype.h"
+
+KeycodeType::KeycodeType(int shortPress)
+{
+ this->shortPress = shortPress;
+ this->longPress = -1;
+}
+
+KeycodeType::KeycodeType(int shortPress, int longPress)
+{
+ this->shortPress = shortPress;
+ this->longPress = longPress;
+}
+
+int KeycodeType::getShortPressKeycode()
+{
+ if (shortPress <= 0) {
+ qWarning() << "invalid short press keycode:" << shortPress;
+ }
+
+ return shortPress;
+}
+
+int KeycodeType::getLongPressKeycode()
+{
+ return longPress;
+}
+
+KeycodeType::~KeycodeType()
+{
+ /* do nothing */
+}
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef KEYCODETYPE_H
+#define KEYCODETYPE_H
+
+#include <QWidget>
+
+class KeycodeType
+{
+public:
+ KeycodeType(int shortPress);
+ KeycodeType(int shortPress, int longPress);
+ ~KeycodeType();
+
+ int getShortPressKeycode();
+ int getLongPressKeycode();
+
+private:
+ int shortPress;
+ int longPress;
+};
+
+#endif // KEYCODETYPE_H
*
*/
+#include <QDebug>
+
#include "skinkeyitem.h"
SkinKeyItem::SkinKeyItem(SkinBezelItem *parent,
{
bezelParent->setHWKeyHandling(isPressed = true);
- if (hwKey->keycode == LONGPRESS_KEYCODE) {
+ if (hwKey->hasLongPressKeycode() == true) {
/* long press checking first */
longPressTimer->start();
return;
}
- qDebug("HW key pressed: %s", qPrintable(hwKey->name));
- do_hw_key_event(KEY_PRESSED, hwKey->keycode);
+ const int keycode = hwKey->getKeycodeType()->getShortPressKeycode();
+
+ qDebug() << hwKey->name << "key pressed:" << keycode;
+ do_hw_key_event(KEY_PRESSED, keycode);
hoverPen.setColor(Qt::transparent);
update();
{
bezelParent->setHWKeyHandling(isPressed = false);
- const int keyCode = hwKey->keycode;
- if (keyCode == LONGPRESS_KEYCODE) {
+ int keycode = hwKey->getKeycodeType()->getShortPressKeycode();
+
+ if (hwKey->hasLongPressKeycode() == true) {
if (longPressTimer->remainingTime() <= 0) {
/* long press */
- qDebug("HW key long pressed : %s", qPrintable(hwKey->name));
+ keycode = hwKey->getKeycodeType()->getLongPressKeycode();
+ qDebug() << hwKey->name << "key long pressed:" << keycode;
} else {
/* short press */
longPressTimer->stop();
- qDebug("HW key short pressed : %s", qPrintable(hwKey->name));
+
+ qDebug() << hwKey->name << "key short pressed:" << keycode;
}
- do_hw_key_event(KEY_PRESSED, keyCode);
+ do_hw_key_event(KEY_PRESSED, keycode);
}
- qDebug("HW key released: %s", qPrintable(hwKey->name));
- do_hw_key_event(KEY_RELEASED, keyCode);
+ qDebug() << hwKey->name << "key released:" << keycode;
+ do_hw_key_event(KEY_RELEASED, keycode);
update();
}
void SkinKeyItem::longPressHook()
{
- qDebug("long press detected");
+ qDebug("key long press detected");
/* do nothing */
}
#include "emul_state.h"
}
-#define LONGPRESS_KEYCODE (-999)
-
class SkinKeyItem : public QObject, public QGraphicsRectItem
{
Q_OBJECT