Add:KeyControl test code.
This commit is contained in:
parent
1ada288d3f
commit
48a5c6f4ba
|
@ -24,7 +24,6 @@ using VirtualKeyEvent = unsigned char;
|
||||||
constexpr int INVALID_PERIOD = -1;
|
constexpr int INVALID_PERIOD = -1;
|
||||||
constexpr int PERIPHERAL_CHECK_PERIOD_MS = 100;
|
constexpr int PERIPHERAL_CHECK_PERIOD_MS = 100;
|
||||||
constexpr int IMEI_LEN = 15;
|
constexpr int IMEI_LEN = 15;
|
||||||
// constexpr long int KEY_DO_NOT_HOLD_PRESSING = -1;
|
|
||||||
void CreateHalCppModule(void);
|
void CreateHalCppModule(void);
|
||||||
class VKeyHalMonitor
|
class VKeyHalMonitor
|
||||||
{
|
{
|
||||||
|
@ -41,7 +40,7 @@ public:
|
||||||
VKeyHal() = default;
|
VKeyHal() = default;
|
||||||
virtual ~VKeyHal() = default;
|
virtual ~VKeyHal() = default;
|
||||||
virtual void CheckKeyStatus(void) {}
|
virtual void CheckKeyStatus(void) {}
|
||||||
virtual const std::string GetKeyName(void) { return "undefine"; }
|
// virtual const std::string GetKeyName(void) { return "undefine"; }
|
||||||
virtual void GetHoldPressingTimeMs(long int &holdTimeMs, VirtualKeyEvent &event) {}
|
virtual void GetHoldPressingTimeMs(long int &holdTimeMs, VirtualKeyEvent &event) {}
|
||||||
virtual void SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor) {}
|
virtual void SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor) {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -84,10 +84,10 @@ void KeyManager::GetAllKeysState(std::map<std::string, KeyStatus> &status)
|
||||||
}
|
}
|
||||||
void KeyManager::SetAllKeysMonitor(void)
|
void KeyManager::SetAllKeysMonitor(void)
|
||||||
{
|
{
|
||||||
|
std::shared_ptr<VKeyHalMonitor> monitor = shared_from_this();
|
||||||
std::map<std::string, std::shared_ptr<VKeyHal>>::iterator iter;
|
std::map<std::string, std::shared_ptr<VKeyHal>>::iterator iter;
|
||||||
for (iter = mAllKeyHal.begin(); iter != mAllKeyHal.end(); ++iter) {
|
for (iter = mAllKeyHal.begin(); iter != mAllKeyHal.end(); ++iter) {
|
||||||
std::shared_ptr<VKeyHal> keyHal = iter->second;
|
std::shared_ptr<VKeyHal> keyHal = iter->second;
|
||||||
std::shared_ptr<VKeyHalMonitor> monitor = shared_from_this();
|
|
||||||
keyHal->SetKeyMonitor(monitor);
|
keyHal->SetKeyMonitor(monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,20 +71,22 @@ public:
|
||||||
class KeyControlTest : public KeyControl, public VKeyHal
|
class KeyControlTest : public KeyControl, public VKeyHal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KeyControlTest() = default;
|
KeyControlTest(const std::string &keyName);
|
||||||
virtual ~KeyControlTest() = default;
|
virtual ~KeyControlTest() = default;
|
||||||
unsigned int GetStatusCheckPeriodMs(void) override { return PERIPHERAL_CHECK_PERIOD_MS; }
|
unsigned int GetStatusCheckPeriodMs(void) override { return PERIPHERAL_CHECK_PERIOD_MS; }
|
||||||
void SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor) override;
|
void SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor) override;
|
||||||
void CheckKeyStatus(void) override;
|
void CheckKeyStatus(void) override;
|
||||||
void KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs) override;
|
void KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs) override;
|
||||||
|
const std::string GetKeyName(void) override { return mKeyName; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<VKeyHalMonitor> mMonitor;
|
const std::string mKeyName;
|
||||||
|
std::weak_ptr<VKeyHalMonitor> mMonitor;
|
||||||
};
|
};
|
||||||
class KeyControlMock : public KeyControlTest
|
class KeyControlMock : public KeyControlTest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KeyControlMock() = default;
|
KeyControlMock(const std::string &keyName);
|
||||||
virtual ~KeyControlMock() = default;
|
virtual ~KeyControlMock() = default;
|
||||||
void SetKeyEvent(const KeyHalEvent &event);
|
void SetKeyEvent(const KeyHalEvent &event);
|
||||||
};
|
};
|
||||||
|
@ -97,6 +99,7 @@ public:
|
||||||
void UnInit(void);
|
void UnInit(void);
|
||||||
void SetAllKeysResult(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys);
|
void SetAllKeysResult(std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys);
|
||||||
void SetKeyEvent(const std::string keyName, const KeyHalEvent &event);
|
void SetKeyEvent(const std::string keyName, const KeyHalEvent &event);
|
||||||
|
void SetKeyClick(const std::string &keyName, const unsigned int &pressingTimeMs = 200);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void HalMockInit(std::shared_ptr<HalCppMock> &mock);
|
void HalMockInit(std::shared_ptr<HalCppMock> &mock);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "HalTestTool.h"
|
#include "HalTestTool.h"
|
||||||
#include "HalMakePtrTest.h"
|
#include "HalMakePtrTest.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
#include <thread>
|
||||||
StatusCode HalCppTest::GetLedHals(std::vector<std::shared_ptr<VLedHal>> &ledHals)
|
StatusCode HalCppTest::GetLedHals(std::vector<std::shared_ptr<VLedHal>> &ledHals)
|
||||||
{
|
{
|
||||||
LogInfo("HalCppTest::GetLedHals\n");
|
LogInfo("HalCppTest::GetLedHals\n");
|
||||||
|
@ -43,6 +44,10 @@ StatusCode HalCppTest::GetAllKeysTrace(std::map<std::string, std::shared_ptr<VKe
|
||||||
LogInfo("HalCppTest::GetAllKeysTrace\n");
|
LogInfo("HalCppTest::GetAllKeysTrace\n");
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||||
}
|
}
|
||||||
|
KeyControlTest::KeyControlTest(const std::string &keyName) : mKeyName(keyName)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
void KeyControlTest::SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor)
|
void KeyControlTest::SetKeyMonitor(std::shared_ptr<VKeyHalMonitor> &monitor)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
@ -55,8 +60,17 @@ void KeyControlTest::CheckKeyStatus(void)
|
||||||
}
|
}
|
||||||
void KeyControlTest::KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs)
|
void KeyControlTest::KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs)
|
||||||
{
|
{
|
||||||
LogInfo("KeyEventTrigger time = %u\n", timeMs);
|
LogInfo("KeyEventTrigger keyName = %s, event = %s, time = %u\n", keyName.c_str(), PrintKeyEvent(event), timeMs);
|
||||||
mMonitor->KeyEventHappened(keyName, static_cast<VirtualKeyEvent>(event), timeMs);
|
auto monitor = mMonitor.lock();
|
||||||
|
if (mMonitor.expired()) {
|
||||||
|
LogError("monitor is nullptr.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
monitor->KeyEventHappened(keyName, static_cast<VirtualKeyEvent>(event), timeMs);
|
||||||
|
}
|
||||||
|
KeyControlMock::KeyControlMock(const std::string &keyName) : KeyControlTest(keyName)
|
||||||
|
{
|
||||||
|
//
|
||||||
}
|
}
|
||||||
void KeyControlMock::SetKeyEvent(const KeyHalEvent &event)
|
void KeyControlMock::SetKeyEvent(const KeyHalEvent &event)
|
||||||
{
|
{
|
||||||
|
@ -71,8 +85,6 @@ void HalTestTool::Init(void)
|
||||||
}
|
}
|
||||||
void HalTestTool::UnInit(void)
|
void HalTestTool::UnInit(void)
|
||||||
{
|
{
|
||||||
// std::shared_ptr<IHalCpp> impl = std::make_shared<IHalCpp>();
|
|
||||||
// IHalCpp::GetInstance(&impl);
|
|
||||||
mHalMock.reset();
|
mHalMock.reset();
|
||||||
CancelOverrideHalMakePtrObject();
|
CancelOverrideHalMakePtrObject();
|
||||||
}
|
}
|
||||||
|
@ -90,6 +102,21 @@ void HalTestTool::SetKeyEvent(const std::string keyName, const KeyHalEvent &even
|
||||||
}
|
}
|
||||||
key->SetKeyEvent(event);
|
key->SetKeyEvent(event);
|
||||||
}
|
}
|
||||||
|
void HalTestTool::SetKeyClick(const std::string &keyName, const unsigned int &pressingTimeMs)
|
||||||
|
{
|
||||||
|
std::shared_ptr<KeyControlMock> key = SearchKey(keyName);
|
||||||
|
if (!key) {
|
||||||
|
LogError("Can't set key event, key not found.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto keyClickThread = [=](std::shared_ptr<KeyControlMock> key) {
|
||||||
|
key->KeyHalEventTrigger(KeyHalEvent::PRESSING);
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(pressingTimeMs));
|
||||||
|
key->KeyHalEventTrigger(KeyHalEvent::NOT_PRESSING);
|
||||||
|
};
|
||||||
|
std::thread clickThread = std::thread(keyClickThread, key);
|
||||||
|
clickThread.detach();
|
||||||
|
}
|
||||||
void HalTestTool::SetAllKeysResult(std::shared_ptr<HalCppMock> &mock,
|
void HalTestTool::SetAllKeysResult(std::shared_ptr<HalCppMock> &mock,
|
||||||
std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys)
|
std::map<std::string, std::shared_ptr<VKeyHal>> &allKeys)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
namespace DeviceManagerTest
|
namespace DeviceManagerTest
|
||||||
{
|
{
|
||||||
|
const char *KEY_TEST = "TEST";
|
||||||
class DeviceManagerTest : public testing::Test, public HalTestTool
|
class DeviceManagerTest : public testing::Test, public HalTestTool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -33,10 +34,7 @@ public:
|
||||||
static void TearDownTestCase() { ILogUnInit(); }
|
static void TearDownTestCase() { ILogUnInit(); }
|
||||||
virtual void SetUp()
|
virtual void SetUp()
|
||||||
{
|
{
|
||||||
// mLinuxTest = LinuxTest::CreateLinuxTest();
|
CreateAllKeysMcok();
|
||||||
// std::shared_ptr<LinuxApiMock> test = mLinuxTest;
|
|
||||||
// LinuxApiMock::GetInstance(&test);
|
|
||||||
// LinuxApiMock::GetInstance()->Init();
|
|
||||||
HalTestTool::Init();
|
HalTestTool::Init();
|
||||||
CreateHalCppModule();
|
CreateHalCppModule();
|
||||||
CreateDeviceManagerModule();
|
CreateDeviceManagerModule();
|
||||||
|
@ -44,28 +42,36 @@ public:
|
||||||
}
|
}
|
||||||
virtual void TearDown()
|
virtual void TearDown()
|
||||||
{
|
{
|
||||||
// LinuxApiMock::GetInstance()->UnInit();
|
|
||||||
// mLinuxTest = std::make_shared<LinuxTest>();
|
|
||||||
// std::shared_ptr<LinuxApiMock> test = std::make_shared<LinuxApiMock>();
|
|
||||||
// LinuxApiMock::GetInstance(&test);
|
|
||||||
HalTestTool::UnInit();
|
HalTestTool::UnInit();
|
||||||
// DestroyMcuManager();
|
|
||||||
DestroyDeviceManagerModule();
|
DestroyDeviceManagerModule();
|
||||||
|
DestroyAllKeysMock();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void CreateAllKeysMcok(void)
|
||||||
|
{
|
||||||
|
std::shared_ptr<KeyControlMock> key = std::make_shared<KeyControlMock>(KEY_TEST);
|
||||||
|
mAllKeysMock[KEY_TEST] = key;
|
||||||
|
}
|
||||||
|
void DestroyAllKeysMock(void)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
mAllKeysMock.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// std::shared_ptr<LinuxTest> mLinuxTest;
|
// std::shared_ptr<LinuxTest> mLinuxTest;
|
||||||
|
protected:
|
||||||
|
std::map<std::string, std::shared_ptr<VKeyHal>> mAllKeysMock;
|
||||||
};
|
};
|
||||||
// ../output_files/test/bin/DeviceManagerTest --gtest_filter=DeviceManagerTest.INTEGRATION_DeviceManager_EXAMPLE_Demo
|
// ../output_files/test/bin/DeviceManagerTest --gtest_filter=DeviceManagerTest.INTEGRATION_DeviceManager_EXAMPLE_Demo
|
||||||
TEST_F(DeviceManagerTest, INTEGRATION_DeviceManager_EXAMPLE_Demo)
|
TEST_F(DeviceManagerTest, INTEGRATION_DeviceManager_EXAMPLE_Demo)
|
||||||
{
|
{
|
||||||
std::map<std::string, std::shared_ptr<VKeyHal>> allKeys;
|
SetAllKeysResult(mAllKeysMock);
|
||||||
std::shared_ptr<KeyControlMock> key = std::make_shared<KeyControlMock>();
|
|
||||||
allKeys["test"] = key;
|
|
||||||
SetAllKeysResult(allKeys);
|
|
||||||
IDeviceManager::GetInstance()->Init();
|
IDeviceManager::GetInstance()->Init();
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||||
SetKeyEvent("test", KeyHalEvent::PRESSING);
|
// SetKeyEvent(KEY_TEST, KeyHalEvent::PRESSING);
|
||||||
|
SetKeyClick(KEY_TEST);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||||
IDeviceManager::GetInstance()->UnInit();
|
IDeviceManager::GetInstance()->UnInit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
constexpr long int KEY_DO_NOT_HOLD_PRESSING = -1;
|
|
||||||
constexpr int KEY_ACTION_LONG_CLICK = 1000 * 5;
|
|
||||||
constexpr int KEY_ACTION_SHORT_CLICK = 200;
|
constexpr int KEY_ACTION_SHORT_CLICK = 200;
|
||||||
constexpr int KEY_ACTION_HOLD_DWON = 500;
|
constexpr int KEY_ACTION_HOLD_DWON = 500;
|
||||||
constexpr long int KEY_NOT_PRESSING = -1;
|
constexpr long int KEY_NOT_PRESSING = -1;
|
||||||
|
@ -42,25 +40,19 @@ public:
|
||||||
virtual ~VKeyControl() = default;
|
virtual ~VKeyControl() = default;
|
||||||
virtual const std::string GetKeyName(void) { return "undefine"; }
|
virtual const std::string GetKeyName(void) { return "undefine"; }
|
||||||
virtual unsigned int GetStatusCheckPeriodMs(void) { return 0; }
|
virtual unsigned int GetStatusCheckPeriodMs(void) { return 0; }
|
||||||
virtual void KeyHalEventTrigger(const KeyHalEvent &event) {}
|
|
||||||
virtual void KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs) {}
|
virtual void KeyEventTrigger(const std::string &keyName, const KeyEvent &event, const unsigned int &timeMs) {}
|
||||||
virtual void TimerKeyEventTrigger(const KeyHalEvent &event) {}
|
|
||||||
virtual long int GetHoldPressingTimeMs(void) { return KEY_DO_NOT_HOLD_PRESSING; }
|
|
||||||
};
|
};
|
||||||
// using KeyActionReport = std::function<void(const std::string &, const KeyEvent &, const unsigned int &)>;
|
|
||||||
class KeyControl : public VKeyControl, public std::enable_shared_from_this<KeyControl>
|
class KeyControl : public VKeyControl, public std::enable_shared_from_this<KeyControl>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KeyControl();
|
KeyControl();
|
||||||
// KeyControl(std::shared_ptr<VKeyControl> &keyHal, const KeyActionReport &keyAction,
|
virtual ~KeyControl();
|
||||||
// const long int &longClickTime = KEY_ACTION_LONG_CLICK);
|
|
||||||
~KeyControl();
|
|
||||||
void KeyHalEventTrigger(const KeyHalEvent &event) override;
|
|
||||||
void TimerKeyEventTrigger(const KeyHalEvent &event) override;
|
|
||||||
long int GetHoldPressingTimeMs(void) override;
|
|
||||||
void Init(void);
|
void Init(void);
|
||||||
void UnInit(void);
|
void UnInit(void);
|
||||||
void ActionReport(const std::string &key, const KeyHalEvent &keyEvent);
|
void KeyHalEventHandle(const std::string &key, const KeyHalEvent &keyEvent);
|
||||||
|
void TimerKeyEventTrigger(const KeyHalEvent &event);
|
||||||
|
void KeyHalEventTrigger(const KeyHalEvent &event);
|
||||||
|
long int GetHoldPressingTimeMs(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void KeyPressingTrigger(const std::string &key);
|
void KeyPressingTrigger(const std::string &key);
|
||||||
|
@ -72,4 +64,5 @@ private:
|
||||||
long int mPressingTime;
|
long int mPressingTime;
|
||||||
long int mLongClickTime;
|
long int mLongClickTime;
|
||||||
};
|
};
|
||||||
|
const char *PrintKeyEvent(const KeyEvent &event);
|
||||||
#endif
|
#endif
|
|
@ -18,35 +18,13 @@ constexpr long int KEY_PRESSING = 0;
|
||||||
constexpr unsigned int NOT_A_HOLD_KEY_ACTION = 0;
|
constexpr unsigned int NOT_A_HOLD_KEY_ACTION = 0;
|
||||||
KeyControl::KeyControl()
|
KeyControl::KeyControl()
|
||||||
{
|
{
|
||||||
// mKeyHal = nullptr;
|
|
||||||
// mKeyActionReport = nullptr;
|
|
||||||
mPressingTime = KEY_NOT_PRESSING;
|
mPressingTime = KEY_NOT_PRESSING;
|
||||||
mLongClickTime = 0;
|
mLongClickTime = 0;
|
||||||
}
|
}
|
||||||
// KeyControl::KeyControl(std::shared_ptr<VKeyControl> &keyHal, const KeyActionReport &keyAction,
|
|
||||||
// const long int &longClickTime)
|
|
||||||
// : mKeyActionReport(keyAction), mLongClickTime(longClickTime)
|
|
||||||
// {
|
|
||||||
// mPressingTime = KEY_NOT_PRESSING;
|
|
||||||
// }
|
|
||||||
KeyControl::~KeyControl() {}
|
KeyControl::~KeyControl() {}
|
||||||
void KeyControl::KeyHalEventTrigger(const KeyHalEvent &event)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> locker(mMutex);
|
|
||||||
ActionReport(GetKeyName(), event);
|
|
||||||
}
|
|
||||||
void KeyControl::TimerKeyEventTrigger(const KeyHalEvent &event)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> locker(mMutex);
|
|
||||||
if (IsKeyPressing()) {
|
|
||||||
ActionReport(GetKeyName(), event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
long int KeyControl::GetHoldPressingTimeMs(void) { return mPressingTime; }
|
|
||||||
bool KeyControl::IsKeyPressing(void) { return mPressingTime >= KEY_PRESSING ? true : false; }
|
bool KeyControl::IsKeyPressing(void) { return mPressingTime >= KEY_PRESSING ? true : false; }
|
||||||
// void KeyControl::Init(void) { SetKeyHalOwner(shared_from_this()); }
|
|
||||||
void KeyControl::UnInit(void) {}
|
void KeyControl::UnInit(void) {}
|
||||||
void KeyControl::ActionReport(const std::string &key, const KeyHalEvent &keyEvent)
|
void KeyControl::KeyHalEventHandle(const std::string &key, const KeyHalEvent &keyEvent)
|
||||||
{
|
{
|
||||||
if (KEY_PRESSING <= mPressingTime) {
|
if (KEY_PRESSING <= mPressingTime) {
|
||||||
mPressingTime += GetStatusCheckPeriodMs();
|
mPressingTime += GetStatusCheckPeriodMs();
|
||||||
|
@ -63,6 +41,23 @@ void KeyControl::ActionReport(const std::string &key, const KeyHalEvent &keyEven
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void KeyControl::TimerKeyEventTrigger(const KeyHalEvent &event)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> locker(mMutex);
|
||||||
|
if (IsKeyPressing()) {
|
||||||
|
KeyHalEventHandle(GetKeyName(), event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void KeyControl::KeyHalEventTrigger(const KeyHalEvent &event)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> locker(mMutex);
|
||||||
|
KeyHalEventHandle(GetKeyName(), event);
|
||||||
|
}
|
||||||
|
long int KeyControl::GetHoldPressingTimeMs(void)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return mPressingTime;
|
||||||
|
}
|
||||||
void KeyControl::KeyPressingTrigger(const std::string &key)
|
void KeyControl::KeyPressingTrigger(const std::string &key)
|
||||||
{
|
{
|
||||||
if (mLongClickTime <= mPressingTime) // Do not support long click, it should be count in application code.
|
if (mLongClickTime <= mPressingTime) // Do not support long click, it should be count in application code.
|
||||||
|
@ -84,4 +79,25 @@ void KeyControl::KeyNotPressingTrigger(const std::string &key)
|
||||||
KeyEventTrigger(key, KeyEvent::HOLD_UP, mPressingTime);
|
KeyEventTrigger(key, KeyEvent::HOLD_UP, mPressingTime);
|
||||||
}
|
}
|
||||||
mPressingTime = KEY_NOT_PRESSING;
|
mPressingTime = KEY_NOT_PRESSING;
|
||||||
|
}
|
||||||
|
const char *PrintKeyEvent(const KeyEvent &event)
|
||||||
|
{
|
||||||
|
switch (event) {
|
||||||
|
case KeyEvent::SHORT_CLICK: {
|
||||||
|
return "SHORT_CLICK";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case KeyEvent::HOLD_DOWN: {
|
||||||
|
return "HOLD_DOWN";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case KeyEvent::HOLD_UP: {
|
||||||
|
return "HOLD_UP";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "unknown event";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user