From f831bff1e1b0f8eefffcf176c8b469bda8c26f4e Mon Sep 17 00:00:00 2001 From: soulr344 Date: Mon, 16 Aug 2021 09:46:38 +0500 Subject: [PATCH] events: fix haptics on newer Samsung devices Newer Samsung devices have a single file that enables/disables/sets the timeout for vibration in /sys/class/timed_output/vibrator/enable The content of the file determines the state of the vibrator, 0 being vibrator being off and any other value being the time in ms that the vibrator is going to run before resetting to 0 again. Change-Id: I1144e139285494e43b8656229ad6df10d5b48f39 Signed-off-by: soulr344 --- minuitwrp/events.cpp | 7 +++++++ minuitwrp/libminuitwrp_defaults.go | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/minuitwrp/events.cpp b/minuitwrp/events.cpp index 8abf0550..80794a1a 100644 --- a/minuitwrp/events.cpp +++ b/minuitwrp/events.cpp @@ -152,6 +152,13 @@ int vibrate(int timeout_ms) if (vib != nullptr) { vib->on((uint32_t)timeout_ms, nullptr); } +#elif defined(USE_SAMSUNG_HAPTICS) + /* Newer Samsung devices have duration file only + 0 in VIBRATOR_TIMEOUT_FILE means no vibration + Anything else is the vibration running for X milliseconds */ + if (std::ifstream(VIBRATOR_TIMEOUT_FILE).good()) { + write_to_file(VIBRATOR_TIMEOUT_FILE, tout); + } #else if (std::ifstream(LEDS_HAPTICS_ACTIVATE_FILE).good()) { write_to_file(LEDS_HAPTICS_DURATION_FILE, tout); diff --git a/minuitwrp/libminuitwrp_defaults.go b/minuitwrp/libminuitwrp_defaults.go index 92be0a09..802533a1 100644 --- a/minuitwrp/libminuitwrp_defaults.go +++ b/minuitwrp/libminuitwrp_defaults.go @@ -19,6 +19,10 @@ func globalFlags(ctx android.BaseContext) []string { cflags = append(cflags, "-DUSE_QTI_AIDL_HAPTICS") } + if getMakeVars(ctx, "TW_USE_SAMSUNG_HAPTICS") == "true" { + cflags = append(cflags, "-DUSE_SAMSUNG_HAPTICS") + } + if getMakeVars(ctx, "TW_TARGET_USES_QCOM_BSP") == "true" { cflags = append(cflags, "-DMSM_BSP") }