diff options
-rw-r--r-- | touch/GloveMode.cpp | 23 | ||||
-rw-r--r-- | touch/GloveMode.h | 1 | ||||
-rw-r--r-- | touch/vendor.lineage.touch@1.0-service.shinano.rc | 2 |
3 files changed, 20 insertions, 6 deletions
diff --git a/touch/GloveMode.cpp b/touch/GloveMode.cpp index 39cee8d..5ba1bd3 100644 --- a/touch/GloveMode.cpp +++ b/touch/GloveMode.cpp @@ -26,10 +26,21 @@ namespace touch { namespace V1_0 { namespace implementation { -constexpr const char kGlovePath[] = "/sys/devices/virtual/input/clearpad/glove"; +constexpr const char kGlovePathClearpad[] = "/sys/devices/virtual/input/clearpad/glove"; +constexpr const char kGlovePathMax1187x[] = "/sys/devices/virtual/input/max1187x/glove"; GloveMode::GloveMode() { - mHasGloveMode = !access(kGlovePath, F_OK); + mHasGloveMode = false; + + if (!access(kGlovePathClearpad, F_OK)) { + LOG(INFO) << "Detected clearpad touchscreen."; + mHasGloveMode = true; + mGloveSysfsPath = kGlovePathClearpad; + } else if (!access(kGlovePathMax1187x, F_OK)) { + LOG(INFO) << "Detected max1187x touchscreen."; + mHasGloveMode = true; + mGloveSysfsPath = kGlovePathMax1187x; + } } // Methods from ::vendor::lineage::touch::V1_0::IGloveMode follow. @@ -38,8 +49,8 @@ Return<bool> GloveMode::isEnabled() { if (!mHasGloveMode) return false; - if (!android::base::ReadFileToString(kGlovePath, &buf)) { - LOG(ERROR) << "Failed to read " << kGlovePath; + if (!android::base::ReadFileToString(mGloveSysfsPath, &buf)) { + LOG(ERROR) << "Failed to read " << mGloveSysfsPath; return false; } @@ -49,8 +60,8 @@ Return<bool> GloveMode::isEnabled() { Return<bool> GloveMode::setEnabled(bool enabled) { if (!mHasGloveMode) return false; - if (!android::base::WriteStringToFile((enabled ? "1" : "0"), kGlovePath)) { - LOG(ERROR) << "Failed to write " << kGlovePath; + if (!android::base::WriteStringToFile((enabled ? "1" : "0"), mGloveSysfsPath)) { + LOG(ERROR) << "Failed to write " << mGloveSysfsPath; return false; } diff --git a/touch/GloveMode.h b/touch/GloveMode.h index ccf4ad0..7480cac 100644 --- a/touch/GloveMode.h +++ b/touch/GloveMode.h @@ -36,6 +36,7 @@ class GloveMode : public IGloveMode { private: bool mHasGloveMode; + std::string mGloveSysfsPath; }; } // namespace implementation diff --git a/touch/vendor.lineage.touch@1.0-service.shinano.rc b/touch/vendor.lineage.touch@1.0-service.shinano.rc index 682b044..e8a783e 100644 --- a/touch/vendor.lineage.touch@1.0-service.shinano.rc +++ b/touch/vendor.lineage.touch@1.0-service.shinano.rc @@ -1,6 +1,8 @@ on boot chown system system /sys/devices/virtual/input/clearpad/glove + chown system system /sys/devices/virtual/input/max1187x/glove chmod 0660 /sys/devices/virtual/input/clearpad/glove + chmod 0660 /sys/devices/virtual/input/max1187x/glove service vendor.touch-hal-1-0 /vendor/bin/hw/vendor.lineage.touch@1.0-service.shinano class hal |