/* * Copyright (C) 2020 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include // defines from drivers/input/touchscreen/xiaomi/xiaomi_touch.h #define SET_CUR_VALUE 0 #define Touch_Doubletap_Mode 14 #define TOUCH_DEV_PATH "/dev/xiaomi-touch" #define TOUCH_MAGIC 0x5400 #define TOUCH_IOC_SETMODE TOUCH_MAGIC + SET_CUR_VALUE namespace aidl { namespace google { namespace hardware { namespace power { namespace impl { namespace pixel { using ::aidl::android::hardware::power::Mode; bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return) { switch (type) { case Mode::DOUBLE_TAP_TO_WAKE: *_aidl_return = true; return true; default: return false; } } bool setDeviceSpecificMode(Mode type, bool enabled) { switch (type) { case Mode::DOUBLE_TAP_TO_WAKE: { int fd = open(TOUCH_DEV_PATH, O_RDWR); int arg[2] = {Touch_Doubletap_Mode, enabled ? 1 : 0}; ioctl(fd, TOUCH_IOC_SETMODE, &arg); close(fd); return true; } default: return false; } } } // namespace pixel } // namespace impl } // namespace power } // namespace hardware } // namespace google } // namespace aidl