void ShowJoystickInfos() { _joystickInfosProperty = serializedObject.FindProperty("_joystickInfos"); if (AddFoldOut(_joystickInfosProperty, "Joysticks".ToGUIContent())) { JoystickInfo[] joystickInfos = _inputSystem.GetJoystickInfos(); JoystickInfo joystickInfo = joystickInfos.Last(); joystickInfo.SetUniqueName("default", "", joystickInfos); serializedObject.Update(); } if (_joystickInfosProperty.isExpanded) { EditorGUI.indentLevel += 1; for (int i = 0; i < _joystickInfosProperty.arraySize; i++) { _currentJoystickInfo = _inputSystem.GetJoystickInfos()[i]; _currentJoystickInfoProperty = _joystickInfosProperty.GetArrayElementAtIndex(i); BeginBox(); string joystickName = _currentJoystickInfoProperty.FindPropertyRelative("_joystick").GetValue<Joysticks>().ToString(); if (DeleteFoldOut(_joystickInfosProperty, i, string.Format("{0} ({1})", _currentJoystickInfo.Name, joystickName).ToGUIContent(), CustomEditorStyles.BoldFoldout)) { break; } ShowJoystickInfo(); EndBox(); } Separator(); EditorGUI.indentLevel -= 1; } }
void xna_init_input() { int tot, i, j, k; string buf = ""; for (i = 0; i < 4; i++) { joy[i] = new GamepadInfo(); } tot = 0; /* first of all, map mouse buttons */ //for (j = 0; j < 3; j++) //{ // buf = sprintf("MOUSE B%d", j + 1); // joynames[tot] = buf; // joylist[tot] = new JoystickInfo(); // joylist[tot].name = joynames[tot]; // joylist[tot].code = MOUSE_BUTTON(j + 1); // tot++; //} for (i = 0; i < num_joysticks; i++) { for (j = 0; j < joy[i].num_sticks; j++) { for (k = 0; k < joy[i].stick[j].num_axis; k++) { joylist[tot] = new JoystickInfo(); joynames[tot] = sprintf(buf, "J%d %s %s -", i + 1, joy[i].stick[j].name, joy[i].stick[j].axis[k].name); joylist[tot].name = joynames[tot]; joylist[tot].code = (uint)JOYCODE(i + 1, j + 1, k + 1, 1); tot++; joylist[tot] = new JoystickInfo(); joynames[tot] = sprintf("J%d %s %s +", i + 1, joy[i].stick[j].name, joy[i].stick[j].axis[k].name); joylist[tot].name = joynames[tot]; joylist[tot].code = (uint)JOYCODE(i + 1, j + 1, k + 1, 2); tot++; } } for (j = 0; j < joy[i].num_buttons; j++) { joynames[tot] = sprintf(buf, "J%d %s", i + 1, joy[i].button[j].name); joylist[tot] = new JoystickInfo(); joylist[tot].name = joynames[tot]; joylist[tot].code = (uint)JOYCODE(i + 1, 0, j + 1, 0); tot++; } } joylist[tot] = new JoystickInfo(); /* terminate array */ joylist[tot].name = null; joylist[tot].code = 0; joylist[tot].standardcode = 0; /* fill in equivalences */ for (i = 0; i < tot; i++) { joylist[i].standardcode = (uint)InputCodes.CODE_OTHER; j = 0; while (joyequiv[j][0] != 0) { if (joyequiv[j][0] == joylist[i].code) { joylist[i].standardcode = (uint)joyequiv[j][1]; break; } j++; } } }