Skip to content

Commit

Permalink
Fix lid switch detection for AirPods Pro 2 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
SpriteOvO committed Jul 27, 2023
1 parent 18ee80f commit 2ba3e8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions Source/Core/AppleCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ bool AirPods::IsBothPodsInCase() const

bool AirPods::IsLidOpened() const
{
return lidState == 1 || lidState == 2 || lidState == 3 || lidState == 4 || lidState == 5 ||
lidState == 6 || lidState == 7 || lidState == 0;
return lid.closed == 0;
}

bool AirPods::IsCaseCharging() const
Expand Down
9 changes: 7 additions & 2 deletions Source/Core/AppleCP.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,13 @@ class AirPods : Header
uint8_t caseCharging : 1; // If it's charging (value != 0)
uint8_t unk9 : 1;
} battery;
uint8_t lidState; // 1/2/3/4/5/6/7/0 == opened, 9/a/b/c/d/e/f/8 == closed
Color color; // Untested because I don't have a device other than white
struct {
uint8_t switchCount : 3; // This count increases if the lid opened or closed once, and
// resets if overflow or no longer broadcasting advertisements
uint8_t closed : 1;
uint8_t unk10 : 4;
} lid;
Color color; // Untested because I don't have a device other than white
uint8_t unk11[1];
uint8_t unk12[16]; // Hash or encrypted payload
};
Expand Down

0 comments on commit 2ba3e8f

Please sign in to comment.