sensors: Handle fod press status without coordinates

Also fix the error handling of sscanf which returns the
number of matched variables on partial success.

Change-Id: I785c0e3f73e89f79addcf18e1b5111e93e25e430
This commit is contained in:
Arian
2023-03-29 17:38:34 +02:00
committed by kuailexs
parent 91bdaa7db2
commit e68ecd639e

View File

@@ -42,7 +42,13 @@ static bool readFpState(int fd, int& screenX, int& screenY) {
}
rc = sscanf(buffer, "%d,%d,%d", &screenX, &screenY, &state);
if (rc < 0) {
if (rc == 1) {
// If only the first variable can be matched assume
// that the node only reports the state
state = screenX;
screenX = 0;
screenY = 0;
} else if (rc < 3) {
ALOGE("failed to parse fp state: %d", rc);
return false;
}