diff options
Diffstat (limited to 'dinput/dinput.cpp')
-rw-r--r-- | dinput/dinput.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/dinput/dinput.cpp b/dinput/dinput.cpp index e896f5f1..575922d9 100644 --- a/dinput/dinput.cpp +++ b/dinput/dinput.cpp @@ -1,4 +1,6 @@ #include "dinput.hpp" +#include "compat/macros.hpp" + #include <QDebug> int di_t::refcnt{0}; @@ -58,3 +60,32 @@ di_t::~di_t() unref_di(); } +bool di_t::poll_device(LPDIRECTINPUTDEVICE8 dev) +{ + HRESULT hr; + + switch (dev->Poll()) + { + case DI_OK: + case DI_NOEFFECT: + return true; + default: + break; + } + + switch (hr = dev->Acquire()) + { + case DI_OK: + case S_FALSE: + switch (hr = dev->Poll()) + { + case DI_OK: + case DI_NOEFFECT: + return true; + default: + eval_once(qDebug() << "dinput: device poll failed:" << (void*)hr); + } + } + + return false; +} |