-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add an environment call for querying the device's battery #15387
Conversation
# Conflicts: # libretro-common/include/libretro.h # runloop.c
- I misunderstood the meaning of these enums
- Don't return 0 seconds; instead, return NO_ESTIMATE - Don't force percent to 100 in the CHARGED state
@LibretroAdmin @barbudreadmon (since you've added callbacks before) Anyone else? This looks pretty straightforward to me. |
It looks fine to me |
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 believe this is working well. Tried adding it to ChaiLove in libretro/libretro-chailove#424 ....
var powerInfo = love.system.getPowerInfo()
print("Battery")
print(to_string(powerInfo.state))
print(to_string(powerInfo.seconds))
print(to_string(powerInfo.percent))
Battery
3
-1
-1
@LibretroAdmin Any objections to merging this PR? |
Description
This pull request adds a new environment callback that allows cores to query the frontend's battery level and power status. This can be useful for emulating battery life on handheld game consoles such as the Nintendo DS. Another possible use case is to allow cores to reduce their workload if the battery is low.
RetroArch already implements this functionality in a cross-platform manner. I just expose it to cores.
Note that this PR has not been tested yet; I intend to test it on a core I'm working on in the near future. Right now I'm gathering feedback and declaring my intent to get this merged at some point. Once I integrate this into my core, I will consider it ready to be merged.Okay, I tested it. Works like a charm. https://cdn.discordapp.com/attachments/876520593636335646/1131628490148560988/20230720_124448.mp4