1c29fa5a6Sopenharmony_ci/* 2c29fa5a6Sopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3c29fa5a6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4c29fa5a6Sopenharmony_ci * you may not use this file except in compliance with the License. 5c29fa5a6Sopenharmony_ci * You may obtain a copy of the License at 6c29fa5a6Sopenharmony_ci * 7c29fa5a6Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8c29fa5a6Sopenharmony_ci * 9c29fa5a6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10c29fa5a6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11c29fa5a6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12c29fa5a6Sopenharmony_ci * See the License for the specific language governing permissions and 13c29fa5a6Sopenharmony_ci * limitations under the License. 14c29fa5a6Sopenharmony_ci */ 15c29fa5a6Sopenharmony_ci 16c29fa5a6Sopenharmony_ci#include "virtual_gamepad.h" 17c29fa5a6Sopenharmony_ci 18c29fa5a6Sopenharmony_cinamespace OHOS { 19c29fa5a6Sopenharmony_cinamespace MMI { 20c29fa5a6Sopenharmony_cinamespace { 21c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_RXYZ = 255; 22c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_FLAT = 15; 23c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MIN_HAT = -1; 24c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MIN_VALUE = -32768; 25c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_VALUE = 32767; 26c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_FUZZ_VALUE = 16; 27c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_FLAT_VALUE = 128; 28c29fa5a6Sopenharmony_ci 29c29fa5a6Sopenharmony_ciAbsInfo absInfos[] = { 30c29fa5a6Sopenharmony_ci { ABS_X, 0, ABS_MAX_RXYZ, 0, ABS_FLAT }, 31c29fa5a6Sopenharmony_ci { ABS_Y, 0, ABS_MAX_RXYZ, 0, ABS_FLAT }, 32c29fa5a6Sopenharmony_ci { ABS_Z, 0, ABS_MAX_RXYZ, 0, ABS_FLAT }, 33c29fa5a6Sopenharmony_ci { ABS_RX, ABS_MIN_VALUE, ABS_MAX_RXYZ, ABS_FUZZ_VALUE, ABS_FLAT_VALUE }, 34c29fa5a6Sopenharmony_ci { ABS_RY, ABS_MIN_VALUE, ABS_MAX_VALUE, ABS_FUZZ_VALUE, ABS_FLAT_VALUE }, 35c29fa5a6Sopenharmony_ci { ABS_RZ, 0, ABS_MAX_RXYZ, 0, ABS_FLAT }, 36c29fa5a6Sopenharmony_ci { ABS_GAS, 0, ABS_MAX_RXYZ, 0, ABS_FLAT }, 37c29fa5a6Sopenharmony_ci { ABS_BRAKE, 0, ABS_MAX_RXYZ, 0, ABS_FLAT }, 38c29fa5a6Sopenharmony_ci { ABS_HAT0X, ABS_MIN_HAT, 1, 0, 0 }, 39c29fa5a6Sopenharmony_ci { ABS_HAT0Y, ABS_MIN_HAT, 1, 0, 0 } 40c29fa5a6Sopenharmony_ci}; 41c29fa5a6Sopenharmony_ci} // namespace 42c29fa5a6Sopenharmony_ci 43c29fa5a6Sopenharmony_ciVirtualGamePad::VirtualGamePad() : VirtualDevice("Virtual GamePad", BUS_USB, 0x79, 0x181c) 44c29fa5a6Sopenharmony_ci{ 45c29fa5a6Sopenharmony_ci eventTypes_ = { EV_KEY, EV_ABS, EV_MSC }; 46c29fa5a6Sopenharmony_ci abs_ = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ, ABS_GAS, ABS_BRAKE, ABS_HAT0X, ABS_HAT0Y }; 47c29fa5a6Sopenharmony_ci keys_ = { 48c29fa5a6Sopenharmony_ci KEY_HOMEPAGE, BTN_SOUTH, BTN_EAST, BTN_C, BTN_NORTH, BTN_WEST, BTN_Z, BTN_TL, BTN_TR, 49c29fa5a6Sopenharmony_ci BTN_TL2, BTN_TR2, BTN_SELECT, BTN_START, BTN_MODE, BTN_THUMBL, BTN_THUMBR 50c29fa5a6Sopenharmony_ci }; 51c29fa5a6Sopenharmony_ci miscellaneous_ = { MSC_SCAN }; 52c29fa5a6Sopenharmony_ci 53c29fa5a6Sopenharmony_ci for (const auto &item : absInfos) { 54c29fa5a6Sopenharmony_ci SetAbsValue(item); 55c29fa5a6Sopenharmony_ci } 56c29fa5a6Sopenharmony_ci} 57c29fa5a6Sopenharmony_ci} // namespace MMI 58c29fa5a6Sopenharmony_ci} // namespace OHOS