summaryrefslogtreecommitdiffhomepage
path: root/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-joystick/ftnoir_tracker_joystick_dialog.cpp')
-rw-r--r--tracker-joystick/ftnoir_tracker_joystick_dialog.cpp46
1 files changed, 6 insertions, 40 deletions
diff --git a/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp b/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp
index 26436c7a..28846809 100644
--- a/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp
+++ b/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp
@@ -1,17 +1,6 @@
#include "ftnoir_tracker_joystick.h"
#include "opentrack/plugin-api.hpp"
-static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext )
-{
- auto self = ( TrackerControls* )pContext;
- auto name = QString(pdidInstance->tszInstanceName);
- auto guid = guid_to_string(pdidInstance->guidInstance);
- TrackerControls::joys cur { name, guid };
- self->_joys.append(cur);
-
- return DIENUM_CONTINUE;
-}
-
TrackerControls::TrackerControls() : tracker(nullptr)
{
ui.setupUi( this );
@@ -21,33 +10,14 @@ TrackerControls::TrackerControls() : tracker(nullptr)
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
{
- auto hr = CoInitialize( nullptr );
- LPDIRECTINPUT8 g_pDI = nullptr;
-
- if( FAILED( hr = DirectInput8Create( GetModuleHandle( NULL ), DIRECTINPUT_VERSION,
- IID_IDirectInput8, ( VOID** )&g_pDI, NULL ) ) )
- goto fin;
-
- if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL,
- EnumJoysticksCallback,
- this,
- DIEDFL_ATTACHEDONLY )))
- goto fin;
-
-fin:
- if (g_pDI)
- g_pDI->Release();
+ win32_joy_ctx joy_ctx;
+
+ _joys = QList<joys>();
+
+ for (auto& j : joy_ctx.joys())
+ _joys.push_back(joys { j.second->name, j.first });
}
- std::sort(_joys.begin(),
- _joys.end(),
- [&](const joys& j1, const joys& j2) -> bool
- {
- if (j1.name == j2.name)
- return j1.guid < j2.guid;
- return j1.name < j2.name;
- });
-
{
int idx = 0;
for (int i = 0; i < _joys.size(); i++)
@@ -75,8 +45,6 @@ void TrackerControls::doOK() {
s.guid = val.guid;
s.joyid = val.name;
s.b->save();
- if (tracker)
- tracker->reload();
this->close();
}
@@ -84,5 +52,3 @@ void TrackerControls::doCancel() {
s.b->reload();
this->close();
}
-
-