Mir

Merge lp:~andreas-pokorny/mir/activate-pointer-acceleration into lp:mir

Proposed by Andreas Pokorny
Status: Work in progress
Proposed branch: lp:~andreas-pokorny/mir/activate-pointer-acceleration
Merge into: lp:mir
Diff against target: 198 lines (+49/-38)
4 files modified
3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp (+1/-1)
3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp (+29/-34)
src/server/input/android/android_input_reader_policy.cpp (+16/-2)
tests/mir_test_doubles/fake_event_hub.cpp (+3/-1)
To merge this branch: bzr merge lp:~andreas-pokorny/mir/activate-pointer-acceleration
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+250358@code.launchpad.net

Commit message

activate pointer acceleration and make it partially dependent on GU value ..

To post a comment you must log in.
2332. By Andreas Pokorny

make sure that motion events are distant enough to be not subject of acceleration

Unmerged revisions

2332. By Andreas Pokorny

make sure that motion events are distant enough to be not subject of acceleration

2331. By Andreas Pokorny

fixing pointer accleration and making it GU dependent for now

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp'
2--- 3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp 2015-02-13 06:12:34 +0000
3+++ 3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp 2015-02-19 19:19:23 +0000
4@@ -70,7 +70,7 @@
5
6 float vx, vy;
7 float scale = mParameters.scale;
8- if (mVelocityTracker.getVelocity(0, &vx, &vy)) {
9+ if (mVelocityTracker.getVelocity(1, &vx, &vy)) {
10 float speed = hypotf(vx, vy) * scale;
11 if (speed >= mParameters.highThreshold) {
12 // Apply full acceleration above the high speed threshold.
13
14=== modified file '3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp'
15--- 3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp 2015-02-13 06:12:34 +0000
16+++ 3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp 2015-02-19 19:19:23 +0000
17@@ -65,36 +65,31 @@
18
19 #if DEBUG_STRATEGY || DEBUG_VELOCITY
20 static String8 vectorToString(const float* a, uint32_t m) {
21- String8 str;
22- str.append("[");
23+ std::stringstream str;
24+ str << '[';
25 while (m--) {
26- str.appendFormat(" %f", *(a++));
27- if (m) {
28- str.append(",");
29- }
30+ str << *a++;
31+ if (m)
32+ str << ',';
33 }
34- str.append(" ]");
35- return str;
36+ str << ']';
37+ return str.str();
38 }
39
40 static String8 matrixToString(const float* a, uint32_t m, uint32_t n, bool rowMajor) {
41- String8 str;
42- str.append("[");
43+ std::stringstream str;
44+ str << '[';
45 for (size_t i = 0; i < m; i++) {
46- if (i) {
47- str.append(",");
48- }
49- str.append(" [");
50+ if (i) str << ',';
51+ str << " [";
52 for (size_t j = 0; j < n; j++) {
53- if (j) {
54- str.append(",");
55- }
56- str.appendFormat(" %f", a[rowMajor ? i * n + j : j * m + i]);
57+ if (j) str << ',';
58+ str << ' ' << a[rowMajor ? i * n + j : j * m + i];
59 }
60- str.append(" ]");
61+ str << " ]";
62 }
63- str.append(" ]");
64- return str;
65+ str << " ]";
66+ return str.str();
67 }
68 #endif
69
70@@ -249,11 +244,11 @@
71 "estimator (degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f)",
72 id, positions[index].x, positions[index].y,
73 int(estimator.degree),
74- vectorToString(estimator.xCoeff, estimator.degree + 1).string(),
75- vectorToString(estimator.yCoeff, estimator.degree + 1).string(),
76+ vectorToString(estimator.xCoeff, estimator.degree + 1).c_str(),
77+ vectorToString(estimator.yCoeff, estimator.degree + 1).c_str(),
78 estimator.confidence);
79 ++index;
80- }
81+ });
82 #endif
83 }
84
85@@ -436,8 +431,8 @@
86 const float* w, uint32_t m, uint32_t n, float* outB, float* outDet) {
87 #if DEBUG_STRATEGY
88 ALOGD("solveLeastSquares: m=%d, n=%d, x=%s, y=%s, w=%s", int(m), int(n),
89- vectorToString(x, m).string(), vectorToString(y, m).string(),
90- vectorToString(w, m).string());
91+ vectorToString(x, m).c_str(), vectorToString(y, m).c_str(),
92+ vectorToString(w, m).c_str());
93 #endif
94
95 // Expand the X vector to a matrix A, pre-multiplied by the weights.
96@@ -449,7 +444,7 @@
97 }
98 }
99 #if DEBUG_STRATEGY
100- ALOGD(" - a=%s", matrixToString(&a[0][0], m, n, false /*rowMajor*/).string());
101+ ALOGD(" - a=%s", matrixToString(&a[0][0], m, n, false /*rowMajor*/).c_str());
102 #endif
103
104 // Apply the Gram-Schmidt process to A to obtain its QR decomposition.
105@@ -484,8 +479,8 @@
106 }
107 }
108 #if DEBUG_STRATEGY
109- ALOGD(" - q=%s", matrixToString(&q[0][0], m, n, false /*rowMajor*/).string());
110- ALOGD(" - r=%s", matrixToString(&r[0][0], n, n, true /*rowMajor*/).string());
111+ ALOGD(" - q=%s", matrixToString(&q[0][0], m, n, false /*rowMajor*/).c_str());
112+ ALOGD(" - r=%s", matrixToString(&r[0][0], n, n, true /*rowMajor*/).c_str());
113
114 // calculate QR, if we factored A correctly then QR should equal A
115 float qr[n][m];
116@@ -497,7 +492,7 @@
117 }
118 }
119 }
120- ALOGD(" - qr=%s", matrixToString(&qr[0][0], m, n, false /*rowMajor*/).string());
121+ ALOGD(" - qr=%s", matrixToString(&qr[0][0], m, n, false /*rowMajor*/).c_str());
122 #endif
123
124 // Solve R B = Qt W Y to find B. This is easy because R is upper triangular.
125@@ -514,7 +509,7 @@
126 outB[i] /= r[i][i];
127 }
128 #if DEBUG_STRATEGY
129- ALOGD(" - b=%s", vectorToString(outB, n).string());
130+ ALOGD(" - b=%s", vectorToString(outB, n).c_str());
131 #endif
132
133 // Calculate the coefficient of determination as 1 - (SSerr / SStot) where
134@@ -598,10 +593,10 @@
135 outEstimator->degree = degree;
136 outEstimator->confidence = xdet * ydet;
137 #if DEBUG_STRATEGY
138- ALOGD("estimate: degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f",
139+ ALOGD("estimate : degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f",
140 int(outEstimator->degree),
141- vectorToString(outEstimator->xCoeff, n).string(),
142- vectorToString(outEstimator->yCoeff, n).string(),
143+ vectorToString(outEstimator->xCoeff, n).c_str(),
144+ vectorToString(outEstimator->yCoeff, n).c_str(),
145 outEstimator->confidence);
146 #endif
147 return true;
148
149=== modified file 'src/server/input/android/android_input_reader_policy.cpp'
150--- src/server/input/android/android_input_reader_policy.cpp 2015-01-21 07:34:50 +0000
151+++ src/server/input/android/android_input_reader_policy.cpp 2015-02-19 19:19:23 +0000
152@@ -22,6 +22,8 @@
153 #include "mir/input/input_region.h"
154 #include "mir/geometry/rectangle.h"
155
156+#include <sstream>
157+
158 namespace mi = mir::input;
159 namespace mia = mir::input::android;
160
161@@ -50,8 +52,20 @@
162 height,
163 default_display_orientation);
164
165- out_config->pointerVelocityControlParameters.acceleration = 1.0;
166-
167+ auto gu_scale = 16.0f;
168+ auto gu_env = getenv("GRID_UNIT_PX");
169+
170+ if (gu_env)
171+ {
172+ std::istringstream in(gu_env);
173+ in >> gu_scale;
174+ }
175+
176+ out_config->pointerVelocityControlParameters.lowThreshold = 150.0f;
177+ out_config->pointerVelocityControlParameters.highThreshold = 500.0f;
178+ out_config->pointerVelocityControlParameters.acceleration = 3.0f + gu_scale/16.0f;
179+ out_config->wheelVelocityControlParameters.acceleration = 4.0f + gu_scale/16.0f;
180+
181 // This only enables passing through the touch coordinates from the InputReader to the TouchVisualizer
182 // the touch visualizer still decides whether or not to render anything.
183 out_config->showTouches = true;
184
185=== modified file 'tests/mir_test_doubles/fake_event_hub.cpp'
186--- tests/mir_test_doubles/fake_event_hub.cpp 2015-02-13 06:12:34 +0000
187+++ tests/mir_test_doubles/fake_event_hub.cpp 2015-02-19 19:19:23 +0000
188@@ -531,7 +531,9 @@
189 void FakeEventHub::synthesize_event(const mis::MotionParameters &parameters)
190 {
191 RawEvent event;
192- event.when = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch());
193+ static auto time = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch());
194+ time += std::chrono::seconds(1);
195+ event.when = time;
196 event.type = EV_REL;
197 if (parameters.device_id)
198 event.deviceId = parameters.device_id;

Subscribers

People subscribed via source and target branches