From 7b4ff0388d4e59791c655ff43a22e055557a5fc3 Mon Sep 17 00:00:00 2001 From: Peter Repukat Date: Sat, 10 Mar 2018 23:07:25 +0100 Subject: [PATCH] Clang-tidy fixes --- SteamTarget/SteamTarget.h | 4 ++++ SteamTarget/TargetOverlay.h | 6 +++++- SteamTarget/VirtualControllerThread.cpp | 17 ++++++++--------- SteamTarget/VirtualControllerThread.h | 14 ++++++++------ 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/SteamTarget/SteamTarget.h b/SteamTarget/SteamTarget.h index 6219ada..229179c 100644 --- a/SteamTarget/SteamTarget.h +++ b/SteamTarget/SteamTarget.h @@ -28,6 +28,10 @@ class SteamTarget : public QApplication public: SteamTarget(int& argc, char** argv); + SteamTarget(const SteamTarget& other) = delete; + SteamTarget(SteamTarget&& other) noexcept = delete; + SteamTarget& operator=(const SteamTarget& other) = delete; + SteamTarget& operator=(SteamTarget&& other) noexcept = delete; ~SteamTarget() = default; void init(); diff --git a/SteamTarget/TargetOverlay.h b/SteamTarget/TargetOverlay.h index 5f63ad4..520ab4c 100644 --- a/SteamTarget/TargetOverlay.h +++ b/SteamTarget/TargetOverlay.h @@ -23,7 +23,11 @@ class TargetOverlay { public: TargetOverlay() = default; - + TargetOverlay(const TargetOverlay& other) = delete; + TargetOverlay(TargetOverlay&& other) noexcept = delete; + TargetOverlay& operator=(const TargetOverlay& other) = delete; + TargetOverlay& operator=(TargetOverlay&& other) noexcept = delete; + ~TargetOverlay() = default; bool init(bool hidden = false); void stop(); diff --git a/SteamTarget/VirtualControllerThread.cpp b/SteamTarget/VirtualControllerThread.cpp index de4c0ce..edefd07 100644 --- a/SteamTarget/VirtualControllerThread.cpp +++ b/SteamTarget/VirtualControllerThread.cpp @@ -1,5 +1,5 @@ /* -Copyright 2018 Peter Repukat - FlatspotSoftware +Copyright 2016 Peter Repukat - FlatspotSoftware Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ VirtualControllerThread::VirtualControllerThread() { std::cout << "Error initializing ViGem!" << std::endl; MessageBoxW(NULL, L"Error initializing ViGem!", L"GloSC-SteamTarget", MB_OK); - bShouldRun = false; + b_should_run_ = false; } for (int i = 0; i < XUSER_MAX_COUNT; i++) @@ -45,13 +45,13 @@ VirtualControllerThread::~VirtualControllerThread() void VirtualControllerThread::run() { - bShouldRun = true; + b_should_run_ = true; controller_thread_ = std::thread(&VirtualControllerThread::controllerLoop, this); } void VirtualControllerThread::stop() { - bShouldRun = false; + b_should_run_ = false; for (int i = 0; i < XUSER_MAX_COUNT; i++) { vigem_target_remove(driver_, vt_x360_[i]); @@ -61,13 +61,13 @@ void VirtualControllerThread::stop() bool VirtualControllerThread::isRunning() const { - return bShouldRun; + return b_should_run_; } void VirtualControllerThread::controllerLoop() { sf::Clock waitForHookTimer; - while (bShouldRun) + while (b_should_run_) { sf_clock_.restart(); @@ -189,17 +189,16 @@ DWORD VirtualControllerThread::XInputGetStateWrapper(DWORD dwUserIndex, XINPUT_S DWORD VirtualControllerThread::callRealXinputGetState(DWORD dwUserIndex, XINPUT_STATE* pState) { - DWORD ret; DWORD dwOldProtect, dwBkup; - BYTE* Address = reinterpret_cast(x_get_state_); + auto* Address = reinterpret_cast(x_get_state_); VirtualProtect(Address, op_patch_lenght, PAGE_EXECUTE_READWRITE, &dwOldProtect); //Change permissions of memory.. for (DWORD i = 0; i < op_patch_lenght; i++) //unpatch Valve's hook { *(Address + i) = real_bytes_[i]; } - ret = x_get_state_(dwUserIndex, pState); //Cal REAL XInputGetState... + const DWORD ret = x_get_state_(dwUserIndex, pState); //Cal REAL XInputGetState... for (int i = 0; i < op_patch_lenght; i++) //repatch Valve's hook { diff --git a/SteamTarget/VirtualControllerThread.h b/SteamTarget/VirtualControllerThread.h index c281f2d..bdba27f 100644 --- a/SteamTarget/VirtualControllerThread.h +++ b/SteamTarget/VirtualControllerThread.h @@ -22,7 +22,7 @@ limitations under the License. #include #include -#include +#include #include @@ -34,6 +34,10 @@ class VirtualControllerThread { public: VirtualControllerThread(); + VirtualControllerThread(const VirtualControllerThread& other) = delete; + VirtualControllerThread(VirtualControllerThread&& other) noexcept = delete; + VirtualControllerThread& operator=(const VirtualControllerThread& other) = delete; + VirtualControllerThread& operator=(VirtualControllerThread&& other) noexcept = delete; ~VirtualControllerThread(); void run(); @@ -43,13 +47,11 @@ public: private: - std::atomic bShouldRun = false; - - + std::atomic b_should_run_ = false; typedef DWORD(WINAPI* XInputGetState_t)(DWORD dwUserIndex, XINPUT_STATE* pState); static const uint8_t op_patch_lenght = 5; - uint8_t valve_hook_bytes_[5]; + uint8_t valve_hook_bytes_[5]{}; bool seven_ = false; @@ -64,7 +66,7 @@ private: XInputGetState_t x_get_state_ = nullptr; PVIGEM_CLIENT driver_; - PVIGEM_TARGET vt_x360_[XUSER_MAX_COUNT]; + PVIGEM_TARGET vt_x360_[XUSER_MAX_COUNT]{}; std::thread controller_thread_;