From 7420261dc38f5857a6ba0ac8ea436f29b6997840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=B6glinger-Stelzer?= Date: Tue, 27 Aug 2019 10:46:08 -0400 Subject: [PATCH] Removed obsolete files Removed Vcpkg attributes from project file Removed Vcpkg instructions and cache from appveyor.yml --- appveyor.yml | 6 -- src/NotificationRequestPool.cpp | 134 -------------------------------- src/NotificationRequestPool.h | 66 ---------------- src/ViGEmClient.vcxproj | 2 - src/XusbNotificationRequest.cpp | 85 -------------------- src/XusbNotificationRequest.h | 44 ----------- 6 files changed, 337 deletions(-) delete mode 100644 src/NotificationRequestPool.cpp delete mode 100644 src/NotificationRequestPool.h delete mode 100644 src/XusbNotificationRequest.cpp delete mode 100644 src/XusbNotificationRequest.h diff --git a/appveyor.yml b/appveyor.yml index 0b5b6a2..e10b69d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,15 +1,9 @@ version: 1.16.{build}.0 image: Visual Studio 2017 -before_build: -- cmd: vcpkg integrate install -- cmd: vcpkg install boost-asio:x86-windows-static -- cmd: vcpkg install boost-asio:x64-windows-static build_script: - ps: .\build.ps1 artifacts: - path: 'bin**\*.dll' -cache: -- c:\tools\vcpkg\installed\ deploy: - provider: Environment name: BUILDBOT diff --git a/src/NotificationRequestPool.cpp b/src/NotificationRequestPool.cpp deleted file mode 100644 index d911eee..0000000 --- a/src/NotificationRequestPool.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* -MIT License - -Copyright (c) 2017-2019 Nefarius Software Solutions e.U. and Contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - - -#include "NotificationRequestPool.h" - -void NotificationRequestPool::strand_dispatch_worker() const -{ - io_svc_->run(); -} - -NotificationRequestPool::NotificationRequestPool( - PVIGEM_CLIENT client, - PVIGEM_TARGET target -) : - client_(client), - target_(target), - stop_(false) -{ - // prepare array of handles and request wrappers - for (auto& wait_handle : wait_handles_) - { - // create auto-reset event - wait_handle = CreateEvent(nullptr, FALSE, FALSE, nullptr); - // create async pending I/O request wrapper - requests_.push_back(std::make_unique( - client_, - target_, - wait_handle - )); - } - - // init ASIO - io_svc_.reset(new boost::asio::io_service()); - worker_.reset(new boost::asio::io_service::work(*io_svc_)); - - // launch notification completion thread - thread_ = std::make_shared(boost::ref(*this)); - - // launch boost I/O service dispatcher thread - worker_thread_ = std::make_shared( - boost::bind(&NotificationRequestPool::strand_dispatch_worker, this)); - - // submit pending I/O to driver - for (auto& request : requests_) - request->request_async(); -} - -NotificationRequestPool::~NotificationRequestPool() noexcept(false) -{ - for (auto& wait_handle : wait_handles_) - CloseHandle(wait_handle); - - for (auto& request : requests_) - request.reset(); - - io_svc_->stop(); - worker_thread_->join(); -} - -void NotificationRequestPool::operator()() -{ - // used to dispatch notification callback - boost::asio::io_service::strand strand(*io_svc_); - - while (true) - { - // wait for the first pending I/O to signal its event - const auto ret = WaitForMultipleObjects( - requests_.size(), - wait_handles_, - FALSE, // first one to be signaled wins - 25 // don't block indefinitely so worker can be canceled - ); - - // timeout has occurred... - if (ret == WAIT_TIMEOUT) - { - // ...check for termination request - boost::mutex::scoped_lock lock(m_); - if (stop_) - // exits function (terminates thread) - break; - - // go for another round - continue; - } - - // handles are closed...? - if (ret == WAIT_FAILED) - { - // exits function (terminates thread) - break; - } - - // index of the request which just got completed - const auto index = ret - WAIT_OBJECT_0; - // grab associated request - const auto req = requests_[index].get(); - - // submit callback for async yet ordered invocation - req->post(std::move(strand)); - - // submit another pending I/O - req->request_async(); - } -} - -void NotificationRequestPool::terminate() -{ - boost::mutex::scoped_lock lock(m_); - stop_ = true; -} diff --git a/src/NotificationRequestPool.h b/src/NotificationRequestPool.h deleted file mode 100644 index eaca845..0000000 --- a/src/NotificationRequestPool.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -MIT License - -Copyright (c) 2017-2019 Nefarius Software Solutions e.U. and Contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - - -#pragma once - -#include -#include -#include -#include -#include "XusbNotificationRequest.h" -#include "ViGEm/Client.h" -#include "Internal.h" - - -class NotificationRequestPool -{ - static const int thread_count = 20; - HANDLE wait_handles_[thread_count]{}; - - PVIGEM_CLIENT client_; - PVIGEM_TARGET target_; - - std::vector> requests_; - std::shared_ptr thread_; - boost::mutex m_; - boost::condition_variable cv_; - bool stop_; - - boost::shared_ptr io_svc_; - boost::shared_ptr worker_; - std::shared_ptr worker_thread_; - - void strand_dispatch_worker() const; - -public: - NotificationRequestPool( - PVIGEM_CLIENT client, - PVIGEM_TARGET target - ); - ~NotificationRequestPool() noexcept(false); - - void operator()(); - void terminate(); -}; diff --git a/src/ViGEmClient.vcxproj b/src/ViGEmClient.vcxproj index 12c905e..dddf1ba 100644 --- a/src/ViGEmClient.vcxproj +++ b/src/ViGEmClient.vcxproj @@ -38,8 +38,6 @@ {7DB06674-1F4F-464B-8E1C-172E9587F9DC} Win32Proj ViGEmClient - x86-windows-static - x64-windows-static diff --git a/src/XusbNotificationRequest.cpp b/src/XusbNotificationRequest.cpp deleted file mode 100644 index d951b44..0000000 --- a/src/XusbNotificationRequest.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* -MIT License - -Copyright (c) 2017-2019 Nefarius Software Solutions e.U. and Contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - - -#include "XusbNotificationRequest.h" -#include -#include -#include "Internal.h" -#include -#include - - -XusbNotificationRequest::XusbNotificationRequest( - PVIGEM_CLIENT client, - PVIGEM_TARGET target, - HANDLE notification -) : client_(client), - target_(target), - payload_(), - overlapped_() -{ - memset(&overlapped_, 0, sizeof(OVERLAPPED)); - overlapped_.hEvent = notification; - XUSB_REQUEST_NOTIFICATION_INIT(&payload_, target_->SerialNo); -} - -bool XusbNotificationRequest::request_async() -{ - // queue request in driver - const auto ret = DeviceIoControl( - client_->hBusDevice, - IOCTL_XUSB_REQUEST_NOTIFICATION, - &payload_, - payload_.Size, - &payload_, - payload_.Size, - nullptr, - &overlapped_ - ); - - const auto error = GetLastError(); - - return (!ret && error == ERROR_IO_PENDING); -} - -void XusbNotificationRequest::post(boost::asio::io_service::strand strand) -{ - // prepare queueing library caller notification callback - const boost::function pfn = PFN_VIGEM_X360_NOTIFICATION(target_->Notification); - - // submit callback for async yet ordered invocation - strand.post(boost::bind(pfn, - client_, - target_, - payload_.LargeMotor, - payload_.SmallMotor, - payload_.LedNumber - )); -} diff --git a/src/XusbNotificationRequest.h b/src/XusbNotificationRequest.h deleted file mode 100644 index 851a2d0..0000000 --- a/src/XusbNotificationRequest.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -MIT License - -Copyright (c) 2017-2019 Nefarius Software Solutions e.U. and Contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - - -#pragma once - -#include -#include "ViGEm/km/BusShared.h" -#include -#include "ViGEm/Client.h" - -class XusbNotificationRequest -{ - PVIGEM_CLIENT client_; - PVIGEM_TARGET target_; - XUSB_REQUEST_NOTIFICATION payload_; - OVERLAPPED overlapped_; - -public: - XusbNotificationRequest(PVIGEM_CLIENT client, PVIGEM_TARGET target, HANDLE notification); - bool request_async(); - void post(boost::asio::io_service::strand strand); -};