summaryrefslogtreecommitdiffhomepage
path: root/tracker-joystick
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-11-16 09:45:19 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-11-16 09:45:19 +0100
commit73c62db8a98e676328a17569b821a0fb3c397a39 (patch)
treed8e46bb4164d3f8798979be390533b78160a3a13 /tracker-joystick
parent798f6e9076855bf7769aba8abde4d570960d0755 (diff)
tracker/win32-joy: forgot to save stick index
Issue: #267
Diffstat (limited to 'tracker-joystick')
-rw-r--r--tracker-joystick/ftnoir_tracker_joystick_dialog.cpp23
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);