Files
device_samsung_a71-common/touch/TouchscreenGesture.cpp
Bruno Martins 6c21d28670 a71-common: touch: Migrate to AIDL
Change-Id: Ibbac9b4320fc64c5b6f365b8e9bd977d71d0d4dd
2025-09-02 18:51:48 +01:00

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