summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-16 17:01:24 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-16 17:53:40 +0200
commita5167736460bac22010333cfe7530a5fa50d2c70 (patch)
treeff4c5885483b06f347df37fb19fa97e6047ae959 /compat
parent7e97b1b0ee2d93aeb70b0c50954ff08e1f0eca71 (diff)
compat, dinput: don't overdo COM logic
Diffstat (limited to 'compat')
-rw-r--r--compat/camera-names.cpp6
-rw-r--r--compat/win32-com.cpp45
-rw-r--r--compat/win32-com.hpp19
3 files changed, 3 insertions, 67 deletions
diff --git a/compat/camera-names.cpp b/compat/camera-names.cpp
index 2f4c2f91..add8c094 100644
--- a/compat/camera-names.cpp
+++ b/compat/camera-names.cpp
@@ -3,7 +3,6 @@
#ifdef _WIN32
# define NO_DSHOW_STRSAFE
# include <dshow.h>
-# include "win32-com.hpp"
# include <cwchar>
#elif defined(__unix) || defined(__linux) || defined(__APPLE__)
# include <unistd.h>
@@ -33,7 +32,7 @@ OPENTRACK_COMPAT_EXPORT QList<QString> get_camera_names()
#if defined(_WIN32)
// Create the System Device Enumerator.
HRESULT hr;
- init_com_threading();
+ CoInitialize(nullptr);
ICreateDevEnum *pSysDevEnum = NULL;
hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum);
if (FAILED(hr))
@@ -49,7 +48,8 @@ OPENTRACK_COMPAT_EXPORT QList<QString> get_camera_names()
// Enumerate the monikers.
IMoniker *pMoniker = NULL;
ULONG cFetched;
- while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) {
+ while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK)
+ {
IPropertyBag *pPropBag;
hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
if (SUCCEEDED(hr)) {
diff --git a/compat/win32-com.cpp b/compat/win32-com.cpp
deleted file mode 100644
index b782e3a7..00000000
--- a/compat/win32-com.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifdef _WIN32
-
-#include "win32-com.hpp"
-
-#include "compat/util.hpp"
-
-#include <QString>
-#include <QCoreApplication>
-#include <QApplication>
-#include <QThread>
-#include <QDebug>
-
-bool OPENTRACK_COMPAT_EXPORT init_com_threading(com_type t_)
-{
- const com_type t = progn(
- if (t_ != com_invalid)
- return t_;
- if (QCoreApplication::instance() == nullptr)
- return com_apartment;
- if (qApp->thread() == QThread::currentThread())
- return com_apartment;
- else
- //return com_multithreaded;
- return com_apartment;
- );
-
- HRESULT ret = CoInitializeEx(0, t);
-
- if (ret != S_OK && ret != S_FALSE)
- {
- qDebug() << "CoInitializeEx failed" << (progn (
- switch (ret)
- {
- case RPC_E_CHANGED_MODE:
- return QStringLiteral("COM threading mode already set");
- default:
- return QStringLiteral("Unknown error ") + QString::number(long(ret));
- }
- ));
- return false;
- }
-
- return true;
-}
-#endif
diff --git a/compat/win32-com.hpp b/compat/win32-com.hpp
deleted file mode 100644
index fe2b478f..00000000
--- a/compat/win32-com.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#pragma once
-
-#ifdef _WIN32
-
-#include "export.hpp"
-
-#include <objbase.h>
-#include <ole2.h>
-
-enum com_type : int
-{
- com_multithreaded = COINIT_MULTITHREADED,
- com_apartment = COINIT_APARTMENTTHREADED,
- com_invalid = 0,
-};
-
-bool OPENTRACK_COMPAT_EXPORT init_com_threading(com_type t = com_invalid);
-
-#endif