hidl: touch: Add binderized service implementation
* Change default ::implementation namespace to ::samsung
* Fill in required methods for used impls
* Cleanup passthrough code for used impls
* Add and setup binderized service
Change-Id: Iadc3b6e385233d103c3349ce31a08d6d040886c7
diff --git a/lineagehw/hidl/touch/TouchscreenGesture.cpp b/lineagehw/hidl/touch/TouchscreenGesture.cpp
index cadea2b..1f47115 100644
--- a/lineagehw/hidl/touch/TouchscreenGesture.cpp
+++ b/lineagehw/hidl/touch/TouchscreenGesture.cpp
@@ -14,33 +14,66 @@
* limitations under the License.
*/
+#include <fstream>
+
#include "TouchscreenGesture.h"
namespace vendor {
namespace lineage {
namespace touch {
namespace V1_0 {
-namespace implementation {
+namespace samsung {
+
+static constexpr const char* kGeasturePath = "/sys/class/sec/sec_epen/epen_gestures";
+
+const std::map<int32_t, TouchscreenGesture::GestureInfo> TouchscreenGesture::kGestureInfoMap = {
+ {0, {0x2f1, "Swipe up stylus"}},
+ {1, {0x2f2, "Swipe down stylus"}},
+ {2, {0x2f3, "Swipe left stylus"}},
+ {3, {0x2f4, "Swipe right stylus"}},
+ {4, {0x2f5, "Long press stylus"}},
+};
+
+
+bool TouchscreenGesture::isSupported() {
+ std::ifstream file(kGeasturePath);
+ return file.good();
+}
// Methods from ::vendor::lineage::touch::V1_0::ITouchscreenGesture follow.
-Return<void> TouchscreenGesture::getSupportedGestures(getSupportedGestures_cb _hidl_cb) {
- // TODO implement
+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<void> TouchscreenGesture::setGestureEnabled(const ::vendor::lineage::touch::V1_0::Gesture& gesture, bool enabled) {
- // TODO implement
- return Void();
+Return<bool> TouchscreenGesture::setGestureEnabled(
+ const ::vendor::lineage::touch::V1_0::Gesture& gesture, bool enabled) {
+ std::fstream file(kGeasturePath);
+ int gestureMode;
+ int mask = 1 << gesture.id;
+
+ file >> gestureMode;
+
+ if (enabled)
+ gestureMode |= mask;
+ else
+ gestureMode &= ~mask;
+
+ file << gestureMode;
+
+ return !file.fail();
}
// Methods from ::android::hidl::base::V1_0::IBase follow.
-//ITouchscreenGesture* HIDL_FETCH_ITouchscreenGesture(const char* /* name */) {
- //return new TouchscreenGesture();
-//}
-//
-} // namespace implementation
+} // namespace samsung
} // namespace V1_0
} // namespace touch
} // namespace lineage