1*e01b6f76SAndroid Build Coastguard Worker /*
2*e01b6f76SAndroid Build Coastguard Worker * Copyright (C) 2015 The Android Open Source Project
3*e01b6f76SAndroid Build Coastguard Worker *
4*e01b6f76SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*e01b6f76SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*e01b6f76SAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*e01b6f76SAndroid Build Coastguard Worker *
8*e01b6f76SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*e01b6f76SAndroid Build Coastguard Worker *
10*e01b6f76SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*e01b6f76SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*e01b6f76SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*e01b6f76SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*e01b6f76SAndroid Build Coastguard Worker * limitations under the License.
15*e01b6f76SAndroid Build Coastguard Worker */
16*e01b6f76SAndroid Build Coastguard Worker
17*e01b6f76SAndroid Build Coastguard Worker #include "InputMocks.h"
18*e01b6f76SAndroid Build Coastguard Worker
19*e01b6f76SAndroid Build Coastguard Worker namespace android {
20*e01b6f76SAndroid Build Coastguard Worker
hasKeyInRange(int32_t startKey,int32_t endKey) const21*e01b6f76SAndroid Build Coastguard Worker bool MockInputDeviceNode::hasKeyInRange(int32_t startKey, int32_t endKey) const {
22*e01b6f76SAndroid Build Coastguard Worker auto iter = mKeys.lower_bound(startKey);
23*e01b6f76SAndroid Build Coastguard Worker if (iter == mKeys.end()) return false;
24*e01b6f76SAndroid Build Coastguard Worker return *iter < endKey;
25*e01b6f76SAndroid Build Coastguard Worker }
26*e01b6f76SAndroid Build Coastguard Worker
27*e01b6f76SAndroid Build Coastguard Worker namespace MockNexus7v2 {
28*e01b6f76SAndroid Build Coastguard Worker
getElanTouchscreen()29*e01b6f76SAndroid Build Coastguard Worker MockInputDeviceNode* getElanTouchscreen() {
30*e01b6f76SAndroid Build Coastguard Worker auto node = new MockInputDeviceNode();
31*e01b6f76SAndroid Build Coastguard Worker node->setPath("/dev/input/event0");
32*e01b6f76SAndroid Build Coastguard Worker node->setName("elan-touchscreen");
33*e01b6f76SAndroid Build Coastguard Worker // Location not set
34*e01b6f76SAndroid Build Coastguard Worker // UniqueId not set
35*e01b6f76SAndroid Build Coastguard Worker node->setBusType(0);
36*e01b6f76SAndroid Build Coastguard Worker node->setVendorId(0);
37*e01b6f76SAndroid Build Coastguard Worker node->setProductId(0);
38*e01b6f76SAndroid Build Coastguard Worker node->setVersion(0);
39*e01b6f76SAndroid Build Coastguard Worker // No keys
40*e01b6f76SAndroid Build Coastguard Worker // No relative axes
41*e01b6f76SAndroid Build Coastguard Worker // TODO: set the AbsoluteAxisInfo pointers
42*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_MT_SLOT, nullptr);
43*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_MT_TOUCH_MAJOR, nullptr);
44*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_MT_POSITION_X, nullptr);
45*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_MT_POSITION_Y, nullptr);
46*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_MT_TRACKING_ID, nullptr);
47*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_MT_PRESSURE, nullptr);
48*e01b6f76SAndroid Build Coastguard Worker // No switches
49*e01b6f76SAndroid Build Coastguard Worker // No forcefeedback
50*e01b6f76SAndroid Build Coastguard Worker node->addInputProperty(INPUT_PROP_DIRECT);
51*e01b6f76SAndroid Build Coastguard Worker return node;
52*e01b6f76SAndroid Build Coastguard Worker }
53*e01b6f76SAndroid Build Coastguard Worker
getLidInput()54*e01b6f76SAndroid Build Coastguard Worker MockInputDeviceNode* getLidInput() {
55*e01b6f76SAndroid Build Coastguard Worker auto node = new MockInputDeviceNode();
56*e01b6f76SAndroid Build Coastguard Worker node->setPath("/dev/input/event1");
57*e01b6f76SAndroid Build Coastguard Worker node->setName("lid_input");
58*e01b6f76SAndroid Build Coastguard Worker node->setLocation("/dev/input/lid_indev");
59*e01b6f76SAndroid Build Coastguard Worker // UniqueId not set
60*e01b6f76SAndroid Build Coastguard Worker node->setBusType(0);
61*e01b6f76SAndroid Build Coastguard Worker node->setVendorId(0);
62*e01b6f76SAndroid Build Coastguard Worker node->setProductId(0);
63*e01b6f76SAndroid Build Coastguard Worker node->setVersion(0);
64*e01b6f76SAndroid Build Coastguard Worker // No keys
65*e01b6f76SAndroid Build Coastguard Worker // No relative axes
66*e01b6f76SAndroid Build Coastguard Worker // No absolute axes
67*e01b6f76SAndroid Build Coastguard Worker node->addSwitch(SW_LID);
68*e01b6f76SAndroid Build Coastguard Worker // No forcefeedback
69*e01b6f76SAndroid Build Coastguard Worker node->addInputProperty(INPUT_PROP_DIRECT);
70*e01b6f76SAndroid Build Coastguard Worker return node;
71*e01b6f76SAndroid Build Coastguard Worker }
72*e01b6f76SAndroid Build Coastguard Worker
getButtonJack()73*e01b6f76SAndroid Build Coastguard Worker MockInputDeviceNode* getButtonJack() {
74*e01b6f76SAndroid Build Coastguard Worker auto node = new MockInputDeviceNode();
75*e01b6f76SAndroid Build Coastguard Worker node->setPath("/dev/input/event2");
76*e01b6f76SAndroid Build Coastguard Worker node->setName("apq8064-tabla-snd-card Button Jack");
77*e01b6f76SAndroid Build Coastguard Worker node->setLocation("ALSA");
78*e01b6f76SAndroid Build Coastguard Worker // UniqueId not set
79*e01b6f76SAndroid Build Coastguard Worker node->setBusType(0);
80*e01b6f76SAndroid Build Coastguard Worker node->setVendorId(0);
81*e01b6f76SAndroid Build Coastguard Worker node->setProductId(0);
82*e01b6f76SAndroid Build Coastguard Worker node->setVersion(0);
83*e01b6f76SAndroid Build Coastguard Worker node->addKeys(BTN_0, BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7);
84*e01b6f76SAndroid Build Coastguard Worker // No relative axes
85*e01b6f76SAndroid Build Coastguard Worker // No absolute axes
86*e01b6f76SAndroid Build Coastguard Worker // No switches
87*e01b6f76SAndroid Build Coastguard Worker // No forcefeedback
88*e01b6f76SAndroid Build Coastguard Worker node->addInputProperty(INPUT_PROP_DIRECT);
89*e01b6f76SAndroid Build Coastguard Worker return node;
90*e01b6f76SAndroid Build Coastguard Worker }
91*e01b6f76SAndroid Build Coastguard Worker
getHeadsetJack()92*e01b6f76SAndroid Build Coastguard Worker MockInputDeviceNode* getHeadsetJack() {
93*e01b6f76SAndroid Build Coastguard Worker auto node = new MockInputDeviceNode();
94*e01b6f76SAndroid Build Coastguard Worker node->setPath("/dev/input/event3");
95*e01b6f76SAndroid Build Coastguard Worker node->setName("apq8064-tabla-snd-card Headset Jack");
96*e01b6f76SAndroid Build Coastguard Worker node->setLocation("ALSA");
97*e01b6f76SAndroid Build Coastguard Worker // UniqueId not set
98*e01b6f76SAndroid Build Coastguard Worker node->setBusType(0);
99*e01b6f76SAndroid Build Coastguard Worker node->setVendorId(0);
100*e01b6f76SAndroid Build Coastguard Worker node->setProductId(0);
101*e01b6f76SAndroid Build Coastguard Worker node->setVersion(0);
102*e01b6f76SAndroid Build Coastguard Worker // No keys
103*e01b6f76SAndroid Build Coastguard Worker // No relative axes
104*e01b6f76SAndroid Build Coastguard Worker // No absolute axes
105*e01b6f76SAndroid Build Coastguard Worker node->addSwitch(SW_HEADPHONE_INSERT);
106*e01b6f76SAndroid Build Coastguard Worker node->addSwitch(SW_MICROPHONE_INSERT);
107*e01b6f76SAndroid Build Coastguard Worker node->addSwitch(SW_LINEOUT_INSERT);
108*e01b6f76SAndroid Build Coastguard Worker // ASUS adds some proprietary switches, but we'll only see two of them.
109*e01b6f76SAndroid Build Coastguard Worker node->addSwitch(0x0e); // SW_HPHL_OVERCURRENT
110*e01b6f76SAndroid Build Coastguard Worker node->addSwitch(0x0f); // SW_HPHR_OVERCURRENT
111*e01b6f76SAndroid Build Coastguard Worker // No forcefeedback
112*e01b6f76SAndroid Build Coastguard Worker node->addInputProperty(INPUT_PROP_DIRECT);
113*e01b6f76SAndroid Build Coastguard Worker return node;
114*e01b6f76SAndroid Build Coastguard Worker }
115*e01b6f76SAndroid Build Coastguard Worker
getH2wButton()116*e01b6f76SAndroid Build Coastguard Worker MockInputDeviceNode* getH2wButton() {
117*e01b6f76SAndroid Build Coastguard Worker auto node = new MockInputDeviceNode();
118*e01b6f76SAndroid Build Coastguard Worker node->setPath("/dev/input/event4");
119*e01b6f76SAndroid Build Coastguard Worker node->setName("h2w button");
120*e01b6f76SAndroid Build Coastguard Worker // Location not set
121*e01b6f76SAndroid Build Coastguard Worker // UniqueId not set
122*e01b6f76SAndroid Build Coastguard Worker node->setBusType(0);
123*e01b6f76SAndroid Build Coastguard Worker node->setVendorId(0);
124*e01b6f76SAndroid Build Coastguard Worker node->setProductId(0);
125*e01b6f76SAndroid Build Coastguard Worker node->setVersion(0);
126*e01b6f76SAndroid Build Coastguard Worker node->addKeys(KEY_MEDIA);
127*e01b6f76SAndroid Build Coastguard Worker // No relative axes
128*e01b6f76SAndroid Build Coastguard Worker // No absolute axes
129*e01b6f76SAndroid Build Coastguard Worker // No switches
130*e01b6f76SAndroid Build Coastguard Worker node->addInputProperty(INPUT_PROP_DIRECT);
131*e01b6f76SAndroid Build Coastguard Worker return node;
132*e01b6f76SAndroid Build Coastguard Worker }
133*e01b6f76SAndroid Build Coastguard Worker
getGpioKeys()134*e01b6f76SAndroid Build Coastguard Worker MockInputDeviceNode* getGpioKeys() {
135*e01b6f76SAndroid Build Coastguard Worker auto node = new MockInputDeviceNode();
136*e01b6f76SAndroid Build Coastguard Worker node->setPath("/dev/input/event5");
137*e01b6f76SAndroid Build Coastguard Worker node->setName("gpio-keys");
138*e01b6f76SAndroid Build Coastguard Worker node->setLocation("gpio-keys/input0");
139*e01b6f76SAndroid Build Coastguard Worker // UniqueId not set
140*e01b6f76SAndroid Build Coastguard Worker node->setBusType(0x0019);
141*e01b6f76SAndroid Build Coastguard Worker node->setVendorId(0x0001);
142*e01b6f76SAndroid Build Coastguard Worker node->setProductId(0x0001);
143*e01b6f76SAndroid Build Coastguard Worker node->setVersion(0x0100);
144*e01b6f76SAndroid Build Coastguard Worker node->addKeys(KEY_VOLUMEDOWN, KEY_VOLUMEUP, KEY_POWER);
145*e01b6f76SAndroid Build Coastguard Worker // No relative axes
146*e01b6f76SAndroid Build Coastguard Worker // No absolute axes
147*e01b6f76SAndroid Build Coastguard Worker // No switches
148*e01b6f76SAndroid Build Coastguard Worker node->addInputProperty(INPUT_PROP_DIRECT);
149*e01b6f76SAndroid Build Coastguard Worker return node;
150*e01b6f76SAndroid Build Coastguard Worker }
151*e01b6f76SAndroid Build Coastguard Worker
152*e01b6f76SAndroid Build Coastguard Worker } // namespace MockNexus7v2
153*e01b6f76SAndroid Build Coastguard Worker
154*e01b6f76SAndroid Build Coastguard Worker namespace MockNexusPlayer {
155*e01b6f76SAndroid Build Coastguard Worker
getGpioKeys()156*e01b6f76SAndroid Build Coastguard Worker MockInputDeviceNode* getGpioKeys() {
157*e01b6f76SAndroid Build Coastguard Worker auto node = new MockInputDeviceNode();
158*e01b6f76SAndroid Build Coastguard Worker node->setPath("/dev/input/event0");
159*e01b6f76SAndroid Build Coastguard Worker node->setName("gpio-keys");
160*e01b6f76SAndroid Build Coastguard Worker node->setLocation("gpio-keys/input0");
161*e01b6f76SAndroid Build Coastguard Worker // UniqueId not set
162*e01b6f76SAndroid Build Coastguard Worker node->setBusType(0x0019);
163*e01b6f76SAndroid Build Coastguard Worker node->setVendorId(0x0001);
164*e01b6f76SAndroid Build Coastguard Worker node->setProductId(0x0001);
165*e01b6f76SAndroid Build Coastguard Worker node->setVersion(0x0100);
166*e01b6f76SAndroid Build Coastguard Worker node->addKeys(KEY_CONNECT);
167*e01b6f76SAndroid Build Coastguard Worker // No relative axes
168*e01b6f76SAndroid Build Coastguard Worker // No absolute axes
169*e01b6f76SAndroid Build Coastguard Worker // No switches
170*e01b6f76SAndroid Build Coastguard Worker node->addInputProperty(INPUT_PROP_DIRECT);
171*e01b6f76SAndroid Build Coastguard Worker return node;
172*e01b6f76SAndroid Build Coastguard Worker }
173*e01b6f76SAndroid Build Coastguard Worker
getMidPowerBtn()174*e01b6f76SAndroid Build Coastguard Worker MockInputDeviceNode* getMidPowerBtn() {
175*e01b6f76SAndroid Build Coastguard Worker auto node = new MockInputDeviceNode();
176*e01b6f76SAndroid Build Coastguard Worker node->setPath("/dev/input/event1");
177*e01b6f76SAndroid Build Coastguard Worker node->setName("mid_powerbtn");
178*e01b6f76SAndroid Build Coastguard Worker node->setLocation("power-button/input0");
179*e01b6f76SAndroid Build Coastguard Worker // UniqueId not set
180*e01b6f76SAndroid Build Coastguard Worker node->setBusType(0x0019);
181*e01b6f76SAndroid Build Coastguard Worker node->setVendorId(0);
182*e01b6f76SAndroid Build Coastguard Worker node->setProductId(0);
183*e01b6f76SAndroid Build Coastguard Worker node->setVersion(0);
184*e01b6f76SAndroid Build Coastguard Worker node->addKeys(KEY_POWER);
185*e01b6f76SAndroid Build Coastguard Worker // No relative axes
186*e01b6f76SAndroid Build Coastguard Worker // No absolute axes
187*e01b6f76SAndroid Build Coastguard Worker // No switches
188*e01b6f76SAndroid Build Coastguard Worker node->addInputProperty(INPUT_PROP_DIRECT);
189*e01b6f76SAndroid Build Coastguard Worker return node;
190*e01b6f76SAndroid Build Coastguard Worker }
191*e01b6f76SAndroid Build Coastguard Worker
getNexusRemote()192*e01b6f76SAndroid Build Coastguard Worker MockInputDeviceNode* getNexusRemote() {
193*e01b6f76SAndroid Build Coastguard Worker auto node = new MockInputDeviceNode();
194*e01b6f76SAndroid Build Coastguard Worker node->setPath("/dev/input/event2");
195*e01b6f76SAndroid Build Coastguard Worker node->setName("Nexus Remote");
196*e01b6f76SAndroid Build Coastguard Worker // Location not set
197*e01b6f76SAndroid Build Coastguard Worker node->setUniqueId("78:86:D9:50:A0:54");
198*e01b6f76SAndroid Build Coastguard Worker node->setBusType(0x0005);
199*e01b6f76SAndroid Build Coastguard Worker node->setVendorId(0x18d1);
200*e01b6f76SAndroid Build Coastguard Worker node->setProductId(0x2c42);
201*e01b6f76SAndroid Build Coastguard Worker node->setVersion(0);
202*e01b6f76SAndroid Build Coastguard Worker node->addKeys(KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_BACK, KEY_PLAYPAUSE,
203*e01b6f76SAndroid Build Coastguard Worker KEY_HOMEPAGE, KEY_SEARCH, KEY_SELECT);
204*e01b6f76SAndroid Build Coastguard Worker // No relative axes
205*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_MISC, nullptr);
206*e01b6f76SAndroid Build Coastguard Worker // No switches
207*e01b6f76SAndroid Build Coastguard Worker node->addInputProperty(INPUT_PROP_DIRECT);
208*e01b6f76SAndroid Build Coastguard Worker return node;
209*e01b6f76SAndroid Build Coastguard Worker }
210*e01b6f76SAndroid Build Coastguard Worker
getAsusGamepad()211*e01b6f76SAndroid Build Coastguard Worker MockInputDeviceNode* getAsusGamepad() {
212*e01b6f76SAndroid Build Coastguard Worker auto node = new MockInputDeviceNode();
213*e01b6f76SAndroid Build Coastguard Worker node->setPath("/dev/input/event3");
214*e01b6f76SAndroid Build Coastguard Worker node->setName("ASUS Gamepad");
215*e01b6f76SAndroid Build Coastguard Worker // Location not set
216*e01b6f76SAndroid Build Coastguard Worker node->setUniqueId("C5:30:CD:50:A0:54");
217*e01b6f76SAndroid Build Coastguard Worker node->setBusType(0x0005);
218*e01b6f76SAndroid Build Coastguard Worker node->setVendorId(0x0b05);
219*e01b6f76SAndroid Build Coastguard Worker node->setProductId(0x4500);
220*e01b6f76SAndroid Build Coastguard Worker node->setVersion(0x0040);
221*e01b6f76SAndroid Build Coastguard Worker node->addKeys(KEY_BACK, KEY_HOMEPAGE, BTN_A, BTN_B, BTN_X, BTN_Y, BTN_TL, BTN_TR,
222*e01b6f76SAndroid Build Coastguard Worker BTN_MODE, BTN_THUMBL, BTN_THUMBR);
223*e01b6f76SAndroid Build Coastguard Worker // No relative axes
224*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_X, nullptr);
225*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_Y, nullptr);
226*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_Z, nullptr);
227*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_RZ, nullptr);
228*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_GAS, nullptr);
229*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_BRAKE, nullptr);
230*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_HAT0X, nullptr);
231*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_HAT0Y, nullptr);
232*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(ABS_MISC, nullptr);
233*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(0x29, nullptr);
234*e01b6f76SAndroid Build Coastguard Worker node->addAbsAxis(0x2a, nullptr);
235*e01b6f76SAndroid Build Coastguard Worker // No switches
236*e01b6f76SAndroid Build Coastguard Worker node->addInputProperty(INPUT_PROP_DIRECT);
237*e01b6f76SAndroid Build Coastguard Worker // Note: this device has MSC and LED bitmaps as well.
238*e01b6f76SAndroid Build Coastguard Worker return node;
239*e01b6f76SAndroid Build Coastguard Worker }
240*e01b6f76SAndroid Build Coastguard Worker
241*e01b6f76SAndroid Build Coastguard Worker } // namespace MockNexusPlayer
242*e01b6f76SAndroid Build Coastguard Worker
243*e01b6f76SAndroid Build Coastguard Worker } // namespace android
244