diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-09-08 09:32:26 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-09-10 17:15:40 +0200 |
commit | 72338c12bc98ac1ad139436bedd422d61dd68291 (patch) | |
tree | 022f7cd0f0722c10a3a089a01c38ede4815ff4c3 /src/plugins/platforms/ios/quiview.mm | |
parent | c942bae4ebf903a60a8bd3da9500f7733c71b04d (diff) |
Use qmath.h's conversions between degrees and radians
The make the semantics overt and avoid the joys of yet another
approximation to pi/180 hard-coded in our source-code.
Change-Id: I9dcbaada2e7de119e385fc7056bc601ecd59311a
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios/quiview.mm')
-rw-r--r-- | src/plugins/platforms/ios/quiview.mm | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index c7f94cc707..ef6c9f49ad 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. @@ -50,6 +50,7 @@ #include "qiosmenu.h" #endif +#include <QtCore/qmath.h> #include <QtGui/qpointingdevice.h> #include <QtGui/private/qguiapplication_p.h> #include <QtGui/private/qwindow_p.h> @@ -388,10 +389,10 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") // azimuth unit vector: +x to the right, +y going downwards CGVector azimuth = [cTouch azimuthUnitVectorInView: self]; // azimuthAngle given in radians, zero when the stylus points towards +x axis; converted to degrees with 0 pointing straight up - qreal azimuthAngle = [cTouch azimuthAngleInView: self] * 180 / M_PI + 90; + qreal azimuthAngle = qRadiansToDegrees([cTouch azimuthAngleInView: self]) + 90; // altitudeAngle given in radians, pi / 2 is with the stylus perpendicular to the iPad, smaller values mean more tilted, but never negative. // Convert to degrees with zero being perpendicular. - qreal altitudeAngle = 90 - cTouch.altitudeAngle * 180 / M_PI; + qreal altitudeAngle = 90 - qRadiansToDegrees(cTouch.altitudeAngle); qCDebug(lcQpaTablet) << i << ":" << timeStamp << localViewPosition << pressure << state << "azimuth" << azimuth.dx << azimuth.dy << "angle" << azimuthAngle << "altitude" << cTouch.altitudeAngle << "xTilt" << qBound(-60.0, altitudeAngle * azimuth.dx, 60.0) << "yTilt" << qBound(-60.0, altitudeAngle * azimuth.dy, 60.0); |