Merge pull request #4468 from Hinsbart/better_axis_desc
More precise InputMap Axis descriptions in project settings.
This commit is contained in:
commit
ea0231a56c
|
@ -56,6 +56,20 @@ static const char* _button_names[JOY_BUTTON_MAX]={
|
||||||
"D-Pad Right"
|
"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) {
|
void ProjectSettings::_notification(int p_what) {
|
||||||
|
|
||||||
if (p_what==NOTIFICATION_ENTER_TREE) {
|
if (p_what==NOTIFICATION_ENTER_TREE) {
|
||||||
|
@ -342,19 +356,7 @@ void ProjectSettings::_add_item(int p_item){
|
||||||
device_index->clear();
|
device_index->clear();
|
||||||
for(int i=0;i<JOY_AXIS_MAX*2;i++) {
|
for(int i=0;i<JOY_AXIS_MAX*2;i++) {
|
||||||
|
|
||||||
String desc;
|
String desc = _axis_names[i];
|
||||||
|
|
||||||
int ax=i/2;
|
|
||||||
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)";
|
|
||||||
|
|
||||||
|
|
||||||
device_index->add_item("Axis "+itos(i/2)+" "+(i&1?"+":"-")+desc);
|
device_index->add_item("Axis "+itos(i/2)+" "+(i&1?"+":"-")+desc);
|
||||||
}
|
}
|
||||||
device_input->popup_centered(Size2(350,95));
|
device_input->popup_centered(Size2(350,95));
|
||||||
|
@ -541,18 +543,10 @@ void ProjectSettings::_update_actions() {
|
||||||
} break;
|
} break;
|
||||||
case InputEvent::JOYSTICK_MOTION: {
|
case InputEvent::JOYSTICK_MOTION: {
|
||||||
|
|
||||||
String desc;
|
|
||||||
int ax = ie.joy_motion.axis;
|
int ax = ie.joy_motion.axis;
|
||||||
|
int n = 2*ax + (ie.joy_motion.axis_value<0 ? 0:1);
|
||||||
if (ax==0 || ax==1)
|
String desc = _axis_names[n];
|
||||||
desc=" (Left Stick).";
|
String str = "Device "+itos(ie.device)+", Axis "+itos(ax)+" "+(ie.joy_motion.axis_value<0?"-":"+")+desc +".";
|
||||||
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;
|
|
||||||
action->set_text(0,str);
|
action->set_text(0,str);
|
||||||
action->set_icon(0,get_icon("JoyAxis","EditorIcons"));
|
action->set_icon(0,get_icon("JoyAxis","EditorIcons"));
|
||||||
} break;
|
} break;
|
||||||
|
|
Loading…
Reference in New Issue