From 4ad662d67bb12feed12095cd9a41a46bfac16d1c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 08:52:59 +0200 Subject: win32-joystick: fix duplicate device name selection logic Tested-by: @nanospork Closes #230 --- .../ftnoir_tracker_joystick_dialog.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp') diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index f3b7077c..0463933f 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -4,9 +4,12 @@ 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(QString(pdidInstance->tszInstanceName), - guid_to_string(pdidInstance->guidInstance)); + self->ui.joylist->addItem(name + " " + guid); return DIENUM_CONTINUE; } @@ -38,8 +41,6 @@ fin: g_pDI->Release(); } - tie_setting(s.joyid, ui.joylist); - tie_setting(s.joy_1, ui.joy_1); tie_setting(s.joy_2, ui.joy_2); tie_setting(s.joy_3, ui.joy_3); @@ -49,7 +50,11 @@ fin: } void TrackerControls::doOK() { - s.guid = ui.joylist->currentData().toString(); + 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(); -- cgit v1.2.3