SteamTarget: Controllers: User setting for update rate (in microseconds)

v2
Peter Repukat 6 years ago
parent ba619fe626
commit 6b7db2e665

@ -45,11 +45,12 @@ void SteamTarget::init()
SetConsoleCtrlHandler(reinterpret_cast<PHANDLER_ROUTINE>(ConsoleCtrlCallback), true);
ShowWindow(GetConsoleWindow(), SW_HIDE);
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
read_ini();
readIni();
target_overlay_.init(!enable_overlay_);
initOverlayEvents();
controller_thread_ = std::make_unique<VirtualControllerThread>(update_rate_);
if (enable_controllers_)
controller_thread_.run();
controller_thread_->run();
if (hook_steam_ && !use_desktop_conf_)
Injector::hookSteam();
launchWatchdog();
@ -80,11 +81,11 @@ void SteamTarget::onAboutToQuit()
if (hook_steam_ && !use_desktop_conf_)
Injector::unhookSteam();
controller_thread_.stop();
controller_thread_->stop();
target_overlay_.stop();
}
void SteamTarget::read_ini()
void SteamTarget::readIni()
{
if (arguments().size() == 1)
{
@ -111,6 +112,14 @@ void SteamTarget::read_ini()
else if (childkey == "bUseDesktopConfig") {
use_desktop_conf_ = settings.value(childkey).toBool();
}
else if (childkey == "iUpdateRate") {
bool isInt = false;
update_rate_ = settings.value(childkey).toInt(&isInt);
if (!isInt)
update_rate_ = 5000;
if (update_rate_ < 0)
update_rate_ = 5000;
}
}
settings.endGroup();
settings.beginGroup("LaunchGame");

@ -56,7 +56,7 @@ public slots:
private:
void read_ini();
void readIni();
void initOverlayEvents();
void launchWatchdog() const;
@ -65,7 +65,7 @@ private:
static HRESULT LaunchUWPApp(LPCWSTR packageFullName, PDWORD pdwProcessId);
TargetOverlay target_overlay_;
VirtualControllerThread controller_thread_;
std::unique_ptr<VirtualControllerThread> controller_thread_;
//Settings from .ini file
bool hook_steam_ = true;
@ -78,6 +78,7 @@ private:
bool launch_uwp_ = false;
std::string launch_app_path_ = "";
std::string launch_app_args_ = "";
int update_rate_ = 5000;
QTimer launch_check_timer_;

@ -16,7 +16,7 @@ limitations under the License.
#include "VirtualControllerThread.h"
//
VirtualControllerThread::VirtualControllerThread()
VirtualControllerThread::VirtualControllerThread(const int delay)
{
driver_ = vigem_alloc();
@ -33,6 +33,7 @@ VirtualControllerThread::VirtualControllerThread()
}
seven_ = IsWindows7OrGreater() != IsWindows8OrGreater();
delay_ = delay;
}
@ -164,9 +165,9 @@ void VirtualControllerThread::controllerLoop()
}
tick_time_ = sf_clock_.getElapsedTime().asMicroseconds();
if (tick_time_ < delay)
if (tick_time_ < delay_)
{
std::this_thread::sleep_for(std::chrono::microseconds(delay - tick_time_));
std::this_thread::sleep_for(std::chrono::microseconds(delay_ - tick_time_));
}
}

@ -33,7 +33,7 @@ limitations under the License.
class VirtualControllerThread
{
public:
VirtualControllerThread();
explicit VirtualControllerThread(int delay);
VirtualControllerThread(const VirtualControllerThread& other) = delete;
VirtualControllerThread(VirtualControllerThread&& other) noexcept = delete;
VirtualControllerThread& operator=(const VirtualControllerThread& other) = delete;
@ -72,7 +72,7 @@ private:
sf::Clock sf_clock_;
int tick_time_ = 0;
constexpr static int delay = 1000000 / 200;
int delay_ = 0;
void controllerLoop();

@ -5,6 +5,7 @@ bEnableOverlayOnlyConfig=0
bEnableControllers=1
bUseDesktopConfig=0
bHookSteam=1
iUpdateRate=5000
version=1298
[LaunchGame]

Loading…
Cancel
Save