/* * Copyright (c) Hisilicon Technologies Co., Ltd. 2020-2022. All rights reserved. * Description: virtualkeypad input * Author: App-Dev Group * Create: 2020-06-16 */ #ifndef ANDROID_VIRTUALKEYPAD_H #define ANDROID_VIRTUALKEYPAD_H #include #include #include "LsadcInterface.h" #include "GpioPowerInterface.h" namespace android { class VirtualKeypad { public: VirtualKeypad(){} ~VirtualKeypad(){} static const int maxKeypadCh = 4; static const td_u32 invalidKey = 0x0; // gpio keypad information std::vector boardKpd = {}; const std::unique_ptr gpioPowerInterface = std::make_unique(); const std::unique_ptr lsadcInterface = std::make_unique(); td_u32 channelMask = -1; void ThreadProcess(); void InitLSADCConfig(); void ProcessKey(td_u32 key); td_u32 MapKeyValue(int keyPadTabIdx, td_u32 origValue) const; td_u32 GetKeyPadPowerValue(std::vector& powerKeyCode, td_u32 length) const; private: static const int maxChNum = 4; static const int keyLevelMaxNum = 8; static const int keyOffTime = 100; // key off time 100ms static const int repeatHoldTime = 405; static const int repeatInterval = 67; const int channelIdMaxValue = 255; void SetChannelMask(td_u32& u32ChannelMask); int TimeAfter(const struct timeval& bef, const struct timeval& cur, unsigned int ms) const; }; } #endif // android_VirtualKeypad_H