1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "mojo/examples/keyboard/keys.h"
6
7#include "base/macros.h"
8#include "ui/events/event_constants.h"
9#include "ui/events/keycodes/keyboard_codes.h"
10
11namespace mojo {
12namespace examples {
13namespace {
14
15const Key kQWERTYKeysRow1[] =
16{
17  { ui::VKEY_Q, 1, 0, 'q' },
18  { ui::VKEY_W, 1, 0, 'w' },
19  { ui::VKEY_E, 1, 0, 'e' },
20  { ui::VKEY_R, 1, 0, 'r' },
21  { ui::VKEY_T, 1, 0, 't' },
22  { ui::VKEY_Y, 1, 0, 'y' },
23  { ui::VKEY_U, 1, 0, 'u' },
24  { ui::VKEY_I, 1, 0, 'i' },
25  { ui::VKEY_O, 1, 0, 'o' },
26  { ui::VKEY_P, 1, 0, 'p' },
27};
28
29const Key kQWERTYKeysRow2[] =
30{
31  { ui::VKEY_A, 1, 0, 'a' },
32  { ui::VKEY_S, 1, 0, 's' },
33  { ui::VKEY_D, 1, 0, 'd' },
34  { ui::VKEY_F, 1, 0, 'f' },
35  { ui::VKEY_G, 1, 0, 'g' },
36  { ui::VKEY_H, 1, 0, 'h' },
37  { ui::VKEY_J, 1, 0, 'j' },
38  { ui::VKEY_K, 1, 0, 'k' },
39  { ui::VKEY_L, 1, 0, 'l' },
40};
41
42const Key kQWERTYKeysRow3[] =
43{
44  { SPECIAL_KEY_SHIFT, 1.5, 0, 0 },
45  { ui::VKEY_Z, 1, 0, 'z' },
46  { ui::VKEY_X, 1, 0, 'x' },
47  { ui::VKEY_C, 1, 0, 'c' },
48  { ui::VKEY_V, 1, 0, 'v' },
49  { ui::VKEY_B, 1, 0, 'b' },
50  { ui::VKEY_N, 1, 0, 'n' },
51  { ui::VKEY_M, 1, 0, 'm' },
52  { ui::VKEY_BACK, 1.5, 0, 0 },
53};
54
55const Key kQWERTYKeysRow4[] =
56{
57  { SPECIAL_KEY_NUMERIC, 1.5, 0, 0 },
58  { ui::VKEY_DIVIDE, 1, 0, '/' },
59  { ui::VKEY_SPACE, 5, 0, ' ' },
60  { ui::VKEY_DECIMAL, 1, 0, '.' },
61  { ui::VKEY_RETURN, 1.5, 0, 0 },
62};
63
64const Row kQWERTYRow1 = {
65  0,
66  kQWERTYKeysRow1,
67  arraysize(kQWERTYKeysRow1),
68};
69
70const Row kQWERTYRow2 = {
71  .5,
72  kQWERTYKeysRow2,
73  arraysize(kQWERTYKeysRow2),
74};
75
76const Row kQWERTYRow3 = {
77  0,
78  kQWERTYKeysRow3,
79  arraysize(kQWERTYKeysRow3),
80};
81
82const Row kQWERTYRow4 = {
83  0,
84  kQWERTYKeysRow4,
85  arraysize(kQWERTYKeysRow4),
86};
87
88const Key kNumericKeysRow1[] =
89{
90  { ui::VKEY_1, 1, 0, 0 },
91  { ui::VKEY_2, 1, 0, 0 },
92  { ui::VKEY_3, 1, 0, 0 },
93  { ui::VKEY_4, 1, 0, 0 },
94  { ui::VKEY_5, 1, 0, 0 },
95  { ui::VKEY_6, 1, 0, 0 },
96  { ui::VKEY_7, 1, 0, 0 },
97  { ui::VKEY_8, 1, 0, 0 },
98  { ui::VKEY_9, 1, 0, 0 },
99  { ui::VKEY_0, 1, 0, 0 },
100};
101
102const Key kNumericKeysRow2[] =
103{
104  // @#$%&-+()
105  { ui::VKEY_2, 1, ui::EF_SHIFT_DOWN, '@' },
106  { ui::VKEY_3, 1, ui::EF_SHIFT_DOWN, '#' },
107  { ui::VKEY_4, 1, ui::EF_SHIFT_DOWN, '$' },
108  { ui::VKEY_5, 1, ui::EF_SHIFT_DOWN, '%' },
109  { ui::VKEY_7, 1, ui::EF_SHIFT_DOWN, '&' },
110  { ui::VKEY_SUBTRACT, 1, 0, '-' },
111  { ui::VKEY_ADD, 1, 0, '+' },
112  { ui::VKEY_9, 1, ui::EF_SHIFT_DOWN, '(' },
113  { ui::VKEY_0, 1, ui::EF_SHIFT_DOWN, ')' },
114};
115
116const Key kNumericKeysRow3[] =
117{
118  // *"':;!? backspace
119  { ui::VKEY_MULTIPLY, 1, 0, '*' },
120  { ui::VKEY_OEM_7, 1, ui::EF_SHIFT_DOWN, '"' },
121  { ui::VKEY_OEM_7, 1, 0, '\'' },
122  { ui::VKEY_OEM_1, 1, ui::EF_SHIFT_DOWN, ':' },
123  { ui::VKEY_OEM_1, 1, 0, ';' },
124  { ui::VKEY_1, 1, ui::EF_SHIFT_DOWN, '!' },
125  { ui::VKEY_OEM_2, 1, ui::EF_SHIFT_DOWN, '?' },
126  { ui::VKEY_BACK, 1.5, 0, 0 },
127};
128
129const Key kNumericKeysRow4[] =
130{
131  // ABC _ / space (3) ,.enter
132  { SPECIAL_KEY_ALPHA, 1.5, 0, 0 },
133  { ui::VKEY_OEM_MINUS, 1, ui::EF_SHIFT_DOWN, '_' },
134  { ui::VKEY_OEM_2, 1, 0, '/' },
135  { ui::VKEY_SPACE, 3, 0, ' ' },
136  { ui::VKEY_OEM_COMMA, 1, 0, ',' },
137  { ui::VKEY_OEM_PERIOD, 1, 0, '.' },
138  { ui::VKEY_RETURN, 1.5, 0, 0 },
139};
140
141const Row kNumericRow1 = {
142  0,
143  kNumericKeysRow1,
144  arraysize(kNumericKeysRow1),
145};
146
147const Row kNumericRow2 = {
148  .5,
149  kNumericKeysRow2,
150  arraysize(kNumericKeysRow2),
151};
152
153const Row kNumericRow3 = {
154  1.5,
155  kNumericKeysRow3,
156  arraysize(kNumericKeysRow3),
157};
158
159const Row kNumericRow4 = {
160  0,
161  kNumericKeysRow4,
162  arraysize(kNumericKeysRow4),
163};
164
165}  // namespace
166
167std::vector<const Row*> GetQWERTYRows() {
168  std::vector<const Row*> rows;
169  rows.push_back(&kQWERTYRow1);
170  rows.push_back(&kQWERTYRow2);
171  rows.push_back(&kQWERTYRow3);
172  rows.push_back(&kQWERTYRow4);
173  return rows;
174}
175
176std::vector<const Row*> GetNumericRows() {
177  std::vector<const Row*> rows;
178  rows.push_back(&kNumericRow1);
179  rows.push_back(&kNumericRow2);
180  rows.push_back(&kNumericRow3);
181  rows.push_back(&kNumericRow4);
182  return rows;
183}
184
185}  // namespace examples
186}  // namespace mojo
187