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

Add an environment call for querying the device's battery #15387

Merged
merged 14 commits into from
Aug 12, 2023

Conversation

JesseTG
Copy link
Contributor

@JesseTG JesseTG commented Jun 15, 2023

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

@JesseTG JesseTG marked this pull request as ready for review July 20, 2023 16:48
@hizzlekizzle
Copy link
Contributor

@LibretroAdmin @barbudreadmon (since you've added callbacks before) Anyone else?

This looks pretty straightforward to me.

@barbudreadmon
Copy link
Contributor

It looks fine to me

Copy link
Member

@RobLoach RobLoach left a 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

@JesseTG
Copy link
Contributor Author

JesseTG commented Aug 8, 2023

@LibretroAdmin Any objections to merging this PR?

@LibretroAdmin LibretroAdmin merged commit 954b046 into libretro:master Aug 12, 2023
22 checks passed
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.

5 participants