Skip to content

Instantly share code, notes, and snippets.

@gus33000
Last active July 25, 2022 21:54
Show Gist options
  • Select an option

  • Save gus33000/8720db998a7ab9c164bd6a96e00dac32 to your computer and use it in GitHub Desktop.

Select an option

Save gus33000/8720db998a7ab9c164bd6a96e00dac32 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <windows.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Devices.Lights.h>
#include <winrt/Windows.Devices.Enumeration.h>
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Devices::Lights;
using namespace Windows::Devices::Enumeration;
int main()
{
init_apartment();
printf("Searching for lamps\n");
for (auto lampId : DeviceInformation::FindAllAsync(Lamp::GetDeviceSelector()).get())
{
std::cout << "Found a Lamp with the following interface id: " << to_string(lampId.Id()) << std::endl;
printf("Preparing to enable the lamp. Please wait...\n");
Lamp lamp = Lamp::FromIdAsync(lampId.Id()).get();
lamp.IsEnabled(true);
std::cout << "Lamp Brightness level: " << lamp.BrightnessLevel() << std::endl;
printf("Done!\n");
}
printf("Press any key to stop\n");
std::cin.get();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment