Skip to content

Commit

Permalink
cleanup, again
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne committed Nov 8, 2024
1 parent 0c19cda commit 4b0b89c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions AudioManager/AudioManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void AudioManager::setAudioDevice(QString ID)
}
}

// AI generated
QList<Device> AudioManager::ListAudioOutputDevices()
{
QList<Device> devices;
Expand Down
1 change: 0 additions & 1 deletion Configurator/Configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ QString Configurator::getDeviceIDFromComboBox(QComboBox* comboBox)

void Configurator::selectAudioDeviceFromSettings(QComboBox *comboBox, const QString &audioDeviceKey)
{
//QString deviceName = settings.value(audioDeviceKey, "").toString();
int index = comboBox->findText(audioDeviceKey);

if (index != -1) {
Expand Down
24 changes: 16 additions & 8 deletions NightLightSwitcher/NightLightSwitcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@

HKEY hKey = nullptr;

void init() {
void init()
{
const std::wstring keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\CloudStore\\Store\\DefaultAccount\\Current\\default$windows.data.bluelightreduction.bluelightreductionstate\\windows.data.bluelightreduction.bluelightreductionstate";

if (RegOpenKeyEx(HKEY_CURRENT_USER, keyPath.c_str(), 0, KEY_READ | KEY_WRITE, &hKey) != ERROR_SUCCESS) {
hKey = nullptr;
}
}

bool NightLightSwitcher::supported() {
bool NightLightSwitcher::supported()
{
init();
return hKey != nullptr;
}

bool NightLightSwitcher::enabled() {
bool NightLightSwitcher::enabled()
{
if (!supported()) return false;

BYTE data[1024];
Expand All @@ -36,19 +39,22 @@ bool NightLightSwitcher::enabled() {
return bytes[18] == 0x15; // 21 in decimal
}

void NightLightSwitcher::enable() {
void NightLightSwitcher::enable()
{
if (supported() && !enabled()) {
toggle();
}
}

void NightLightSwitcher::disable() {
void NightLightSwitcher::disable()
{
if (supported() && enabled()) {
toggle();
}
}

void NightLightSwitcher::toggle() {
void NightLightSwitcher::toggle()
{
if (!supported()) return;

BYTE data[1024];
Expand Down Expand Up @@ -93,7 +99,8 @@ void NightLightSwitcher::toggle() {
}
}

std::vector<BYTE> hexToBytes(const std::wstring& hex) {
std::vector<BYTE> hexToBytes(const std::wstring& hex)
{
std::vector<BYTE> bytes;
size_t len = hex.size();
for (size_t i = 0; i < len; i += 2) {
Expand All @@ -103,7 +110,8 @@ std::vector<BYTE> hexToBytes(const std::wstring& hex) {
return bytes;
}

std::wstring bytesToHex(const std::vector<BYTE>& bytes) {
std::wstring bytesToHex(const std::vector<BYTE>& bytes)
{
std::wstringstream ss;
for (BYTE byte : bytes) {
ss << std::hex << std::setw(2) << std::setfill(L'0') << static_cast<int>(byte);
Expand Down
4 changes: 0 additions & 4 deletions Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,7 @@ void Utils::sendMediaKey(WORD keyCode) {
INPUT ip = {0};
ip.type = INPUT_KEYBOARD;
ip.ki.wVk = keyCode;

// Press the key
SendInput(1, &ip, sizeof(INPUT));

// Release the key
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
}

0 comments on commit 4b0b89c

Please sign in to comment.