mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
feat(ioscompanion): add Describe to companion transport
This commit is contained in:
1 parent
222a51cb93
commit
f73fc898dd
3 files changed
+59
No files matched your search
@@ -47,6 +47,26 @@ func (c *grpcCompanion) AccessibilityInfo(ctx context.Context) (string, error) {
|
||||
return resp.GetJson(), nil
|
||||
}
|
||||
|
||||
func (c *grpcCompanion) Describe(ctx context.Context) (ScreenDescription, error) {
|
||||
resp, err := c.client.Describe(ctx, &pb.TargetDescriptionRequest{})
|
||||
if err != nil {
|
||||
return ScreenDescription{}, err
|
||||
}
|
||||
return screenDescriptionFrom(resp), nil
|
||||
}
|
||||
|
||||
// screenDescriptionFrom extracts the point dimensions and scale from a describe
|
||||
// response. The generated getters are nil-safe, so a response missing the
|
||||
// nested messages yields a zero-valued ScreenDescription rather than panicking.
|
||||
func screenDescriptionFrom(resp *pb.TargetDescriptionResponse) ScreenDescription {
|
||||
dimensions := resp.GetTargetDescription().GetScreenDimensions()
|
||||
return ScreenDescription{
|
||||
WidthPoints: int(dimensions.GetWidthPoints()),
|
||||
HeightPoints: int(dimensions.GetHeightPoints()),
|
||||
Scale: dimensions.GetDensity(),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *grpcCompanion) SendHID(ctx context.Context, events ...HIDEvent) error {
|
||||
stream, err := c.client.Hid(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user