public void UpdateFromXInput(State state, bool IsConnected) { // If nothing changed then return. if (state.Equals(oldState)) return; oldState = state; var wasConnected = gamePadStateIsConnected; var nowConnected = IsConnected; gamePadStateIsConnected = IsConnected; gamePadState = state; // If form was disabled and no data is comming then just return. if (!wasConnected && !nowConnected) return; // If device connection changed then... if (wasConnected != nowConnected) { if (nowConnected) { // Enable form. this.FrontPictureBox.Image = frontImage; this.TopPictureBox.Image = topImage; } else { // Disable form. this.FrontPictureBox.Image = frontDisabledImage; this.TopPictureBox.Image = topDisabledImage; } } if (nowConnected) { _leftX = state.Gamepad.LeftThumbX; _leftY = state.Gamepad.LeftThumbY; _rightX = state.Gamepad.RightThumbX; _rightY = state.Gamepad.RightThumbY; } else { _leftX = 0; _leftY = 0; _rightX = 0; _rightY = 0; } UpdateControl(LeftThumbTextBox, string.Format("{0};{1}", _leftX, _leftY)); UpdateControl(RightThumbTextBox, string.Format("{0};{1}", _rightX, _rightY)); var axis = diControl.Axis; bool success; int index; SettingType type; success = SettingsConverter.TryParseIndexAndType(LeftThumbAxisXComboBox.Text, out index, out type); if (success) LeftThumbXUserControl.DrawPoint(axis[index - 1], _leftX, type == SettingType.IAxis); success = SettingsConverter.TryParseIndexAndType(LeftThumbAxisYComboBox.Text, out index, out type); if (success) LeftThumbYUserControl.DrawPoint(axis[index - 1], _leftY, type == SettingType.IAxis); success = SettingsConverter.TryParseIndexAndType(RightThumbAxisXComboBox.Text, out index, out type); if (success) RightThumbXUserControl.DrawPoint(axis[index - 1], _rightX, type == SettingType.IAxis); success = SettingsConverter.TryParseIndexAndType(RightThumbAxisYComboBox.Text, out index, out type); if (success) RightThumbYUserControl.DrawPoint(axis[index - 1], _rightY, type == SettingType.IAxis); this.TopPictureBox.Refresh(); this.FrontPictureBox.Refresh(); }
public void UpdateFromXInput(State state, bool IsConnected) { // If nothing changed then return. if (state.Equals(oldState)) return; oldState = state; var wasConnected = gamePadStateIsConnected; var nowConnected = IsConnected; gamePadStateIsConnected = IsConnected; gamePadState = state; // If form was disabled and no data is comming then just return. if (!wasConnected && !nowConnected) return; // If device connection changed then... if (wasConnected != nowConnected) { if (nowConnected) { // Enable form. this.FrontPictureBox.Image = frontImage; this.TopPictureBox.Image = topImage; } else { // Disable form. this.FrontPictureBox.Image = frontDisabledImage; this.TopPictureBox.Image = topDisabledImage; } } if (nowConnected) { this.leftX = state.Gamepad.LeftThumbX; this.leftY = state.Gamepad.LeftThumbY; this.rightX = state.Gamepad.RightThumbX; this.rightY = state.Gamepad.RightThumbY; } else { this.leftX = 0; this.leftY = 0; this.rightX = 0; this.rightY = 0; } UpdateControl(LeftThumbTextBox, string.Format("{0};{1}", this.leftX, this.leftY)); UpdateControl(RightThumbTextBox, string.Format("{0};{1}", this.rightX, this.rightY)); this.TopPictureBox.Refresh(); this.FrontPictureBox.Refresh(); }