1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-13 22:06:46 +00:00

touch: Correct pressure calculation

Fingertip S for Nintendo Switch uses a custom spatial calculation. It now allows to identify area of touch.
This commit is contained in:
CTCaer 2020-03-13 08:34:16 +02:00
parent 8b74c487eb
commit 95e3159fe9
2 changed files with 10 additions and 3 deletions

View file

@ -75,7 +75,14 @@ static void _touch_process_contact_event(touch_event *event, bool touching)
if (touching) if (touching)
{ {
event->y = (event->raw[3] << 4) | (event->raw[4] & STMFTS_MASK_X_MSB); event->y = (event->raw[3] << 4) | (event->raw[4] & STMFTS_MASK_X_MSB);
event->z = event->raw[5];
event->z = event->raw[5] | (event->raw[6] << 8);
event->z = event->z << 6;
u16 tmp = 0x40;
if ((event->raw[7] & 0x3F) != 1 && (event->raw[7] & 0x3F) != 0x3F)
tmp = event->raw[7] & 0x3F;
event->z /= tmp + 0x40;
event->fingers = ((event->raw[1] & STMFTS_MASK_TOUCH_ID) >> 4) + 1; event->fingers = ((event->raw[1] & STMFTS_MASK_TOUCH_ID) >> 4) + 1;
} }
else else
@ -93,7 +100,7 @@ static void _touch_parse_event(touch_event *event)
case STMFTS_EV_MULTI_TOUCH_ENTER: case STMFTS_EV_MULTI_TOUCH_ENTER:
case STMFTS_EV_MULTI_TOUCH_MOTION: case STMFTS_EV_MULTI_TOUCH_MOTION:
_touch_process_contact_event(event, true); _touch_process_contact_event(event, true);
if (event->z > 52) // Discard noisy hover touch. if (event->z > 52 && event->z < 255) // Discard noisy hover touch and palm rest.
event->touch = true; event->touch = true;
else else
{ {

View file

@ -100,7 +100,7 @@ typedef struct _touch_event {
u16 type; // Event type. u16 type; // Event type.
u16 x; // Horizontal coordinates. u16 x; // Horizontal coordinates.
u16 y; // Vertical coordinates. u16 y; // Vertical coordinates.
u8 z; u32 z;
u8 fingers; u8 fingers;
bool touch; bool touch;
} touch_event; } touch_event;