You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
device_samsung_sm7125-common/touch/TouchscreenGesture.cpp

68 lines
1.9 KiB

/*
* Copyright (C) 2019 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <fstream>
#include "TouchscreenGesture.h"
namespace vendor {
namespace lineage {
namespace touch {
namespace V1_0 {
namespace samsung {
static constexpr const char* kTspPath = TSP_CMD_NODE;
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(kTspPath);
return file.good();
}
// Methods from ::vendor::lineage::touch::V1_0::ITouchscreenGesture follow.
Return<void> TouchscreenGesture::getSupportedGestures(getSupportedGestures_cb resultCb) {
std::vector<Gesture> gestures;
for (const auto& entry : kGestureInfoMap) {
gestures.push_back({entry.first, entry.second.name, entry.second.keycode});
}
resultCb(gestures);
return Void();
}
Return<bool> TouchscreenGesture::setGestureEnabled(
const ::vendor::lineage::touch::V1_0::Gesture&, bool enabled) {
std::fstream file(kTspPath);
file << "singletap_enable," << (enabled ? "1" : "0");
return !file.fail();
}
// Methods from ::android::hidl::base::V1_0::IBase follow.
} // namespace samsung
} // namespace V1_0
} // namespace touch
} // namespace lineage
} // namespace vendor