*
*/
-#include <Qt>
#include <QtWidgets>
#include "keyboardhelper.h"
void KeyboardHelper::autoKeyRelease(void)
{
- while (!this->keyCodeList.isEmpty()) {
- qDebug() << "auto release scancode: " << this->keyCodeList.last();
- do_qt_keyboard_key_event(KEY_RELEASED, this->keyCodeList.last());
- this->keyCodeList.removeLast();
+ while (!keyCodeList.isEmpty()) {
+ qDebug() << "auto release scancode : " << keyCodeList.last();
+
+ do_qt_keyboard_key_event(KEY_RELEASED, keyCodeList.last());
+ keyCodeList.removeLast();
}
#if 0
int KeyboardHelper::keyCodeOperation(QKeyEvent *event, int keyCode)
{
/* keypad and specialKey translation */
- if (!this->numLockState && (event->modifiers() == (Qt::KeypadModifier | Qt::ShiftModifier))) {
- QMap<int, int>::iterator keypadIter = this->keypadMap.find(keyCode);
- while (keypadIter != this->keypadMap.end()) {
+ if (!numLockState && (event->modifiers() == (Qt::KeypadModifier | Qt::ShiftModifier))) {
+ QMap<int, int>::iterator keypadIter = keypadMap.find(keyCode);
+ while (keypadIter != keypadMap.end()) {
if (keypadIter.key() == keyCode) {
keyCode = keypadIter.value();
break;
}
}
- if (this->isSpecialKey(keyCode)) {
+ if (isSpecialKey(keyCode)) {
virtio_keyboard_event(224);
}
- QMap<int, int>::iterator keyMapIter = this->keyMap.find(keyCode);
- while (keyMapIter != this->keyMap.end()) {
+ QMap<int, int>::iterator keyMapIter = keyMap.find(keyCode);
+ while (keyMapIter != keyMap.end()) {
if (keyMapIter.key() == keyCode) {
break;
}
}
- if (keyMapIter == this->keyMap.end()) {
- qDebug() << "unsupported keycode pressed: " << keyCode;
+ if (keyMapIter == keyMap.end()) {
+ qWarning() << "unsupported keycode pressed : " << keyCode;
return -1;
}
void KeyboardHelper::keyPressed(QKeyEvent *event)
{
int keyCode = event->key();
- qDebug() << "key pressed :" << event->key() << event->text() << event->nativeScanCode() << event->modifiers() << event->nativeModifiers();
+ qDebug() << "key pressed :" << event->key() << event->text() <<
+ event->nativeScanCode() << event->modifiers() << event->nativeModifiers();
#if 0
/* TODO: multi-touch */
if (get_emul_max_touch_point() > 1) {
/* multi-touch checking */
- if (event->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)) {
+ if (event->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) {
get_emul_multi_touch_state()->multitouch_enable = 2;
/* add a finger before start the multi-touch processing
if already exist the pressed touch in display */
+
qDebug() << "enable multi-touch = mode 2";
} else if (event->modifiers() == Qt::ShiftModifier ||
event->modifiers() == Qt::ControlModifier) {
get_emul_multi_touch_state()->multitouch_enable = 1;
+
qDebug() << "enable multi-touch = mode 1";
}
}
if (keyCode == Qt::Key_NumLock) {
#ifdef CONFIG_WIN32
if (event->nativeModifiers() == 0x1000200) {
- this->numLockState = ON;
+ numLockState = ON;
} else if (event->nativeModifiers() == 0x1000000) {
- this->numLockState = OFF;
+ numLockState = OFF;
}
#else
if (event->nativeModifiers() == 0) {
- this->numLockState = ON;
+ numLockState = ON;
} else if (event->nativeModifiers() == 16) {
- this->numLockState = OFF;
+ numLockState = OFF;
}
#endif
- qDebug() << "num_lock state: " << this->numLockState << "pressed";
+ qDebug() << "num_lock state : " << numLockState << "pressed";
return;
} else if (keyCode == Qt::Key_CapsLock) {
#ifdef CONFIG_WIN32
if (event->nativeModifiers() == 256) {
- this->capsLockState = ON;
+ capsLockState = ON;
} else if (event->nativeModifiers() == 0) {
- this->capsLockState = OFF;
+ capsLockState = OFF;
}
#else
if (event->nativeModifiers() == 18) {
- this->capsLockState = ON;
+ capsLockState = ON;
} else if (event->nativeModifiers() == 16) {
- this->capsLockState = OFF;
+ capsLockState = OFF;
}
#endif
- qDebug() << "caps_lock state: " << this->capsLockState << "pressed";
+ qDebug() << "caps_lock state : " << capsLockState << "pressed";
return;
}
- /* host numlock check for sync */
+ /* host NumLock check for sync */
if ((event->modifiers() & Qt::KeypadModifier)) {
- if (this->isSpecialKey(keyCode) || keyCode == Qt::Key_Clear) {
+ if (isSpecialKey(keyCode) || keyCode == Qt::Key_Clear) {
if (!(event->modifiers() & Qt::ShiftModifier)) {
- this->numLockState = OFF;
+ numLockState = OFF;
} else {
- this->numLockState = ON;
+ numLockState = ON;
}
} else {
- if (!(event->modifiers() & Qt::ShiftModifier || keyCode == 42 || keyCode == 43 || keyCode == 45 || keyCode == 47)) { /* (42 = *, 43 = +, 45 = -, 47 = /) on keypad */
- this->numLockState = ON;
+ if (!((event->modifiers() & Qt::ShiftModifier) ||
+ keyCode == 42 || keyCode == 43 || keyCode == 45 || keyCode == 47))
+ { /* (42 = *, 43 = +, 45 = -, 47 = /) on keypad */
+ numLockState = ON;
} else {
- this->numLockState = OFF;
+ numLockState = OFF;
}
}
}
+
if (event->key() >= 65 && event->key() <= 90) {
#ifdef CONFIG_WIN32
if (event->nativeModifiers() & 256) {
#else
if (event->nativeModifiers() & 0x02) {
#endif
- this->capsLockState = ON;
+ capsLockState = ON;
} else {
- this->capsLockState = OFF;
+ capsLockState = OFF;
}
}
- if (get_emul_caps_lock_state() != this->capsLockState) {
+ if (get_emul_caps_lock_state() != capsLockState) {
virtio_keyboard_event(58);
virtio_keyboard_event(58 | 0x80);
set_emul_caps_lock_state(get_emul_caps_lock_state() ^ 1);
+
qDebug() << "qemu CapsLock state was synchronized with host key value (" <<
get_emul_caps_lock_state() << ")";
}
- if (get_emul_num_lock_state() != this->numLockState) {
+ if (get_emul_num_lock_state() != numLockState) {
virtio_keyboard_event(69);
virtio_keyboard_event(69 | 0x80);
set_emul_num_lock_state(get_emul_num_lock_state() ^ 1);
+
qDebug() << "qemu NumLock state was synchronized with host key value (" <<
get_emul_num_lock_state() << ")";
}
- int ret = this->keyCodeOperation(event, keyCode);
+ int ret = keyCodeOperation(event, keyCode);
if (ret != -1) {
/* for auto release */
- this->keyCodeList.append(ret);
+ keyCodeList.append(ret);
do_qt_keyboard_key_event(KEY_PRESSED, ret);
}
}
void KeyboardHelper::keyReleased(QKeyEvent *event)
{
int keyCode = event->key();
- qDebug() << "key released :" << event->key() << event->text() << event->nativeScanCode() << event->modifiers() << event->nativeModifiers();
+ qDebug() << "key released :" << event->key() << event->text() <<
+ event->nativeScanCode() << event->modifiers() << event->nativeModifiers();
#if 0
/* TODO: multi-touch */
if (event->key() == Qt::Key_Shift && event->modifiers() == Qt::ControlModifier) {
get_emul_multi_touch_state()->multitouch_enable = 1;
+
qDebug() << "enabled multi-touch = mode 1";
} else if (event->key() == Qt::Key_Shift || event->key() == Qt::Key_Control) {
clear_finger_slot(false);
+
qDebug() << "disable multi-touch";
}
#endif
if (keyCode == Qt::Key_NumLock) {
- qDebug() << "num_lock state: " << this->numLockState << "released";
+ qDebug() << "num_lock state : " << numLockState << "released";
return;
} else if (keyCode == Qt::Key_CapsLock) {
- qDebug() << "caps_lock state: " << this->capsLockState << "released";
+ qDebug() << "caps_lock state : " << capsLockState << "released";
return;
}
#ifdef CONFIG_LINUX
/* for keypad keycode translation */
- if (this->numLockState && event->modifiers() == Qt::KeypadModifier) {
- if (this->isSpecialKey(keyCode) || keyCode == Qt::Key_Clear) {
+ if (numLockState && event->modifiers() == Qt::KeypadModifier) {
+ if (isSpecialKey(keyCode) || keyCode == Qt::Key_Clear) {
switch(keyCode) {
case Qt::Key_Delete:
keyCode = 46; /* . */
}
#endif
- int ret = this->keyCodeOperation(event, keyCode);
+ int ret = keyCodeOperation(event, keyCode);
if (ret != -1) {
do_qt_keyboard_key_event(KEY_RELEASED, ret);
/* remove keycode from list */
- this->keyCodeList.removeOne(ret);
+ keyCodeList.removeOne(ret);
}
}
if (uiInfo->getMainForm()->keyList.count() > 0) {
hwKeyList = uiInfo->getMainForm()->keyList;
} else if (uiInfo->getMainForm()->keyList.count() == 0) {
- qDebug() << "hwKey is not exist";
+ qWarning() << "hwKey is not exist";
return;
} else {
- qDebug() << "hwKeyList is not exist";
+ qWarning() << "hwKeyList is not exist";
return;
}
} else {
- qDebug() << "uiInfo->getMainForm() is NULL";
+ qWarning() << "uiInfo->getMainForm() is NULL";
}
} else {
- qDebug() << "uiInfo is NULL";
+ qWarning() << "uiInfo is NULL";
return;
}
QList<QAction *> switchList = parent->getPopupMenu()->switchGroup->actions();
if (!action) {
- qDebug() << "switch prev failed.";
+ qWarning() << "switch prev failed.";
return;
}
QList<QAction *> switchList = parent->getPopupMenu()->switchGroup->actions();
if (!action) {
- qDebug() << "switch next failed.";
+ qWarning() << "switch next failed.";
return;
}
QList<QAction *> scaleList = parent->getPopupMenu()->scaleGroup->actions();
if (!action) {
- qDebug() << "scale next failed.";
+ qWarning() << "scale next failed.";
return;
}
QList<QAction *> scaleList = parent->getPopupMenu()->scaleGroup->actions();
if (!action) {
- qDebug() << "scale prev failed.";
+ qWarning() << "scale prev failed.";
return;
}
QList<QAction *> controllerList = parent->getPopupMenu()->controllerGroup->actions();
if (!action) {
- qDebug() << "change controller failed.";
+ qWarning() << "change controller failed.";
return;
}
QAction *nextControllerAction = controllerList.at(index);
if (!nextControllerAction) {
- qDebug() << "controllerList.at(" << index << ") is NULL";
+ qWarning() << "controllerList.at(" << index << ") is NULL";
return;
}
QList<QAction *> keyboardStatusList = parent->getPopupMenu()->keyboardGroup->actions();
if (!action) {
- qDebug() << "HostKeyboard enable/disable failed";
+ qWarning() << "HostKeyboard enable/disable failed";
return;
}
}
if (index == hwKeyList.count()) {
- qDebug() << item << "is not exist in KeyList";
+ qWarning() << item << "is not exist in KeyList";
}
return keyCode;