From 4493b90224f575e5570afeb1ec181be5c4e74b09 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Tue, 2 Feb 2021 12:23:23 +0200 Subject: Android: fix compiler warnings for Android input QPointingDevice requires using the constructor to set its settings in Qt 6. Replace + with | operator and return QKeyCombination instead of int. Change-Id: Id3da469cc13b34ec7b55afa751dbc04601880df6 Reviewed-by: Volker Hilsheimer --- src/plugins/platforms/android/androidjniinput.cpp | 64 ++++++++++++----------- 1 file changed, 33 insertions(+), 31 deletions(-) (limited to 'src/plugins/platforms/android/androidjniinput.cpp') diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index a72682dd23..1de25b2857 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -274,13 +274,15 @@ namespace QtAndroidInput return; QPointingDevice *touchDevice = platformIntegration->touchDevice(); - if (touchDevice == 0) { - touchDevice = new QPointingDevice; // TODO fill out the constructor args - touchDevice->setType(QInputDevice::DeviceType::TouchScreen); - touchDevice->setCapabilities(QPointingDevice::Capability::Position - | QPointingDevice::Capability::Area - | QPointingDevice::Capability::Pressure - | QPointingDevice::Capability::NormalizedPosition); + if (!touchDevice) { + touchDevice = new QPointingDevice("Android touchscreen", 1, + QInputDevice::DeviceType::TouchScreen, + QPointingDevice::PointerType::Finger, + QPointingDevice::Capability::Position + | QPointingDevice::Capability::Area + | QPointingDevice::Capability::Pressure + | QPointingDevice::Capability::NormalizedPosition, + 10, 0); QWindowSystemInterface::registerInputDevice(touchDevice); platformIntegration->setTouchDevice(touchDevice); } @@ -346,23 +348,23 @@ namespace QtAndroidInput #endif // QT_CONFIG(tabletevent) } - static int mapAndroidKey(int key) + static QKeyCombination mapAndroidKey(int key) { // 0--9 0x00000007 -- 0x00000010 if (key >= 0x00000007 && key <= 0x00000010) - return Qt::Key_0 + key - 0x00000007; + return QKeyCombination::fromCombined(Qt::Key_0 + key - 0x00000007); // A--Z 0x0000001d -- 0x00000036 if (key >= 0x0000001d && key <= 0x00000036) - return Qt::Key_A + key - 0x0000001d; + return QKeyCombination::fromCombined(Qt::Key_A + key - 0x0000001d); // F1--F12 0x00000083 -- 0x0000008e if (key >= 0x00000083 && key <= 0x0000008e) - return Qt::Key_F1 + key - 0x00000083; + return QKeyCombination::fromCombined(Qt::Key_F1 + key - 0x00000083); // NUMPAD_0--NUMPAD_9 0x00000090 -- 0x00000099 if (key >= 0x00000090 && key <= 0x00000099) - return Qt::KeypadModifier + Qt::Key_0 + key - 0x00000090; + return QKeyCombination::fromCombined(Qt::KeypadModifier | Qt::Key_0 + key - 0x00000090); // BUTTON_1--KEYCODE_BUTTON_16 0x000000bc -- 0x000000cb @@ -496,7 +498,7 @@ namespace QtAndroidInput return Qt::Key_Alt; case 0x0000004f: // KEYCODE_HEADSETHOOK - return 0; + return QKeyCombination::fromCombined(0); case 0x00000050: // KEYCODE_FOCUS return Qt::Key_CameraFocus; @@ -508,7 +510,7 @@ namespace QtAndroidInput return Qt::Key_Menu; case 0x00000053: // KEYCODE_NOTIFICATION - return 0; + return QKeyCombination::fromCombined(0); case 0x00000054: // KEYCODE_SEARCH return Qt::Key_Search; @@ -541,7 +543,7 @@ namespace QtAndroidInput return Qt::Key_PageDown; case 0x0000005e: // KEYCODE_PICTSYMBOLS - return 0; + return QKeyCombination::fromCombined(0); case 0x00000060: // KEYCODE_BUTTON_A case 0x00000061: // KEYCODE_BUTTON_B @@ -558,7 +560,7 @@ namespace QtAndroidInput case 0x0000006c: // KEYCODE_BUTTON_START case 0x0000006d: // KEYCODE_BUTTON_SELECT case 0x0000006e: // KEYCODE_BUTTON_MODE - return 0; + return QKeyCombination::fromCombined(0); case 0x0000006f: // KEYCODE_ESCAPE return Qt::Key_Escape; @@ -581,7 +583,7 @@ namespace QtAndroidInput return Qt::Key_Meta; case 0x00000077: // KEYCODE_FUNCTION - return 0; + return QKeyCombination::fromCombined(0); case 0x00000078: // KEYCODE_SYSRQ return Qt::Key_Print; @@ -622,28 +624,28 @@ namespace QtAndroidInput // NUMPAD_0--NUMPAD_9 0x00000090 -- 0x00000099 case 0x0000009a: // KEYCODE_NUMPAD_DIVIDE - return Qt::KeypadModifier + Qt::Key_Slash; + return Qt::KeypadModifier | Qt::Key_Slash; case 0x0000009b: // KEYCODE_NUMPAD_MULTIPLY - return Qt::KeypadModifier + Qt::Key_Asterisk; + return Qt::KeypadModifier | Qt::Key_Asterisk; case 0x0000009c: // KEYCODE_NUMPAD_SUBTRACT - return Qt::KeypadModifier + Qt::Key_Minus; + return Qt::KeypadModifier | Qt::Key_Minus; case 0x0000009d: // KEYCODE_NUMPAD_ADD - return Qt::KeypadModifier + Qt::Key_Plus; + return Qt::KeypadModifier | Qt::Key_Plus; case 0x0000009e: // KEYCODE_NUMPAD_DOT - return Qt::KeypadModifier + Qt::Key_Period; + return Qt::KeypadModifier | Qt::Key_Period; case 0x0000009f: // KEYCODE_NUMPAD_COMMA - return Qt::KeypadModifier + Qt::Key_Comma; + return Qt::KeypadModifier | Qt::Key_Comma; case 0x000000a0: // KEYCODE_NUMPAD_ENTER return Qt::Key_Enter; case 0x000000a1: // KEYCODE_NUMPAD_EQUALS - return Qt::KeypadModifier + Qt::Key_Equal; + return Qt::KeypadModifier | Qt::Key_Equal; case 0x000000a2: // KEYCODE_NUMPAD_LEFT_PAREN return Qt::Key_ParenLeft; @@ -671,13 +673,13 @@ namespace QtAndroidInput case 0x000000aa: // KEYCODE_TV case 0x000000ab: // KEYCODE_WINDOW - return 0; + return QKeyCombination::fromCombined(0); case 0x000000ac: // KEYCODE_GUIDE return Qt::Key_Guide; case 0x000000ad: // KEYCODE_DVR - return 0; + return QKeyCombination::fromCombined(0); case 0x000000ae: // KEYCODE_BOOKMARK return Qt::Key_AddFavorite; @@ -694,7 +696,7 @@ namespace QtAndroidInput case 0x000000b4: // KEYCODE_STB_INPUT case 0x000000b5: // KEYCODE_AVR_POWER case 0x000000b6: // KEYCODE_AVR_INPUT - return 0; + return QKeyCombination::fromCombined(0); case 0x000000b7: // KEYCODE_PROG_RED return Qt::Key_Red; @@ -716,7 +718,7 @@ namespace QtAndroidInput case 0x000000cd: // KEYCODE_MANNER_MODE do we need such a thing? case 0x000000ce: // KEYCODE_3D_MODE case 0x000000cf: // KEYCODE_CONTACTS - return 0; + return QKeyCombination::fromCombined(0); case 0x000000d0: // KEYCODE_CALENDAR return Qt::Key_Calendar; @@ -742,7 +744,7 @@ namespace QtAndroidInput default: qWarning() << "Unhandled key code " << key << '!'; - return 0; + return QKeyCombination::fromCombined(0); } } @@ -775,7 +777,7 @@ namespace QtAndroidInput { QWindowSystemInterface::handleKeyEvent(0, QEvent::KeyPress, - mapAndroidKey(key), + mapAndroidKey(key).toCombined(), mapAndroidModifiers(modifier), toString(unicode), autoRepeat); @@ -785,7 +787,7 @@ namespace QtAndroidInput { QWindowSystemInterface::handleKeyEvent(0, QEvent::KeyRelease, - mapAndroidKey(key), + mapAndroidKey(key).toCombined(), mapAndroidModifiers(modifier), toString(unicode), autoRepeat); -- cgit v1.2.3