Skip to content

Commit

Permalink
TWRP: Enable qti input haptics vibrators support
Browse files Browse the repository at this point in the history
 * these type of vibrators are present in newer devices based on
   board sm8150 & above. Like Oneplus 7 series, Redmi K20 Pro, etc.
 * to enable it add TW_SUPPORT_INPUT_1_2_HAPTICS := true in Boardconfig.mk
 * you will need to add the vendor vibrator service to init and run it in your device tree
Change-Id: I0fe6612def149e70808ca41829b6f7ba0b23cd62
Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
  • Loading branch information
AndroiableDroid authored and bigbiff committed Jun 8, 2020
1 parent 4e37953 commit 909daa9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions minuitwrp/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ LOCAL_SRC_FILES := \
graphics_utils.cpp \
events.cpp

ifeq ($(TW_SUPPORT_INPUT_1_2_HAPTICS),true)
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0)
LOCAL_SHARED_LIBRARIES += android.hardware.vibrator@1.2 libhidlbase
LOCAL_CFLAGS += -DUSE_QTI_HAPTICS
endif
endif

ifneq ($(TW_BOARD_CUSTOM_GRAPHICS),)
$(warning ****************************************************************************)
$(warning * TW_BOARD_CUSTOM_GRAPHICS support has been deprecated in TWRP. *)
Expand Down
12 changes: 11 additions & 1 deletion minuitwrp/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include <string.h>
#include <fstream>

#ifdef USE_QTI_HAPTICS
#include <android/hardware/vibrator/1.2/IVibrator.h>
#endif

#include "../common.h"

#include "minui.h"
Expand Down Expand Up @@ -130,12 +134,18 @@ int vibrate(int timeout_ms)
char tout[6];
sprintf(tout, "%i", timeout_ms);

#ifdef USE_QTI_HAPTICS
android::sp<android::hardware::vibrator::V1_2::IVibrator> vib = android::hardware::vibrator::V1_2::IVibrator::getService();
if (vib != nullptr) {
vib->on((uint32_t)timeout_ms);
}
#else
if (std::ifstream(LEDS_HAPTICS_ACTIVATE_FILE).good()) {
write_to_file(LEDS_HAPTICS_DURATION_FILE, tout);
write_to_file(LEDS_HAPTICS_ACTIVATE_FILE, "1");
} else
write_to_file(VIBRATOR_TIMEOUT_FILE, tout);

#endif
return 0;
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions prebuilt/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ ifeq ($(TW_INCLUDE_CRYPTO), true)
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/keystore_cli
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/servicemanager
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.system.wifi.keystore@1.0.so
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0)
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.vibrator@1.0.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.vibrator@1.1.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.vibrator@1.2.so
endif

ifneq ($(wildcard system/keymaster/keymaster_stl.cpp),)
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster_portable.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster_staging.so
Expand Down

0 comments on commit 909daa9

Please sign in to comment.