Index: services/prediction/key_set.cc |
diff --git a/services/prediction/key_set.cc b/services/prediction/key_set.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..86bc996ed90a3822daefecce7f69efe793d2d97f |
--- /dev/null |
+++ b/services/prediction/key_set.cc |
@@ -0,0 +1,56 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "services/prediction/key_set.h" |
+ |
+namespace prediction { |
+ |
+const Key KeySet::A(97, 43, 58, 29, 58, 4, 9); |
+const Key KeySet::B(98, 188, 116, 29, 58, 4, 9); |
+const Key KeySet::C(99, 130, 116, 29, 58, 4, 9); |
+const Key KeySet::D(100, 101, 58, 29, 58, 4, 9); |
+const Key KeySet::E(101, 87, 0, 29, 58, 4, 9); |
+const Key KeySet::F(102, 130, 58, 29, 58, 4, 9); |
+const Key KeySet::G(103, 159, 58, 29, 58, 4, 9); |
+const Key KeySet::H(104, 188, 58, 29, 58, 4, 9); |
+const Key KeySet::I(105, 232, 0, 29, 58, 4, 9); |
+const Key KeySet::J(106, 217, 58, 29, 58, 4, 9); |
+const Key KeySet::K(107, 246, 58, 29, 58, 4, 9); |
+const Key KeySet::L(108, 275, 58, 29, 58, 4, 9); |
+const Key KeySet::M(109, 246, 116, 29, 58, 4, 9); |
+const Key KeySet::N(110, 217, 116, 29, 58, 4, 9); |
+const Key KeySet::O(111, 261, 0, 29, 58, 4, 9); |
+const Key KeySet::P(112, 290, 0, 29, 58, 4, 9); |
+const Key KeySet::Q(113, 29, 0, 29, 58, 4, 9); |
+const Key KeySet::R(114, 116, 0, 29, 58, 4, 9); |
+const Key KeySet::S(115, 72, 58, 29, 58, 4, 9); |
+const Key KeySet::T(116, 145, 0, 29, 58, 4, 9); |
+const Key KeySet::U(117, 203, 0, 29, 58, 4, 9); |
+const Key KeySet::V(118, 159, 116, 29, 58, 4, 9); |
+const Key KeySet::W(119, 58, 0, 29, 58, 4, 9); |
+const Key KeySet::X(120, 101, 116, 29, 58, 4, 9); |
+const Key KeySet::Y(121, 174, 0, 29, 58, 4, 9); |
+const Key KeySet::Z(122, 72, 116, 29, 58, 4, 9); |
+ |
+const Key KeySet::key_set[] = { |
+ KeySet::Q, KeySet::W, KeySet::E, KeySet::R, KeySet::T, KeySet::Y, KeySet::U, |
+ KeySet::I, KeySet::O, KeySet::P, KeySet::A, KeySet::S, KeySet::D, KeySet::F, |
+ KeySet::G, KeySet::H, KeySet::J, KeySet::K, KeySet::L, KeySet::Z, KeySet::X, |
+ KeySet::C, KeySet::V, KeySet::B, KeySet::N, KeySet::M}; |
+ |
+const int KeySet::key_count = 26; |
+ |
+int KeySet::SquaredDistanceToEdge(int x, int y, Key k) { |
+ const int left = k.kx; |
+ const int right = left + k.kwidth; |
+ const int top = k.ky; |
+ const int bottom = top + k.kheight; |
+ const int edge_x = x < left ? left : (x > right ? right : x); |
+ const int edge_y = y < top ? top : (y > bottom ? bottom : y); |
+ const int dx = x - edge_x; |
+ const int dy = y - edge_y; |
+ return dx * dx + dy * dy; |
+} |
+ |
+} // namespace prediction |