switchbrew / libnx

Library for Switch Homebrew
https://switchbrew.github.io/libnx/
ISC License
1.26k stars 167 forks source link

applet: add appletGetMessageEvent #607

Closed liamwhite closed 1 year ago

liamwhite commented 1 year ago

This allows waiting for applet messages using a custom event loop (as opposed to using appletMainLoop).

yellows8 commented 1 year ago

as opposed to ... appletGetMessage can already be used for custom event loop - not sure why exposing the Event is needed?

SciresM commented 1 year ago

presumably to wait for message to become available. appletGetMessage waits with timeout zero, so you end up wasting cpu time if you loop calling it.

liamwhite commented 1 year ago

@yellows8 To allow including the event in a call to waitMulti(&idx, -1, waiterForEvent(appletMessageEvent)), along with other events. As SciresM noted, if you call appletGetMessage, it does not wait for a message to become available and returns immediately if there is no message.