From c4c69df6dcf0492c2a4088301a35ab73138b54e3 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 19 Sep 2010 04:04:34 +0000 Subject: [PATCH] - Fixed: FOptionMenuItemJoyMap::SetSelection() did not convert from menu selection number to joyaxis number. SVN r2829 (trunk) --- src/menu/joystickmenu.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/menu/joystickmenu.cpp b/src/menu/joystickmenu.cpp index a29df9596..27bd150f8 100644 --- a/src/menu/joystickmenu.cpp +++ b/src/menu/joystickmenu.cpp @@ -168,7 +168,8 @@ public: int GetSelection() { - float f = (float)(int)SELECTED_JOYSTICK->GetAxisMap(mAxis); + double f = SELECTED_JOYSTICK->GetAxisMap(mAxis); + // Map from joystick axis to menu selection. for(unsigned i=0;imValues.Size(); i++) { if (fabs(f - mValues->mValues[i].Value) < FLT_EPSILON) @@ -179,9 +180,18 @@ public: return -1; } - void SetSelection(int Selection) + void SetSelection(int selection) { - SELECTED_JOYSTICK->SetAxisMap(mAxis, (EJoyAxis)Selection); + // Map from menu selection to joystick axis. + if ((unsigned)selection >= mValues->mValues.Size()) + { + selection = JOYAXIS_None; + } + else + { + selection = (int)mValues->mValues[selection].Value; + } + SELECTED_JOYSTICK->SetAxisMap(mAxis, (EJoyAxis)selection); } };