6#include <QtGui/qtguiglobal.h>
12#include <qpa/qplatformwindow.h>
13#include <qpa/qwindowsysteminterface.h>
17#include <QGuiApplication>
39 GenericMotionEventListener::~GenericMotionEventListener() {}
41 struct GenericMotionEventListeners {
43 QList<QtAndroidInput::GenericMotionEventListener *>
listeners;
46 Q_GLOBAL_STATIC(GenericMotionEventListeners, g_genericMotionEventListeners)
48 static jboolean dispatchGenericMotionEvent(JNIEnv *, jclass, jobject
event)
50 jboolean
ret = JNI_FALSE;
52 for (
auto *listener : std::as_const(g_genericMotionEventListeners()->
listeners))
53 ret |= listener->handleGenericMotionEvent(
event);
57 KeyEventListener::~KeyEventListener() {}
59 struct KeyEventListeners {
61 QList<QtAndroidInput::KeyEventListener *>
listeners;
66 static jboolean dispatchKeyEvent(JNIEnv *, jclass, jobject
event)
68 jboolean
ret = JNI_FALSE;
70 for (
auto *listener : std::as_const(g_keyEventListeners()->
listeners))
71 ret |= listener->handleKeyEvent(
event);
78 g_genericMotionEventListeners()->listeners.push_back(listener);
84 g_genericMotionEventListeners()->listeners.removeOne(listener);
90 g_keyEventListeners()->listeners.push_back(listener);
96 g_keyEventListeners()->listeners.removeOne(listener);
104 void updateSelection(
int selStart,
int selEnd,
int candidatesStart,
int candidatesEnd)
106 qCDebug(lcQpaInputMethods) <<
">>> UPDATESELECTION" << selStart << selEnd << candidatesStart << candidatesEnd;
118 qtLayout().object<QtJniTypes::QtLayout>(),
125 qCDebug(lcQpaInputMethods) <<
"@@@ SHOWSOFTWAREKEYBOARD" <<
left <<
top <<
width <<
height << inputHints << enterKeyType;
131 qCDebug(lcQpaInputMethods) <<
"@@@ RESETSOFTWAREKEYBOARD";
137 qCDebug(lcQpaInputMethods) <<
"@@@ HIDESOFTWAREKEYBOARD";
142 return qtInputDelegate().callMethod<jboolean>(
"isSoftwareKeyboardVisible");
159 qtLayout().object<QtJniTypes::QtLayout>(),
160 mode, editMenuPos.x(), editMenuPos.y(), editButtons,
162 anchor.
x(), anchor.
y(), rtl);
177 static
Qt::MouseButtons toMouseButtons(jint j_buttons)
179 const auto buttons =
static_cast<AndroidMouseButtons
>(j_buttons);
180 Qt::MouseButtons mouseButtons;
204 qWarning() <<
"Unhandled button value:" << buttons <<
"Falling back to Qt::LeftButton";
213 const Qt::MouseButtons mouseButtons =
toMouseButtons(mouseButtonState);
214 const Qt::MouseButtons changedButtons = mouseButtons & ~m_buttons;
219 static_assert (
sizeof(changedButtons) <=
sizeof(
uint),
"Qt::MouseButtons size changed. Adapt code.");
221 for (
uint buttonInt = 0x1;
static_cast<uint>(changedButtons) >= buttonInt; buttonInt <<= 1) {
223 if (changedButtons.testFlag(
button)) {
230 static void mouseDown(JNIEnv *, jobject , jint winId, jint
x, jint
y, jint mouseButtonState)
239 window->handle()->mapFromGlobal(globalPos) : globalPos;
243 static void mouseUp(JNIEnv *, jobject , jint winId, jint
x, jint
y, jint mouseButtonState)
251 window->handle()->mapFromGlobal(globalPos) : globalPos;
258 static void mouseMove(JNIEnv *, jobject , jint winId, jint
x, jint
y)
269 window->handle()->mapFromGlobal(globalPos) : globalPos;
275 static void mouseWheel(JNIEnv *, jobject , jint winId, jint
x, jint
y, jfloat hdelta, jfloat vdelta)
285 window->handle()->mapFromGlobal(globalPos) : globalPos;
286 const QPoint angleDelta(hdelta * 120, vdelta * 120);
295 static void longPress(JNIEnv *, jobject , jint winId, jint
x, jint
y)
303 if (!rightMouseFromLongPress)
309 window->handle()->mapFromGlobal(globalPos) : globalPos;
327 static void touchAdd(JNIEnv *, jobject , jint , jint
id, jint action, jboolean , jint
x, jint
y,
328 jfloat major, jfloat minor, jfloat rotation, jfloat pressure)
355 y -
double(major * 0.5f),
369 if (!platformIntegration)
389 static void touchEnd(JNIEnv * , jobject , jint winId, jint )
423#if QT_CONFIG(tabletevent)
430 static void tabletEvent(JNIEnv *, jobject , jint winId, jint deviceId, jlong
time, jint action,
431 jint
pointerType, jint buttonState, jfloat
x, jfloat
y, jfloat pressure)
433#if QT_CONFIG(tabletevent)
437 window->handle()->mapFromGlobalF(globalPosF) : globalPosF;
462 if (buttonState == 0)
465 buttons = Qt::MouseButtons(buttonState);
469 qCDebug(lcQpaInputMethods) << action <<
pointerType << buttonState <<
'@' <<
x <<
y <<
"pressure" << pressure <<
": buttons" << buttons;
480 if (
key >= 0x00000007 &&
key <= 0x00000010)
484 if (
key >= 0x0000001d &&
key <= 0x00000036)
488 if (
key >= 0x00000083 &&
key <= 0x0000008e)
492 if (
key >= 0x00000090 &&
key <= 0x00000099)
879 Qt::KeyboardModifiers qmodifiers;
902 static void keyDown(JNIEnv *, jobject , jint
key, jint unicode, jint modifier, jboolean autoRepeat)
912 static void keyUp(JNIEnv *, jobject , jint
key, jint unicode, jint modifier, jboolean autoRepeat)
935 qCDebug(lcQpaInputMethods) <<
"@@@ KEYBOARDVISIBILITYCHANGED" << inputContext;
953 qCDebug(lcQpaInputMethods) <<
"@@@ handleLocationChanged" <<
id <<
x <<
y;
964 {
"touchAdd",
"(IIIZIIFFFF)V",(
void*)
touchAdd},
965 {
"touchEnd",
"(II)V",(
void*)
touchEnd},
967 {
"mouseDown",
"(IIII)V", (
void *)
mouseDown},
968 {
"mouseUp",
"(IIII)V", (
void *)
mouseUp},
969 {
"mouseMove",
"(III)V", (
void *)
mouseMove},
970 {
"mouseWheel",
"(IIIFF)V", (
void *)
mouseWheel},
971 {
"longPress",
"(III)V", (
void *)
longPress},
973 {
"tabletEvent",
"(IIJIIIFFF)V", (
void *)
tabletEvent},
974 {
"keyDown",
"(IIIZ)V", (
void *)
keyDown},
975 {
"keyUp",
"(IIIZ)V", (
void *)
keyUp},
980 {
"dispatchKeyEvent",
"(Landroid/view/KeyEvent;)Z",
reinterpret_cast<void *
>(
dispatchKeyEvent)},
985 if (!env.registerNativeMethods(QtJniTypes::Traits<QtJniTypes::QtInputDelegate>::className(),
987 __android_log_print(ANDROID_LOG_FATAL,
"Qt",
"RegisterNatives failed");
static JNINativeMethod methods[]
static QAndroidInputContext * androidInputContext()
State
Specifies the state of this event point.
Type
This enum type defines the valid event types in Qt.
static constexpr QKeyCombination fromCombined(int combined)
void emitInputPanelVisibleChanged()
Active QPlatformInputContext is responsible for providing visible property to QInputMethod.
void emitKeyboardRectChanged()
Active QPlatformInputContext is responsible for providing keyboardRectangle property to QInputMethod.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
static bool handleTouchEvent(QWindow *window, const QPointingDevice *device, const QList< struct TouchPoint > &points, Qt::KeyboardModifiers mods=Qt::NoModifier)
static bool handleTabletEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, const QPointF &local, const QPointF &global, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
static bool handleTouchCancelEvent(QWindow *window, const QPointingDevice *device, Qt::KeyboardModifiers mods=Qt::NoModifier)
static bool handleMouseEvent(QWindow *window, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
static void registerInputDevice(const QInputDevice *device)
static bool handleKeyEvent(QWindow *window, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString &text=QString(), bool autorep=false, ushort count=1)
static bool handleWheelEvent(QWindow *window, const QPointF &local, const QPointF &global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::ScrollPhase phase=Qt::NoScrollPhase, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
EGLImageKHR int int EGLuint64KHR * modifiers
static bool registerNatives()
Combined button and popup list for selecting options.
Q_CORE_EXPORT QtJniTypes::Activity activity()
QBasicMutex * platformInterfaceMutex()
QtJniTypes::QtActivityDelegateBase qtActivityDelegate()
QAndroidPlatformIntegration * androidPlatformIntegration()
QtJniTypes::QtInputDelegate qtInputDelegate()
int availableWidthPixels()
QWindow * windowFromId(int windowId)
int availableHeightPixels()
@ Key_KeyboardBrightnessUp
@ Key_MediaTogglePlayPause
@ Key_KeyboardBrightnessDown
@ BlockingQueuedConnection
#define Q_DECLARE_FLAGS(Flags, Enum)
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
constexpr float qRadiansToDegrees(float radians)
Qt::MouseButtons m_buttons
#define Q_ARG(Type, data)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble GLdouble top
GLfloat GLfloat GLfloat GLfloat h
QT_BEGIN_NAMESPACE Q_DECLARE_JNI_CLASS(Environment, "android/os/Environment")
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
static QPointingDevice::PointerType pointerType(unsigned currentCursor)
char * toString(const MyType &t)
[31]