Skip to content

Instantly share code, notes, and snippets.

@chadcatlett
Created February 11, 2023 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadcatlett/0366fef70bb526b6c36518a82398c7f6 to your computer and use it in GitHub Desktop.
Save chadcatlett/0366fef70bb526b6c36518a82398c7f6 to your computer and use it in GitHub Desktop.
#include "pch.h"
#include <winrt/Windows.Gaming.Input.h>
#include <winrt/Windows.Devices.Power.h>
using namespace winrt;
using namespace Windows::Gaming::Input;
int main()
{
init_apartment();
printf("Attempting to enumerate all gamepads\n");
for (auto const& gamepad : Gamepad::Gamepads()) {
auto bat = gamepad.TryGetBatteryReport();
auto currentCharge = bat.RemainingCapacityInMilliwattHours();
if (currentCharge != nullptr) {
printf("remaining charge: %i\n", currentCharge.GetInt32());
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment