Fix DT2W on Xiaomi Mi 11 Lite 5G by using xiaomi-touch
It may also fix for other Xiaomi devices
This commit is contained in:
parent
b962aa4bfd
commit
a66fa56752
3
base.mk
3
base.mk
@ -218,4 +218,7 @@ PRODUCT_COPY_FILES += \
|
|||||||
|
|
||||||
PRODUCT_PACKAGES += phh-ota
|
PRODUCT_PACKAGES += phh-ota
|
||||||
|
|
||||||
|
PRODUCT_PACKAGES += \
|
||||||
|
xiaomi-touch
|
||||||
|
|
||||||
include build/make/target/product/gsi_release.mk
|
include build/make/target/product/gsi_release.mk
|
||||||
|
@ -204,3 +204,10 @@ cc_binary {
|
|||||||
"oplus-alert-slider.rc",
|
"oplus-alert-slider.rc",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc_binary {
|
||||||
|
name: "xiaomi-touch",
|
||||||
|
srcs: [
|
||||||
|
"xiaomi-touch.cpp",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int dir;
|
int dir;
|
||||||
@ -27,4 +28,5 @@ int main(int argc, char **argv) {
|
|||||||
cfg.speed = 4;
|
cfg.speed = 4;
|
||||||
|
|
||||||
ioctl(fd, ASUS_MOTOR_DRV_MANUAL_MODE, &cfg);
|
ioctl(fd, ASUS_MOTOR_DRV_MANUAL_MODE, &cfg);
|
||||||
|
close(fd);
|
||||||
}
|
}
|
||||||
|
48
cmds/xiaomi-touch.cpp
Normal file
48
cmds/xiaomi-touch.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
#define SET_CUR_VALUE 0
|
||||||
|
|
||||||
|
#define Touch_Game_Mode 0
|
||||||
|
#define Touch_Active_MODE 1
|
||||||
|
#define Touch_UP_THRESHOLD 2
|
||||||
|
#define Touch_Tolerance 3
|
||||||
|
#define Touch_Aim_Sensitivity 4
|
||||||
|
#define Touch_Tap_Stability 5
|
||||||
|
#define Touch_Expert_Mode 6
|
||||||
|
#define Touch_Edge_Filter 7
|
||||||
|
#define Touch_Panel_Orientation 8
|
||||||
|
#define Touch_Report_Rate 9
|
||||||
|
#define Touch_Fod_Enable 10
|
||||||
|
#define Touch_Aod_Enable 11
|
||||||
|
#define Touch_Resist_RF 12
|
||||||
|
#define Touch_Idle_Time 13
|
||||||
|
#define Touch_Doubletap_Mode 14
|
||||||
|
#define Touch_Grip_Mode 15
|
||||||
|
#define Touch_FodIcon_Enable 16
|
||||||
|
#define Touch_Nonui_Mode 17
|
||||||
|
#define Touch_Debug_Level 18
|
||||||
|
#define Touch_Power_Status 19
|
||||||
|
#define Touch_Mode_NUM 20
|
||||||
|
|
||||||
|
#define TOUCH_DEV_PATH "/dev/xiaomi-touch"
|
||||||
|
#define TOUCH_ID 0
|
||||||
|
#define TOUCH_MAGIC 0x5400
|
||||||
|
#define TOUCH_IOC_SETMODE TOUCH_MAGIC + SET_CUR_VALUE
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
if(argc != 3) {
|
||||||
|
fprintf(stderr, "Usage: %s <mode> <0|1>\n", argv[0]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int mode = atoi(argv[1]);
|
||||||
|
int enabled = atoi(argv[2]);
|
||||||
|
if (mode < 0 || mode > 20) return -1;
|
||||||
|
if (enabled != 0 && enabled != 1) return -1;
|
||||||
|
int fd = open(TOUCH_DEV_PATH, O_RDWR);
|
||||||
|
int arg[3] = {TOUCH_ID, mode, enabled};
|
||||||
|
ioctl(fd, TOUCH_IOC_SETMODE, &arg);
|
||||||
|
close(fd);
|
||||||
|
}
|
@ -52,6 +52,15 @@ xiaomi_toggle_dt2w_event_node() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xiaomi_toggle_dt2w_ioctl() {
|
||||||
|
if [ -c "/dev/xiaomi-touch" ]; then
|
||||||
|
echo "Trying to set dt2w mode with ioctl on /dev/xiaomi-touch"
|
||||||
|
# 14 - Touch_Doubletap_Mode
|
||||||
|
xiaomi-touch 14 "$1"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
restartAudio() {
|
restartAudio() {
|
||||||
setprop ctl.restart audioserver
|
setprop ctl.restart audioserver
|
||||||
@ -66,11 +75,12 @@ if [ "$1" == "persist.sys.phh.xiaomi.dt2w" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! xiaomi_toggle_dt2w_proc_node "$prop_value"; then
|
xiaomi_toggle_dt2w_proc_node "$prop_value"
|
||||||
# Fallback to event node method
|
# Fallback to event node method
|
||||||
xiaomi_toggle_dt2w_event_node "$prop_value"
|
xiaomi_toggle_dt2w_event_node "$prop_value"
|
||||||
fi
|
# Fallback to ioctl method
|
||||||
exit $?
|
xiaomi_toggle_dt2w_ioctl "$prop_value"
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" == "persist.sys.phh.oppo.dt2w" ]; then
|
if [ "$1" == "persist.sys.phh.oppo.dt2w" ]; then
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
/system/bin/phh-on-boot.sh u:object_r:phhsu_exec:s0
|
/system/bin/phh-on-boot.sh u:object_r:phhsu_exec:s0
|
||||||
/system/bin/phh-on-data.sh u:object_r:phhsu_exec:s0
|
/system/bin/phh-on-data.sh u:object_r:phhsu_exec:s0
|
||||||
/system/bin/asus-motor u:object_r:phhsu_exec:s0
|
/system/bin/asus-motor u:object_r:phhsu_exec:s0
|
||||||
|
/system/bin/xiaomi-touch u:object_r:phhsu_exec:s0
|
||||||
|
|
||||||
#/system/bin/fsck\.exfat u:object_r:fsck_exec:s0
|
#/system/bin/fsck\.exfat u:object_r:fsck_exec:s0
|
||||||
/system/bin/fsck\.ntfs u:object_r:fsck_exec:s0
|
/system/bin/fsck\.ntfs u:object_r:fsck_exec:s0
|
||||||
|
Loading…
Reference in New Issue
Block a user