Rtwo/device/motorola/sm8550-common/touch/TouchscreenGesture.cpp
2025-09-30 19:22:48 -05:00

47 lines
1.4 KiB
C++

/*
* SPDX-FileCopyrightText: The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#define LOG_TAG "TouchscreenGestureService"
#include <fstream>
#include <android-base/file.h>
#include <android-base/logging.h>
#include "TouchscreenGesture.h"
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
ndk::ScopedAStatus TouchscreenGesture::getSupportedGestures(std::vector<Gesture>* _aidl_return) {
std::vector<Gesture> gestures;
for (int32_t i = 0; i < std::size(kGestureNodes); ++i) {
gestures.push_back({i, kGestureNodes[i].name, kGestureNodes[i].keycode});
}
*_aidl_return = gestures;
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus TouchscreenGesture::setGestureEnabled(const Gesture& gesture, bool enable) {
if (gesture.id >= std::size(kGestureNodes)) {
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
if (!android::base::WriteStringToFile(enable ? kGestureNodes[gesture.id].enable : kGestureNodes[gesture.id].disable,
kGestureNodes[gesture.id].path)) {
LOG(ERROR) << "Writing to file " << kGestureNodes[gesture.id].path << " failed";
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
return ndk::ScopedAStatus::ok();
}
} // namespace touch
} // namespace lineage
} // namespace vendor
} // namespace aidl