From 1c5b35a3c15d5de31f56c917fdbcb32109da15cc Mon Sep 17 00:00:00 2001 From: Arian Date: Thu, 14 Mar 2024 14:09:52 +0100 Subject: [PATCH] sm8450-common: udfps: Inform hwmodule about press coordinates These coordinates can be from the last press, ideally we would get the coordinates freshly when fod_press_status changes. Change-Id: I8c0096c96612c8ea8b612696ecf702d7945a1b84 --- udfps/UdfpsHandler.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/udfps/UdfpsHandler.cpp b/udfps/UdfpsHandler.cpp index dcb9702..739fc07 100644 --- a/udfps/UdfpsHandler.cpp +++ b/udfps/UdfpsHandler.cpp @@ -27,6 +27,8 @@ #define LOW_BRIGHTNESS_THRESHHOLD 100 #define COMMAND_FOD_PRESS_STATUS 1 +#define COMMAND_FOD_PRESS_X 2 +#define COMMAND_FOD_PRESS_Y 3 #define PARAM_FOD_PRESSED 1 #define PARAM_FOD_RELEASED 0 @@ -115,6 +117,8 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler { } bool pressed = readBool(fd); + mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_X, pressed ? lastPressX : 0); + mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_Y, pressed ? lastPressY : 0); mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_STATUS, pressed ? PARAM_FOD_PRESSED : PARAM_FOD_RELEASED); @@ -197,8 +201,12 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler { }).detach(); } - void onFingerDown(uint32_t /*x*/, uint32_t /*y*/, float /*minor*/, float /*major*/) { - LOG(INFO) << __func__; + void onFingerDown(uint32_t x, uint32_t y, float /*minor*/, float /*major*/) { + LOG(INFO) << __func__ << "x: " << x << ", y: " << y; + // Track x and y coordinates + lastPressX = x; + lastPressY = y; + // Ensure touchscreen is aware of the press state, ideally this is not needed setFingerDown(true); } @@ -259,6 +267,7 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler { android::base::unique_fd touch_fd_; android::base::unique_fd disp_fd_; bool enrolling = false; + uint32_t lastPressX, lastPressY; void setFodStatus(int value) { int buf[MAX_BUF_SIZE] = {MI_DISP_PRIMARY, Touch_Fod_Enable, value};