Not able to run tap scenario
./fbsimctl <udid> tap 200.0 200.0. it always say Could not connect to HID, it must be provided on launch. I did pass hid port on launching simulator. Am I missing something?
It only worked on --direct-launch for me.
yes I am launching with fbsimctl <udid> boot --direct-launch -- listen --http 8090 --hid 4590
This is correct. --direct-launch is required, but you must interact from the same process as boots the simulator.
The reason for this is that the process that is responsible for booting the simulator, owns the rights to write to the mach port that actually sends the HID events to the simulator. You can either use the HID Socket functionality to pump HID events to the simulator, or with the HTTP server. It's currently not possible to do this from another process.
This is how I ended up sending a tap action through the socket in case you get the HID connection working. (--hid 8091)
echo '{"x":150,"y":100,"class":"touch","type":"down"}' | nc localhost 8091 && \
sleep 0.2 && \
echo '{"x":150,"y":100,"class":"touch","type":"up"}' | nc localhost 8091
@ssynix that looks similar to what I have locally. A socket should work well with other languages like python, though I haven't gotten round to adding this to the fbsimctl e2e tests.
Sorry i was away for day. I just tests this and it works. thanks @ssynix & @lawrencelomax. Do you have some documentation on using rest api like @ssynix showed or we have to dig into code
There's pretty decent documentation in the header files and commit messages, so that's the first place I look.
For HID stuff, see here.
Thanks @ssynix . I will go through it.
I'd like for this to eventually documented, but for now this API is in its early stages. I'm confident that keeping line terminated json will stay, as well as keeping the primitives the same. Higher level gestures can be built on top of this. For a real-time API, simple primitives make the most sense as it will be easy to convert to UI events in a browser or native application.
If there's anything else you'd like to know, please reopen.
@lawrencelomax I see protocol changed here. So tried this
echo '{"action":"hid","payload":{"x":112,"y":94,"class":"touch","direction":"down"},"udid":"285A2218-1FF6-4727-821A-785908A78584"}' | nc localhost 4570 && sleep 0.2 && echo '{"action":"hid","payload":{"x":112,"y":94,"class":"touch","direction":"up"},"udid":"285A2218-1FF6-4727-821A-785908A78584"}' | nc localhost 4570
I see that its not working anymore. It feels like this does long click rather than click. I removed sleep part it still doesn't help.
I also see that following in log. I have feeling it does same action twice
{"event_type":"started","timestamp":1493761660,"subject":{"y":94,"x":112,"class":"touch","direction":"down"},"event_name":"hid"}
{"event_type":"ended","timestamp":1493761660,"subject":{"y":94,"x":112,"class":"touch","direction":"down"},"event_name":"hid"}
{"event_type":"started","timestamp":1493761660,"subject":{"y":94,"x":112,"class":"touch","direction":"up"},"event_name":"hid"}
{"event_type":"ended","timestamp":1493761660,"subject":{"y":94,"x":112,"class":"touch","direction":"up"},"event_name":"hid"}
actually issue was with my parsing logic. It still works :). Sorry to bother.
Cannot pass hid port on launch. fbsimctl is not accepting hid port? Is something changed?
fbsimctl boot -- listen --hid 8490 doesn't work. However,
fbsimctl boot -- listen --http 2346 does.
Any ideas?
Could you try booting with --direct-launch as suggested earlier?
I have tried both (with and without --direct-launch).
Actually my problem is that fbsimtcl is not even able to parse --hid 8490 as valid input.
One of the recent commits is: Change --hid to --socket So give that a try!
One of the recent commits is: Change --hid to --socket So give that a try
Good point, there has been a bunch of recent changes here. Main reason for doing so is that some of the functionality of fbsimctl (the binary) is being pushed down into the frameworks FBSimulatorControl/FBControlCore so that the remote interaction functionality can be placed in an arbitrary executable.
Additionally, the way that actions can be wired over a socket are being consolidated so that hid actions are not special snowflakes. Other actions such as launching an application can be sent over the same socket.