Skip to content

Commit

Permalink
V1.2.1 - Launch associated app
Browse files Browse the repository at this point in the history
  • Loading branch information
thompsonnoahe committed Dec 8, 2024
1 parent 2a88f0a commit b7da69b
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Src/GpuPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,11 @@ namespace nthompson {
}
selectedGpu_ = gpu.index;
}

void GpuPlugin::KeyDownForAction(const std::string &inAction, const std::string &inContext,
const nlohmann::json &inPayload, const std::string &inDeviceID) {
if (!usage_) return;

usage_->LaunchAssociatedApp();
}
}
6 changes: 6 additions & 0 deletions Src/GpuPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ namespace nthompson {
const std::string &inContext,
const nlohmann::json &inPayload,
const std::string &inDeviceID) override;

void KeyDownForAction(
const std::string& inAction,
const std::string& inContext,
const nlohmann::json& inPayload,
const std::string& inDeviceID) override;
private:
void FindAvailableGpus();
std::vector<Gpu> gpus_;
Expand Down
27 changes: 27 additions & 0 deletions Src/Windows/Amd/AmdGpuUsage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,32 @@ namespace nthompson {
helper_.Terminate();
}

void AmdGpuUsage::LaunchAssociatedApp() {
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInformation;

ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
ZeroMemory(&processInformation, sizeof(processInformation));

LPCTSTR path = R"(C:\Program Files\AMD\CNext\CNext\RadeonSoftware.exe)";

CreateProcess(
path,
nullptr,
nullptr,
nullptr,
FALSE,
0,
nullptr,
nullptr,
&startupInfo,
&processInformation
);

CloseHandle(processInformation.hProcess);
CloseHandle(processInformation.hThread);
}

}

6 changes: 4 additions & 2 deletions Src/Windows/Amd/AmdGpuUsage.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ namespace nthompson {

class AmdGpuUsage : public IGpuUsage {
public:
AmdGpuUsage(int32_t index = 0);
explicit AmdGpuUsage(int32_t index = 0);
~AmdGpuUsage() override;
uint32_t GetGpuUsage() override;
private:
void LaunchAssociatedApp() override;

private:
static inline ADLXHelper helper_;
adlx::IADLXGPUPtr gpu_;
adlx::IADLXPerformanceMonitoringServicesPtr perfMonitoringServices_;
Expand Down
1 change: 1 addition & 0 deletions Src/Windows/IGpuUsage.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ namespace nthompson {
IGpuUsage() = default;
virtual ~IGpuUsage() = default;
virtual uint32_t GetGpuUsage() = 0;
virtual void LaunchAssociatedApp() = 0;
};
}
27 changes: 27 additions & 0 deletions Src/Windows/Nvidia/NvidiaGpuUsage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,32 @@ namespace nthompson {
nvmlShutdown();
}

void NvidiaGpuUsage::LaunchAssociatedApp() {
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInformation;

ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
ZeroMemory(&processInformation, sizeof(processInformation));

LPCTSTR path = R"(C:\Program Files\NVIDIA Corporation\NVIDIA app\CEF\NVIDIA app.exe)";

CreateProcess(
path,
nullptr,
nullptr,
nullptr,
FALSE,
0,
nullptr,
nullptr,
&startupInfo,
&processInformation
);

CloseHandle(processInformation.hProcess);
CloseHandle(processInformation.hThread);
}


} // nthompson
5 changes: 4 additions & 1 deletion Src/Windows/Nvidia/NvidiaGpuUsage.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include <nvml.h>
#include <windows.h>
#include <cstdint>
#include "StreamDeckSDK/ESDLogger.h"
#include "../IGpuUsage.h"
Expand All @@ -16,7 +17,9 @@ namespace nthompson {
explicit NvidiaGpuUsage(int32_t index = 0);
~NvidiaGpuUsage() override;
uint32_t GetGpuUsage() override;
private:
void LaunchAssociatedApp() override;

private:
nvmlDevice_t device_;
nvmlUtilization_t utilization_;
};
Expand Down

0 comments on commit b7da69b

Please sign in to comment.