/// <summary> /// Resets the Action Tree /// </summary> private void InitActionTree( Boolean addDefaultBinding ) { log.Debug( "InitActionTree - Entry" ); // build TreeView and the ActionMaps m_AT = new ActionTree( m_AppSettings.BlendUnmapped, m_AppSettings.BlendUnmappedGP, m_Joystick, m_Gamepad ); m_AT.Ctrl = treeView1; // the ActionTree owns the TreeView control m_AT.IgnoreMaps = m_AppSettings.IgnoreActionmaps; // provide the display items (init) m_AT.DefineShowOptions( cbxShowJoystick.Checked, cbxShowGamepad.Checked, cbxShowKeyboard.Checked, cbxShowMappedOnly.Checked ); // Init with default profile filepath m_AT.LoadProfileTree( m_AppSettings.DefProfileName, addDefaultBinding ); // provide an array of checkboxes to Options (all is handled there) List<CheckBox> inversions = new List<CheckBox>( ); inversions.Add( cbxInvAimPitch ); inversions.Add( cbxInvViewPitch ); inversions.Add( cbxInvAimYaw ); inversions.Add( cbxInvViewYaw ); inversions.Add( cbxInvThrottle ); inversions.Add( cbxInvStrafeVert ); inversions.Add( cbxInvStrafeLat ); inversions.Add( cbxInvStrafeLon ); m_AT.InvertCheckList = inversions; // apply a default JS to Joystick mapping - can be changed and reloaded from XML mappings // must take care of Gamepads if there are (but we take care of one only...) int joyStickIndex = 0; // Joystick List Index for ( int deviceTabIndex=0; deviceTabIndex < JoystickCls.JSnum_MAX; deviceTabIndex++ ) { if ( tc1.TabPages.Count > deviceTabIndex ) { // valid Device Tab if ( IsGamepadTab( tc1.TabPages[deviceTabIndex] ) ) { ; // ignore gamepads } else if ( m_Joystick.Count > joyStickIndex ) { // there is a joystick device left.. m_Joystick[joyStickIndex].JSAssignment = joyStickIndex + 1; // assign number 1.. m_AT.ActionMaps.jsN[deviceTabIndex] = m_Joystick[joyStickIndex].DevName; m_AT.ActionMaps.jsNGUID[deviceTabIndex] = m_Joystick[joyStickIndex].DevInstanceGUID; joyStickIndex++; } } } }
/// <summary> /// Copy return the complete ActionTree while reassigning JsN /// </summary> /// <param name="newJsList">The JsN reassign list</param> /// <returns>The ActionTree Copy with reassigned input</returns> public ActionTree ReassignJsN( JsReassingList newJsList ) { ActionTree nTree = new ActionTree( BlendUnmappedJS, BlendUnmappedGP, m_jsList, m_gamepad ); // full copy from 'this' nTree.m_MasterTree = this.m_MasterTree; nTree.m_ctrl = this.m_ctrl; nTree.IgnoreMaps = this.IgnoreMaps; nTree.m_Filter = this.m_Filter; nTree.ActionMaps = this.ActionMaps.ReassignJsN( newJsList ); nTree.Dirty = true; return nTree; }
private void btJsReassign_Click( object sender, EventArgs e ) { // have to stop polling while the Reassign window is open timer1.Enabled = false; if ( m_Joystick.ShowReassign( ) != System.Windows.Forms.DialogResult.Cancel ) { // copy the action tree while reassigning the jsN mappings from OLD to NEW ActionTree newTree = m_AT.ReassignJsN( m_Joystick.JsReassingList ); // we have still the old assignment in the ActionMap - change it here (map does not know about the devices) JoystickCls j = null; // for all supported jsN devices for ( int i=0; i < JoystickCls.JSnum_MAX; i++ ) { j = m_Joystick.Find_jsN( i + 1 ); if ( j != null ) { newTree.ActionMaps.jsN[i] = j.DevName; newTree.ActionMaps.jsNGUID[i] = j.DevInstanceGUID; } else { newTree.ActionMaps.jsN[i] = ""; newTree.ActionMaps.jsNGUID[i] = ""; } } m_AT = newTree; // make it the valid one m_AT.DefineShowOptions( cbxShowJoystick.Checked, cbxShowGamepad.Checked, cbxShowKeyboard.Checked, cbxShowMappedOnly.Checked ); m_AT.ReloadTreeView( ); if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor; } timer1.Enabled = true; }