Moved pairInputDesktop() from desktop.h to input.cpp

This commit is contained in:
loki 2021-04-26 19:27:55 +02:00
parent bb88d6f828
commit 1be5b4787f
3 changed files with 19 additions and 23 deletions

View File

@ -1,18 +0,0 @@
namespace platf {
using namespace std::literals;
inline auto pairInputDesktop(){
auto hDesk = OpenInputDesktop(DF_ALLOWOTHERACCOUNTHOOK, FALSE, GENERIC_ALL);
if (NULL == hDesk) {
auto err = GetLastError();
BOOST_LOG(error) << "Failed to OpenInputDesktop [0x"sv << util::hex(err).to_string_view() << ']';
} else {
BOOST_LOG(info) << std::endl << "Opened desktop [0x"sv << util::hex(hDesk).to_string_view() << ']';
if (!SetThreadDesktop(hDesk) ) {
auto err = GetLastError();
BOOST_LOG(error) << "Failed to SetThreadDesktop [0x"sv << util::hex(err).to_string_view() << ']';
}
CloseDesktop(hDesk);
}
return hDesk;
};
};

View File

@ -10,8 +10,6 @@
#include "display.h"
#include "desktop.h"
namespace platf {
using namespace std::literals;
}
@ -92,7 +90,6 @@ int display_base_t::init() {
FreeLibrary(user32);
});
*/
pairInputDesktop();
dxgi::factory1_t::pointer factory_p {};
dxgi::adapter_t::pointer adapter_p {};

View File

@ -12,14 +12,13 @@
#include "sunshine/main.h"
#include "sunshine/platform/common.h"
#include "desktop.h"
namespace platf {
using namespace std::literals;
using adapteraddrs_t = util::c_ptr<IP_ADAPTER_ADDRESSES>;
volatile HDESK _lastKnownInputDesktop = NULL;
HDESK pairInputDesktop();
class vigem_t {
public:
@ -355,6 +354,24 @@ int thread_priority() {
return SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) ? 0 : 1;
}
HDESK pairInputDesktop() {
auto hDesk = OpenInputDesktop(DF_ALLOWOTHERACCOUNTHOOK, FALSE, GENERIC_ALL);
if (NULL == hDesk) {
auto err = GetLastError();
BOOST_LOG(error) << "Failed to OpenInputDesktop [0x"sv << util::hex(err).to_string_view() << ']';
}
else {
BOOST_LOG(info) << std::endl << "Opened desktop [0x"sv << util::hex(hDesk).to_string_view() << ']';
if (!SetThreadDesktop(hDesk) ) {
auto err = GetLastError();
BOOST_LOG(error) << "Failed to SetThreadDesktop [0x"sv << util::hex(err).to_string_view() << ']';
}
CloseDesktop(hDesk);
}
return hDesk;
};
void freeInput(void *p) {
auto vigem = (vigem_t*)p;