diff options
-rw-r--r-- | tracker-joystick/ftnoir_tracker_joystick_dialog.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp b/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp index 0463933f..26436c7a 100644 --- a/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp @@ -9,8 +9,6 @@ static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance TrackerControls::joys cur { name, guid }; self->_joys.append(cur); - self->ui.joylist->addItem(name + " " + guid); - return DIENUM_CONTINUE; } @@ -40,6 +38,27 @@ fin: if (g_pDI) g_pDI->Release(); } + + 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++) + { + const joys& j = _joys[i]; + if (j.guid == s.guid && j.name == s.joyid) + idx = i; + ui.joylist->addItem(j.name + " " + j.guid); + } + ui.joylist->setCurrentIndex(idx); + } tie_setting(s.joy_1, ui.joy_1); tie_setting(s.joy_2, ui.joy_2); |