From 3a3f56689e8d0ccebde4668dc81c975f03381ff7 Mon Sep 17 00:00:00 2001 From: Hinsbart Date: Thu, 28 Apr 2016 15:53:49 +0200 Subject: [PATCH] More precise InputMap Axis descriptions in project settings. Now it's "Left Stick {Up, Down, Left, Right}" instead of just "Left Stick" repeated 4x. (cherry picked from commit 418049b741bc6aa1445e64b78c681e5291f5a4d4) --- tools/editor/project_settings.cpp | 42 +++++++++++++------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp index cd11345e0d7..f4797b4338e 100644 --- a/tools/editor/project_settings.cpp +++ b/tools/editor/project_settings.cpp @@ -56,6 +56,20 @@ static const char* _button_names[JOY_BUTTON_MAX]={ "D-Pad Right" }; +static const char* _axis_names[JOY_AXIS_MAX*2] = { + " (Left Stick Left)", + " (Left Stick Right)", + " (Left Stick Up)", + " (Left Stick Down)", + " (Right Stick Left)", + " (Right Stick Right)", + " (Right Stick Up)", + " (Right Stick Down)", + "","","","", + "", " (L2)", + "", " (R2)" +}; + void ProjectSettings::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { @@ -342,19 +356,7 @@ void ProjectSettings::_add_item(int p_item){ device_index->clear(); for(int i=0;iadd_item("Axis "+itos(i/2)+" "+(i&1?"+":"-")+desc); } device_input->popup_centered(Size2(350,95)); @@ -541,18 +543,10 @@ void ProjectSettings::_update_actions() { } break; case InputEvent::JOYSTICK_MOTION: { - String desc; int ax = ie.joy_motion.axis; - - if (ax==0 || ax==1) - desc=" (Left Stick)."; - else if (ax==2 || ax==3) - desc=" (Right Stick)."; - else if (ax==6) - desc=" (L2)."; - else if (ax==7) - desc=" (R2)."; - String str = "Device "+itos(ie.device)+", Axis "+itos(ie.joy_motion.axis)+" "+(ie.joy_motion.axis_value<0?"-":"+")+desc; + int n = 2*ax + (ie.joy_motion.axis_value<0 ? 0:1); + String desc = _axis_names[n]; + String str = "Device "+itos(ie.device)+", Axis "+itos(ax)+" "+(ie.joy_motion.axis_value<0?"-":"+")+desc +"."; action->set_text(0,str); action->set_icon(0,get_icon("JoyAxis","EditorIcons")); } break;