diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-30 09:01:32 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-30 09:01:32 +0100 |
| commit | d785d3616500d5846ac8c5f5a6347da832a593b4 (patch) | |
| tree | ac670a125c5b880ad7e4b4f24a8635da4e66f0da /tracker-joystick/ftnoir_tracker_joystick_dialog.cpp | |
| parent | 232c2ba8aca7900eaa950c48813ddfaca8a749a8 (diff) | |
| parent | 9b736d361bcde7a2ddaf3fe54b471c0e658e94f4 (diff) | |
Merge branch 'unstable' into trackhat
* unstable:
cmake: cleanup hydra
rename gui directory
move to subdirectory-based build system
cmake: switch to GNU CC 5.2.0 in mingw-w64 toolchain file
rift-080: forgot ovr_Initialize()
rift 025: fix name
Diffstat (limited to 'tracker-joystick/ftnoir_tracker_joystick_dialog.cpp')
| -rw-r--r-- | tracker-joystick/ftnoir_tracker_joystick_dialog.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp b/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp new file mode 100644 index 00000000..0463933f --- /dev/null +++ b/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp @@ -0,0 +1,69 @@ +#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); + + self->ui.joylist->addItem(name + " " + guid); + + return DIENUM_CONTINUE; +} + +TrackerControls::TrackerControls() : tracker(nullptr) +{ + ui.setupUi( this ); + + // Connect Qt signals to member-functions + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + 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(); + } + + tie_setting(s.joy_1, ui.joy_1); + tie_setting(s.joy_2, ui.joy_2); + tie_setting(s.joy_3, ui.joy_3); + tie_setting(s.joy_4, ui.joy_4); + tie_setting(s.joy_5, ui.joy_5); + tie_setting(s.joy_6, ui.joy_6); +} + +void TrackerControls::doOK() { + int idx = ui.joylist->currentIndex(); + joys def { "", "" }; + auto val = _joys.value(idx, def); + s.guid = val.guid; + s.joyid = val.name; + s.b->save(); + if (tracker) + tracker->reload(); + this->close(); +} + +void TrackerControls::doCancel() { + s.b->reload(); + this->close(); +} + + |
