// command private void comboboxCommand_SelectedIndexChanged(object sender, EventArgs e) { if (this.Tag == null & listviewControls.SelectedIndices.Count == 1) { int i = listviewControls.SelectedIndices[0]; int j = comboboxCommand.SelectedIndex; if (j >= 0) { Interface.CurrentControls[i].Command = Interface.CommandInfos[j].Command; Interface.CommandInfo Info; Interface.TryGetCommandInfo(Interface.CommandInfos[j].Command, out Info); Interface.CurrentControls[i].InheritedType = Info.Type; UpdateControlListElement(listviewControls.Items[i], i, true); } } }
private void UpdateControlListElement(ListViewItem Item, int Index, bool ResizeColumns) { Interface.CommandInfo Info; Interface.TryGetCommandInfo(Interface.CurrentControls[Index].Command, out Info); Item.SubItems[0].Text = Info.Name; switch (Info.Type) { case Interface.CommandType.Digital: Item.SubItems[1].Text = Interface.GetInterfaceString("controls_list_type_digital"); break; case Interface.CommandType.AnalogHalf: Item.SubItems[1].Text = Interface.GetInterfaceString("controls_list_type_analoghalf"); break; case Interface.CommandType.AnalogFull: Item.SubItems[1].Text = Interface.GetInterfaceString("controls_list_type_analogfull"); break; default: Item.SubItems[1].Text = Info.Type.ToString(); break; } Item.SubItems[2].Text = Info.Description; if (Interface.CurrentControls[Index].Method == Interface.ControlMethod.Keyboard) { Item.ImageKey = "keyboard"; } else if (Interface.CurrentControls[Index].Method == Interface.ControlMethod.Joystick) { if (Info.Type == Interface.CommandType.AnalogHalf | Info.Type == Interface.CommandType.AnalogFull) { Item.ImageKey = "joystick"; } else { Item.ImageKey = "gamepad"; } } else { Item.ImageKey = null; } Item.SubItems[3].Text = GetControlDetails(Index); if (ResizeColumns) { listviewControls.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); } }
// get control details private string GetControlDetails(int Index) { Interface.CommandInfo Info; Interface.TryGetCommandInfo(Interface.CurrentControls[Index].Command, out Info); System.Globalization.CultureInfo Culture = System.Globalization.CultureInfo.InvariantCulture; string Separator = Interface.GetInterfaceString("controls_assignment_separator"); if (Interface.CurrentControls[Index].Method == Interface.ControlMethod.Keyboard) { string t = Interface.GetInterfaceString("controls_assignment_keyboard") + Separator; if ((Interface.CurrentControls[Index].Modifier & Interface.KeyboardModifier.Shift) != 0) { t += Interface.GetInterfaceString("controls_assignment_keyboard_shift"); } if ((Interface.CurrentControls[Index].Modifier & Interface.KeyboardModifier.Ctrl) != 0) { t += Interface.GetInterfaceString("controls_assignment_keyboard_ctrl"); } if ((Interface.CurrentControls[Index].Modifier & Interface.KeyboardModifier.Alt) != 0) { t += Interface.GetInterfaceString("controls_assignment_keyboard_alt"); } int j; for (j = 0; j < Interface.Keys.Length; j++) { if (Interface.Keys[j].Value == Interface.CurrentControls[Index].Element) { t += Interface.Keys[j].Description; break; } } if (j == Interface.Keys.Length) { t += "{" + Interface.CurrentControls[Index].Element.ToString(Culture) + "}"; } return(t); } else if (Interface.CurrentControls[Index].Method == Interface.ControlMethod.Joystick) { string t = Interface.GetInterfaceString("controls_assignment_joystick").Replace("[index]", (Interface.CurrentControls[Index].Device + 1).ToString(Culture)); switch (Interface.CurrentControls[Index].Component) { case Interface.JoystickComponent.Axis: t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_axis").Replace("[index]", (Interface.CurrentControls[Index].Element + 1).ToString(Culture)); if (Interface.CurrentControls[Index].Direction == -1) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_axis_negative"); } else if (Interface.CurrentControls[Index].Direction == 1) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_axis_positive"); } else { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_axis_invalid"); } break; case Interface.JoystickComponent.Button: t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_button").Replace("[index]", (Interface.CurrentControls[Index].Element + 1).ToString(Culture)); break; case Interface.JoystickComponent.Hat: t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat").Replace("[index]", (Interface.CurrentControls[Index].Element + 1).ToString(Culture)); if (Interface.CurrentControls[Index].Direction == (int)Sdl.SDL_HAT_LEFT) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_left"); } else if (Interface.CurrentControls[Index].Direction == (int)Sdl.SDL_HAT_LEFTUP) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_upleft"); } else if (Interface.CurrentControls[Index].Direction == (int)Sdl.SDL_HAT_UP) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_up"); } else if (Interface.CurrentControls[Index].Direction == (int)Sdl.SDL_HAT_RIGHTUP) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_upright"); } else if (Interface.CurrentControls[Index].Direction == (int)Sdl.SDL_HAT_RIGHT) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_right"); } else if (Interface.CurrentControls[Index].Direction == (int)Sdl.SDL_HAT_RIGHTDOWN) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_downright"); } else if (Interface.CurrentControls[Index].Direction == (int)Sdl.SDL_HAT_DOWN) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_down"); } else if (Interface.CurrentControls[Index].Direction == (int)Sdl.SDL_HAT_LEFTDOWN) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_downleft"); } else { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_invalid"); } break; default: break; } return(t); } else { return(Interface.GetInterfaceString("controls_assignment_invalid")); } }
// get control details private string GetControlDetails(int Index) { Interface.CommandInfo Info; Interface.TryGetCommandInfo(Interface.CurrentControls[Index].Command, out Info); System.Globalization.CultureInfo Culture = System.Globalization.CultureInfo.InvariantCulture; string Separator = Interface.GetInterfaceString("controls_assignment_separator"); if (Interface.CurrentControls[Index].Method == Interface.ControlMethod.Keyboard) { string t = Interface.GetInterfaceString("controls_assignment_keyboard") + Separator; if ((Interface.CurrentControls[Index].Modifier & Interface.KeyboardModifier.Shift) != 0) { t += Interface.GetInterfaceString("controls_assignment_keyboard_shift"); } if ((Interface.CurrentControls[Index].Modifier & Interface.KeyboardModifier.Ctrl) != 0) { t += Interface.GetInterfaceString("controls_assignment_keyboard_ctrl"); } if ((Interface.CurrentControls[Index].Modifier & Interface.KeyboardModifier.Alt) != 0) { t += Interface.GetInterfaceString("controls_assignment_keyboard_alt"); } int j; for (j = 0; j < 133; j++) { //OpenTK key description if (Interface.CurrentControls[Index].Key != Key.Unknown) { t += Interface.CurrentControls[Index].Key; break; } } if (j == 133) { t += "{" + Interface.CurrentControls[Index].Element.ToString(Culture) + "}"; } return(t); } if (Interface.CurrentControls[Index].Method == Interface.ControlMethod.Joystick) { string t = Interface.GetInterfaceString("controls_assignment_joystick").Replace("[index]", (Interface.CurrentControls[Index].Device + 1).ToString(Culture)); switch (Interface.CurrentControls[Index].Component) { case Interface.JoystickComponent.Axis: t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_axis").Replace("[index]", (Interface.CurrentControls[Index].Element + 1).ToString(Culture)); if (Interface.CurrentControls[Index].Direction == -1) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_axis_negative"); } else if (Interface.CurrentControls[Index].Direction == 1) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_axis_positive"); } else { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_axis_invalid"); } break; case Interface.JoystickComponent.Button: t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_button").Replace("[index]", (Interface.CurrentControls[Index].Element + 1).ToString(Culture)); break; case Interface.JoystickComponent.Hat: t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat").Replace("[index]", (Interface.CurrentControls[Index].Element + 1).ToString(Culture)); if (Interface.CurrentControls[Index].Direction == (int)HatPosition.Left) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_left"); } else if (Interface.CurrentControls[Index].Direction == (int)HatPosition.UpLeft) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_upleft"); } else if (Interface.CurrentControls[Index].Direction == (int)HatPosition.Up) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_up"); } else if (Interface.CurrentControls[Index].Direction == (int)HatPosition.UpRight) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_upright"); } else if (Interface.CurrentControls[Index].Direction == (int)HatPosition.Right) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_right"); } else if (Interface.CurrentControls[Index].Direction == (int)HatPosition.DownRight) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_downright"); } else if (Interface.CurrentControls[Index].Direction == (int)HatPosition.Down) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_down"); } else if (Interface.CurrentControls[Index].Direction == (int)HatPosition.DownLeft) { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_downleft"); } else { t += Separator + Interface.GetInterfaceString("controls_assignment_joystick_hat_invalid"); } break; } return(t); } return(Interface.GetInterfaceString("controls_assignment_invalid")); }