Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use touchX command with extra args to dispatch touch events to sim-server #543

Merged
merged 4 commits into from
Sep 17, 2024

Conversation

kmagiera
Copy link
Member

@kmagiera kmagiera commented Sep 13, 2024

This PR builds on top of changes from https://github.com/software-mansion-labs/simulator-server/pull/173 where we add support for multitouch events to be dispatched to device (Android for the time being).

This change restructures the multitouch handling code both on the front-end and in extension code such that we follow the new protocol. Now, instead of having separate command for multitouch, we allow for the dispatchTouch method to take an array of touches (typically one or two). Then, we send touchDown or similar command with additional coordinates after the x and y of the first pointer are added.

The main change on the frontend was that we don't send leading point and anchor points but instead send two concrete touch points,. This removes coupling because sim-server and frontend code as otherwise we'd need to have code that calculates touch points on both sides (including logic related to rounding etc)

This PR also updates some parts of the rpc code that I needed for one stage of the changes since we werent handling null value correctly (which apparently has typeof = 'object' in JS)

Test plan

This has been tested on custom sim-server build that includes https://github.com/software-mansion-labs/simulator-server/pull/173 by opening an app with zoomable control on Android (I used photo gallery)

Copy link

vercel bot commented Sep 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 17, 2024 0:45am

Comment on lines 55 to 56
const fff = `touch${type} ` + touches.map((pt) => `${pt.xRatio} ${pt.yRatio}`).join(" ") + "\n";
this.subprocess?.stdin?.write(fff);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change fff to something more meaningful?

Suggested change
const fff = `touch${type} ` + touches.map((pt) => `${pt.xRatio} ${pt.yRatio}`).join(" ") + "\n";
this.subprocess?.stdin?.write(fff);
const touchCommand = `touch${type} ` + touches.map((pt) => `${pt.xRatio} ${pt.yRatio}`).join(" ") + "\n";
this.subprocess?.stdin?.write(touchCommand);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, this one got in by accident. Was debugging it and then forgot to inline it back again. Will change that

p-malecki added a commit that referenced this pull request Sep 17, 2024
@kmagiera kmagiera merged commit 66ee860 into main Sep 17, 2024
3 checks passed
@kmagiera kmagiera deleted the kmagiera/multitouch-android branch September 17, 2024 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants