From 73c62db8a98e676328a17569b821a0fb3c397a39 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 16 Nov 2015 09:45:19 +0100 Subject: tracker/win32-joy: forgot to save stick index Issue: #267 --- .../ftnoir_tracker_joystick_dialog.cpp | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'tracker-joystick') 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); -- cgit v1.2.3