////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////// private void comboInputSelection_SelectedIndexChanged(object sender, EventArgs e) { m_isWaitingForInput = false; m_currentWaitingButton = (int)Keys.None; for (int i = 0; i < (int)InputsMgr.e_buttons.__btn_max__; i++) { m_inputs[i] = (int)Keys.None; } RefreshUI(); }
////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////// private void InputManagerForm_KeyDown(object sender, KeyEventArgs e) { if (m_isWaitingForInput) { Keys k = e.KeyCode; m_inputs[(int)m_currentWaitingButton] = (int)k; m_isWaitingForInput = false; m_currentWaitingButton = (int)Keys.None; RefreshUI(); } }
////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////// private void GamePadCheckInput(object comboBoxItemObj) { ComboboxItem item = (ComboboxItem)comboBoxItemObj; UserIndex i = UserIndex.Any; switch (item.Value) { case InputsMgr.eInputName.e_inputName_gamepad_1: { i = UserIndex.One; break; } case InputsMgr.eInputName.e_inputName_gamepad_2: { i = UserIndex.Two; break; } case InputsMgr.eInputName.e_inputName_gamepad_3: { i = UserIndex.Three; break; } case InputsMgr.eInputName.e_inputName_gamepad_4: { i = UserIndex.Four; break; } } if (i != UserIndex.Any) { Xbox360Controller.Gamepad360 g = new Xbox360Controller.Gamepad360(i); int input = 0; do { input = getGamepadInput(g); Thread.Sleep(100); } while (input == 0); m_inputs[(int)m_currentWaitingButton] = input; m_isWaitingForInput = false; m_currentWaitingButton = (int)Keys.None; this.Invoke((MethodInvoker) delegate() { this.RefreshUI(); }); } }
////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////// private void RecordInput(InputsMgr.e_buttons button) { ComboboxItem item = (ComboboxItem)comboInputSelection.SelectedItem; if (item.Value == InputsMgr.eInputName.e_inputName_keyboard) { m_isWaitingForInput = true; m_currentWaitingButton = button; } else { m_isWaitingForInput = true; m_currentWaitingButton = button; Thread t = new Thread(new ParameterizedThreadStart(GamePadCheckInput)); t.Start(item); } }