55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
/*
|
|
* SPDX-FileCopyrightText: 2025 The LineageOS Project
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <fstream>
|
|
|
|
#include "TouchscreenGesture.h"
|
|
|
|
namespace aidl {
|
|
namespace vendor {
|
|
namespace lineage {
|
|
namespace touch {
|
|
|
|
const std::map<int32_t, TouchscreenGesture::GestureInfo> TouchscreenGesture::kGestureInfoMap = {
|
|
// clang-format off
|
|
{0, {0x1c7, "Single Tap"}},
|
|
// clang-format on
|
|
};
|
|
|
|
bool TouchscreenGesture::isSupported() {
|
|
std::ifstream file(TSP_CMD_LIST_NODE);
|
|
if (file.is_open()) {
|
|
std::string line;
|
|
while (getline(file, line)) {
|
|
if (!line.compare("singletap_enable")) return true;
|
|
}
|
|
file.close();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
ndk::ScopedAStatus TouchscreenGesture::getSupportedGestures(std::vector<Gesture>* _aidl_return) {
|
|
std::vector<Gesture> gestures;
|
|
|
|
for (const auto& entry : kGestureInfoMap) {
|
|
gestures.push_back({entry.first, entry.second.name, entry.second.keycode});
|
|
}
|
|
|
|
*_aidl_return = gestures;
|
|
return ndk::ScopedAStatus::ok();
|
|
}
|
|
|
|
ndk::ScopedAStatus TouchscreenGesture::setGestureEnabled(const Gesture& gesture, bool enabled) {
|
|
std::ofstream file(TSP_CMD_NODE);
|
|
file << "singletap_enable," << (enabled ? "1" : "0");
|
|
|
|
return ndk::ScopedAStatus::ok();
|
|
}
|
|
|
|
} // namespace touch
|
|
} // namespace lineage
|
|
} // namespace vendor
|
|
} // namespace aidl
|