Skip to content

Tip state parsing logic is problematic #43

@AlexGuo1998

Description

@AlexGuo1998

This State parsing logic contains problems:

// 0x1 = Transition between states
// 0x2 = Floating finger
// 0x4 = Contact/Valid
// I've gotten 0x6 if I press on the trackpad and then keep my finger close
// Note: These values come from my MBP9,2. These also are valid on my MT2
ptpOutputReport.Contacts[i].TipSwitch = (f->State & 0x4) && (driverContext->IgnoreNearFingers == FALSE ? TRUE : !(f->State & 0x2));

After carefully reviewing some packet captures from a Magic Trackpad 2, the correct definition seems to be

Value State Notes
1 ToHover (Transition from any state to Hover)
2 Hover Finger approaching the trackpad, but have not (already) contacted
3 ToTouch (Transition from any state to Touch)
4 Touch Finger touching the trackpad
5 ToLeave (Transition from any state to Leave)
6 Leave After a touch, finger going back to hovering
7 ToOff (Transition from any state to Off)
0 Off The final state, when the finger is completely away from the trackpad
Captured data

(+ means the transition bit is set)

Swipe on the trackpad

1 +hover (This state may be missed)
3 +touch
4  touch
4  touch
...
4  touch
4  touch
5 +leave
7 +  off
0    off

Slow approach-touch-leave

2  hover (For the first finger, the first state is 2 instead of 1)
2  hover
2  hover
...
2  hover
2  hover
3 +touch
4  touch
4  touch
...
4  touch
4  touch
4  touch
5 +leave
6  leave
7 +  off
0    off

Slow approach-touch-leave while another finger touching

#1 4  touch
#1 4  touch
#1 4  touch
#1 4  touch #9 1 +hover (For the second finger, the first state is 1)
#1 4  touch #9 2  hover
#1 4  touch #9 2  hover
...
#1 4  touch #9 2  hover
#1 4  touch #9 2  hover
#1 4  touch #9 3 +touch
#1 4  touch #9 4  touch
#1 4  touch #9 4  touch
...
#1 4  touch #9 4  touch
#1 4  touch #9 4  touch
#1 4  touch #9 5 +leave
#1 4  touch #9 6  leave
#1 4  touch #9 6  leave
...
#1 4  touch #9 6  leave
#1 4  touch #9 6  leave
#1 4  touch #9 7 +  off
#1 4  touch #9 0    off
#1 4  touch #9 0    off (Yes, there are 2 frames with state 0, for the second finger)
#1 4  touch
#1 4  touch
#1 4  touch

Weaving a USB cable over the trackpad

2  hover
2  hover
2  hover
...
2  hover
2  hover
7 +  off
0    off

The current logic treats, for example, 4 (Touch) and 5 (ToLeave) the same, but 4 (Touch) should actually be treated the same as 3 (ToTouch). This causes a 1-frame lag when transitioning between states.

Also, states 2 (Hover) and 6 (Leave) should be differentiated. During normal use, if a finger accidentally lifts slightly off the trackpad while moving, the state sequence becomes ...44566...663444..., while a cable hovering over the trackpad only produces state 2. Thus it may be a good idea to treat 6 (Leave) as touching, but 2 (Hover) as not touching.

I can create a patch for the driver and control panel, if we agree to update the current implementation.

BTW, thanks for the signed drivers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions