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
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp 2015-02-13 06:12:34 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp 2015-02-19 19:19:23 +0000
@@ -70,7 +70,7 @@
7070
71 float vx, vy;71 float vx, vy;
72 float scale = mParameters.scale;72 float scale = mParameters.scale;
73 if (mVelocityTracker.getVelocity(0, &vx, &vy)) {73 if (mVelocityTracker.getVelocity(1, &vx, &vy)) {
74 float speed = hypotf(vx, vy) * scale;74 float speed = hypotf(vx, vy) * scale;
75 if (speed >= mParameters.highThreshold) {75 if (speed >= mParameters.highThreshold) {
76 // Apply full acceleration above the high speed threshold.76 // Apply full acceleration above the high speed threshold.
7777
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp 2015-02-13 06:12:34 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp 2015-02-19 19:19:23 +0000
@@ -65,36 +65,31 @@
6565
66#if DEBUG_STRATEGY || DEBUG_VELOCITY66#if DEBUG_STRATEGY || DEBUG_VELOCITY
67static String8 vectorToString(const float* a, uint32_t m) {67static String8 vectorToString(const float* a, uint32_t m) {
68 String8 str;68 std::stringstream str;
69 str.append("[");69 str << '[';
70 while (m--) {70 while (m--) {
71 str.appendFormat(" %f", *(a++));71 str << *a++;
72 if (m) {72 if (m)
73 str.append(",");73 str << ',';
74 }
75 }74 }
76 str.append(" ]");75 str << ']';
77 return str;76 return str.str();
78}77}
7978
80static String8 matrixToString(const float* a, uint32_t m, uint32_t n, bool rowMajor) {79static String8 matrixToString(const float* a, uint32_t m, uint32_t n, bool rowMajor) {
81 String8 str;80 std::stringstream str;
82 str.append("[");81 str << '[';
83 for (size_t i = 0; i < m; i++) {82 for (size_t i = 0; i < m; i++) {
84 if (i) {83 if (i) str << ',';
85 str.append(",");84 str << " [";
86 }
87 str.append(" [");
88 for (size_t j = 0; j < n; j++) {85 for (size_t j = 0; j < n; j++) {
89 if (j) {86 if (j) str << ',';
90 str.append(",");87 str << ' ' << a[rowMajor ? i * n + j : j * m + i];
91 }
92 str.appendFormat(" %f", a[rowMajor ? i * n + j : j * m + i]);
93 }88 }
94 str.append(" ]");89 str << " ]";
95 }90 }
96 str.append(" ]");91 str << " ]";
97 return str;92 return str.str();
98}93}
99#endif94#endif
10095
@@ -249,11 +244,11 @@
249 "estimator (degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f)",244 "estimator (degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f)",
250 id, positions[index].x, positions[index].y,245 id, positions[index].x, positions[index].y,
251 int(estimator.degree),246 int(estimator.degree),
252 vectorToString(estimator.xCoeff, estimator.degree + 1).string(),247 vectorToString(estimator.xCoeff, estimator.degree + 1).c_str(),
253 vectorToString(estimator.yCoeff, estimator.degree + 1).string(),248 vectorToString(estimator.yCoeff, estimator.degree + 1).c_str(),
254 estimator.confidence);249 estimator.confidence);
255 ++index;250 ++index;
256 }251 });
257#endif252#endif
258}253}
259254
@@ -436,8 +431,8 @@
436 const float* w, uint32_t m, uint32_t n, float* outB, float* outDet) {431 const float* w, uint32_t m, uint32_t n, float* outB, float* outDet) {
437#if DEBUG_STRATEGY432#if DEBUG_STRATEGY
438 ALOGD("solveLeastSquares: m=%d, n=%d, x=%s, y=%s, w=%s", int(m), int(n),433 ALOGD("solveLeastSquares: m=%d, n=%d, x=%s, y=%s, w=%s", int(m), int(n),
439 vectorToString(x, m).string(), vectorToString(y, m).string(),434 vectorToString(x, m).c_str(), vectorToString(y, m).c_str(),
440 vectorToString(w, m).string());435 vectorToString(w, m).c_str());
441#endif436#endif
442437
443 // Expand the X vector to a matrix A, pre-multiplied by the weights.438 // Expand the X vector to a matrix A, pre-multiplied by the weights.
@@ -449,7 +444,7 @@
449 }444 }
450 }445 }
451#if DEBUG_STRATEGY446#if DEBUG_STRATEGY
452 ALOGD(" - a=%s", matrixToString(&a[0][0], m, n, false /*rowMajor*/).string());447 ALOGD(" - a=%s", matrixToString(&a[0][0], m, n, false /*rowMajor*/).c_str());
453#endif448#endif
454449
455 // Apply the Gram-Schmidt process to A to obtain its QR decomposition.450 // Apply the Gram-Schmidt process to A to obtain its QR decomposition.
@@ -484,8 +479,8 @@
484 }479 }
485 }480 }
486#if DEBUG_STRATEGY481#if DEBUG_STRATEGY
487 ALOGD(" - q=%s", matrixToString(&q[0][0], m, n, false /*rowMajor*/).string());482 ALOGD(" - q=%s", matrixToString(&q[0][0], m, n, false /*rowMajor*/).c_str());
488 ALOGD(" - r=%s", matrixToString(&r[0][0], n, n, true /*rowMajor*/).string());483 ALOGD(" - r=%s", matrixToString(&r[0][0], n, n, true /*rowMajor*/).c_str());
489484
490 // calculate QR, if we factored A correctly then QR should equal A485 // calculate QR, if we factored A correctly then QR should equal A
491 float qr[n][m];486 float qr[n][m];
@@ -497,7 +492,7 @@
497 }492 }
498 }493 }
499 }494 }
500 ALOGD(" - qr=%s", matrixToString(&qr[0][0], m, n, false /*rowMajor*/).string());495 ALOGD(" - qr=%s", matrixToString(&qr[0][0], m, n, false /*rowMajor*/).c_str());
501#endif496#endif
502497
503 // Solve R B = Qt W Y to find B. This is easy because R is upper triangular.498 // Solve R B = Qt W Y to find B. This is easy because R is upper triangular.
@@ -514,7 +509,7 @@
514 outB[i] /= r[i][i];509 outB[i] /= r[i][i];
515 }510 }
516#if DEBUG_STRATEGY511#if DEBUG_STRATEGY
517 ALOGD(" - b=%s", vectorToString(outB, n).string());512 ALOGD(" - b=%s", vectorToString(outB, n).c_str());
518#endif513#endif
519514
520 // Calculate the coefficient of determination as 1 - (SSerr / SStot) where515 // Calculate the coefficient of determination as 1 - (SSerr / SStot) where
@@ -598,10 +593,10 @@
598 outEstimator->degree = degree;593 outEstimator->degree = degree;
599 outEstimator->confidence = xdet * ydet;594 outEstimator->confidence = xdet * ydet;
600#if DEBUG_STRATEGY595#if DEBUG_STRATEGY
601 ALOGD("estimate: degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f",596 ALOGD("estimate : degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f",
602 int(outEstimator->degree),597 int(outEstimator->degree),
603 vectorToString(outEstimator->xCoeff, n).string(),598 vectorToString(outEstimator->xCoeff, n).c_str(),
604 vectorToString(outEstimator->yCoeff, n).string(),599 vectorToString(outEstimator->yCoeff, n).c_str(),
605 outEstimator->confidence);600 outEstimator->confidence);
606#endif601#endif
607 return true;602 return true;
608603
=== modified file 'src/server/input/android/android_input_reader_policy.cpp'
--- src/server/input/android/android_input_reader_policy.cpp 2015-01-21 07:34:50 +0000
+++ src/server/input/android/android_input_reader_policy.cpp 2015-02-19 19:19:23 +0000
@@ -22,6 +22,8 @@
22#include "mir/input/input_region.h"22#include "mir/input/input_region.h"
23#include "mir/geometry/rectangle.h"23#include "mir/geometry/rectangle.h"
2424
25#include <sstream>
26
25namespace mi = mir::input;27namespace mi = mir::input;
26namespace mia = mir::input::android;28namespace mia = mir::input::android;
2729
@@ -50,8 +52,20 @@
50 height,52 height,
51 default_display_orientation);53 default_display_orientation);
5254
53 out_config->pointerVelocityControlParameters.acceleration = 1.0;55 auto gu_scale = 16.0f;
54 56 auto gu_env = getenv("GRID_UNIT_PX");
57
58 if (gu_env)
59 {
60 std::istringstream in(gu_env);
61 in >> gu_scale;
62 }
63
64 out_config->pointerVelocityControlParameters.lowThreshold = 150.0f;
65 out_config->pointerVelocityControlParameters.highThreshold = 500.0f;
66 out_config->pointerVelocityControlParameters.acceleration = 3.0f + gu_scale/16.0f;
67 out_config->wheelVelocityControlParameters.acceleration = 4.0f + gu_scale/16.0f;
68
55 // This only enables passing through the touch coordinates from the InputReader to the TouchVisualizer69 // This only enables passing through the touch coordinates from the InputReader to the TouchVisualizer
56 // the touch visualizer still decides whether or not to render anything.70 // the touch visualizer still decides whether or not to render anything.
57 out_config->showTouches = true;71 out_config->showTouches = true;
5872
=== modified file 'tests/mir_test_doubles/fake_event_hub.cpp'
--- tests/mir_test_doubles/fake_event_hub.cpp 2015-02-13 06:12:34 +0000
+++ tests/mir_test_doubles/fake_event_hub.cpp 2015-02-19 19:19:23 +0000
@@ -531,7 +531,9 @@
531void FakeEventHub::synthesize_event(const mis::MotionParameters &parameters)531void FakeEventHub::synthesize_event(const mis::MotionParameters &parameters)
532{532{
533 RawEvent event;533 RawEvent event;
534 event.when = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch());534 static auto time = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch());
535 time += std::chrono::seconds(1);
536 event.when = time;
535 event.type = EV_REL;537 event.type = EV_REL;
536 if (parameters.device_id)538 if (parameters.device_id)
537 event.deviceId = parameters.device_id;539 event.deviceId = parameters.device_id;

Subscribers

People subscribed via source and target branches