1 /*
2  * Copyright 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.cts.input
18 
19 import android.app.Instrumentation
20 import android.view.InputDevice.SOURCE_KEYBOARD
21 
createKeyboardRegisterCommandnull22 private fun createKeyboardRegisterCommand(): UinputRegisterCommand {
23     val configurationItems = listOf(
24         ConfigurationItem("UI_SET_EVBIT", listOf("EV_KEY")),
25         ConfigurationItem("UI_SET_KEYBIT", listOf(
26             "KEY_Q", "KEY_W", "KEY_E", "KEY_A", "KEY_B", "KEY_C", "KEY_BACKSPACE", "KEY_ESC",
27             "KEY_LEFTALT", "KEY_LEFTMETA", "KEY_LEFT", "KEY_LEFTSHIFT", "KEY_CAPSLOCK",
28         ))
29     )
30 
31     return UinputRegisterCommand(
32         id = 1,
33         name = "Test Keyboard (USB)",
34         vid = 0x18d1,
35         pid = 0xabcd,
36         bus = "usb",
37         port = "usb:1",
38         configuration = configurationItems,
39         absInfo = emptyMap(),
40     )
41 }
42 
43 /**
44  * A Keyboard that only has a few common keys (lots of keys are missing, for simplicity).
45  */
46 class UinputKeyboard(instrumentation: Instrumentation) : UinputDevice(
47     instrumentation,
48     SOURCE_KEYBOARD,
49     createKeyboardRegisterCommand()
50 )
51