-
Notifications
You must be signed in to change notification settings - Fork 18
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
Implement low hanging apt sleep/homemenu functions and chainloader #161
Conversation
oh, looks like i made my PR on the wrong branch edit: fixed |
8fd0550
to
c95cd26
Compare
It’s a pretty straightforward addition. Just one question, what does “sleep allowed” actually do? Can the app stop the system to sleep even if the shell is closed?
Chainloader and applist stuff could be implemented with the already existing |
It's used in online multiplayer games and stuff like that. i've seen the no-sleep/no-home combo for example in Steel Diver: Sub Wars when playing online. essentially, if you close the shell (or use the toggle switch on the O2DS), the displays turn off, but the console does not go to sleep. you can see this because the blue LED does not oscillate in brightness when it's not sleeping. I should probably write better documentation, since it wasn't clear at first glance what it did.
edit: turns out i didn't know the existing AM API provided that, i have made a chainloader prototype, although i don't really like it as-is |
Alright, implemented a chainloader API, the problem is that the bindings are missing a function. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just a couple small tweaks I'd recommend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes are small and contained. LGTM
@@ -90,3 +132,48 @@ impl Drop for Apt { | |||
unsafe { ctru_sys::aptExit() }; | |||
} | |||
} | |||
|
|||
/// Can launch other applications when the current one exits. | |||
pub struct Chainloader<'a> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chainloader
should clear on Drop
, so that leftovers from previous usages won't influence in un-mutable environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i did think about this, but then forgot to propose it.
the problem is that the destructor will run when you exit the app, as the chainloader goes out of scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, didn’t think about it.
Wait, does this mean the setup only works because there is a reference to Apt
that doesn’t get uninitialised? (The one made in libctru, i mean). If this were to not work without that (because the apt service were to be unused) then we must find a way around this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at a first look it definitely looks that way.
|
||
impl<'a> Chainloader<'a> { | ||
/// Gets a handle to the chainloader | ||
pub fn new(apt: &'a Apt) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe Chainloader
should require a mutable reference to Apt
, but that may not be necessary if no other aspect of Apt
reads or uses data handled by Chainloader
.
Tell me what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i tried this, but then using it inside the main apt
loop is a mess because it takes an immutable reference to loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I know, that’s exactly what I was thinking would happen. It’s not an issue as long as all of the chainloader code is only accessible from here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are the only chainloader functions, so i think it's fine to have it be this way
Co-authored-by: Meziu <[email protected]>
Saw that these weren't added yet, although they're very simple.
TLDR, Implemented
aptSetSleepAllowed
aptIsSleepAllowed
aptSetHomeAllowed
aptIsHomeAllowed
aptJumpToHomeMenu