Enables remap of NumpadKeys when Numlock is on and using evkeyboard.

Task-number: QTBUG-32823
Change-Id: I80841a965c61a117e8b50a2775431bb723ca8eca
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
This commit is contained in:
Risto Avila 2014-08-18 11:32:03 +03:00
parent 53eeddf855
commit e5b36bb54e

View File

@ -408,6 +408,53 @@ QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint
#ifdef QT_QPA_KEYMAP_DEBUG
qWarning("Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode & ~modmask, (qtcode & modmask));
#endif
//If NumLockOff and keypad key pressed remap event sent
if (!m_locks[1] &&
(qtcode & Qt::KeypadModifier) &&
keycode >= 71 &&
keycode <= 83 &&
keycode != 74 &&
keycode != 78) {
unicode = 0xffff;
int oldMask = (qtcode & modmask);
switch (keycode) {
case 71: //7 --> Home
qtcode = Qt::Key_Home;
break;
case 72: //8 --> Up
qtcode = Qt::Key_Up;
break;
case 73: //9 --> PgUp
qtcode = Qt::Key_PageUp;
break;
case 75: //4 --> Left
qtcode = Qt::Key_Left;
break;
case 76: //5 --> Clear
qtcode = Qt::Key_Clear;
break;
case 77: //6 --> right
qtcode = Qt::Key_Right;
break;
case 79: //1 --> End
qtcode = Qt::Key_End;
break;
case 80: //2 --> Down
qtcode = Qt::Key_Down;
break;
case 81: //3 --> PgDn
qtcode = Qt::Key_PageDown;
break;
case 82: //0 --> Ins
qtcode = Qt::Key_Insert;
break;
case 83: //, --> Del
qtcode = Qt::Key_Delete;
break;
}
qtcode ^= oldMask;
}
// send the result to the server
processKeyEvent(keycode, unicode, qtcode & ~modmask, Qt::KeyboardModifiers(qtcode & modmask), pressed, autorepeat);
@ -437,6 +484,29 @@ void QEvdevKeyboardHandler::unloadKeymap()
memset(m_locks, 0, sizeof(m_locks));
m_composing = 0;
m_dead_unicode = 0xffff;
//Set locks according to keyboard leds
quint16 ledbits[1];
memset(ledbits, 0, sizeof(ledbits));
if (::ioctl(m_fd, EVIOCGLED(sizeof(ledbits)), ledbits) < 0) {
qWarning("Failed to query led states. Settings numlock & capslock off");
switchLed(LED_NUML,false);
switchLed(LED_CAPSL, false);
switchLed(LED_SCROLLL,false);
} else {
//Capslock
if ((ledbits[0]&0x02) > 0)
m_locks[0] = 1;
//Numlock
if ((ledbits[0]&0x01) > 0)
m_locks[1] = 1;
//Scrollock
if ((ledbits[0]&0x04) > 0)
m_locks[2] = 1;
#ifdef QT_QPA_KEYMAP_DEBUG
qWarning("numlock=%d , capslock=%d, scrolllock=%d",m_locks[1],m_locks[0],m_locks[2]);
#endif
}
}
bool QEvdevKeyboardHandler::loadKeymap(const QString &file)