Re-design and update for AC1.0 mapping policies

Can only map to appropriate device type (mixed ones no longer supported)
Can extend an action which then uses addbind in XML (context menu)
Removed Invert per command (no longer supported)
Update options usage and syntax
Changed actionmap version to 1
Persist treeview filter checkboxes in app settings
pull/104/head
bm98 10 years ago
parent 4c617f85ab
commit 47fb23f1cf

@ -91,7 +91,7 @@ namespace SCJMapper_V2
} }
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "False" )] // false [DefaultSettingValueAttribute( "False" )]
public Boolean BlendUnmapped // Joystick (back compatibility) public Boolean BlendUnmapped // Joystick (back compatibility)
{ {
get { return ( Boolean )this["BlendUnmapped"]; } get { return ( Boolean )this["BlendUnmapped"]; }
@ -99,18 +99,50 @@ namespace SCJMapper_V2
} }
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "False" )] // false [DefaultSettingValueAttribute( "False" )]
public Boolean BlendUnmappedGP public Boolean BlendUnmappedGP
{ {
get { return ( Boolean )this["BlendUnmappedGP"]; } get { return ( Boolean )this["BlendUnmappedGP"]; }
set { this["BlendUnmappedGP"] = value; } set { this["BlendUnmappedGP"] = value; }
} }
[UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "True" )]
public Boolean ShowJoystick
{
get { return ( Boolean )this["ShowJoystick"]; }
set { this["ShowJoystick"] = value; }
}
[UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "True" )]
public Boolean ShowGamepad
{
get { return ( Boolean )this["ShowGamepad"]; }
set { this["ShowGamepad"] = value; }
}
[UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "True" )]
public Boolean ShowKeyboard
{
get { return ( Boolean )this["ShowKeyboard"]; }
set { this["ShowKeyboard"] = value; }
}
[UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "False" )]
public Boolean ShowMapped
{
get { return ( Boolean )this["ShowMapped"]; }
set { this["ShowMapped"] = value; }
}
// Seetings Window // Seetings Window
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "" )] // empty [DefaultSettingValueAttribute( "" )]
public String IgnoreJS1 public String IgnoreJS1
{ {
get { return ( String )this["IgnoreJS1"]; } get { return ( String )this["IgnoreJS1"]; }
@ -118,7 +150,7 @@ namespace SCJMapper_V2
} }
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "" )] // empty [DefaultSettingValueAttribute( "" )]
public String IgnoreJS2 public String IgnoreJS2
{ {
get { return ( String )this["IgnoreJS2"]; } get { return ( String )this["IgnoreJS2"]; }
@ -126,7 +158,7 @@ namespace SCJMapper_V2
} }
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "" )] // empty [DefaultSettingValueAttribute( "" )]
public String IgnoreJS3 public String IgnoreJS3
{ {
get { return ( String )this["IgnoreJS3"]; } get { return ( String )this["IgnoreJS3"]; }
@ -134,7 +166,7 @@ namespace SCJMapper_V2
} }
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "" )] // empty [DefaultSettingValueAttribute( "" )]
public String IgnoreJS4 public String IgnoreJS4
{ {
get { return ( String )this["IgnoreJS4"]; } get { return ( String )this["IgnoreJS4"]; }
@ -142,7 +174,7 @@ namespace SCJMapper_V2
} }
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "" )] // empty [DefaultSettingValueAttribute( "" )]
public String IgnoreJS5 public String IgnoreJS5
{ {
get { return ( String )this["IgnoreJS5"]; } get { return ( String )this["IgnoreJS5"]; }
@ -150,7 +182,7 @@ namespace SCJMapper_V2
} }
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "" )] // empty [DefaultSettingValueAttribute( "" )]
public String IgnoreJS6 public String IgnoreJS6
{ {
get { return ( String )this["IgnoreJS6"]; } get { return ( String )this["IgnoreJS6"]; }
@ -158,7 +190,7 @@ namespace SCJMapper_V2
} }
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "" )] // empty [DefaultSettingValueAttribute( "" )]
public String IgnoreJS7 public String IgnoreJS7
{ {
get { return ( String )this["IgnoreJS7"]; } get { return ( String )this["IgnoreJS7"]; }
@ -166,7 +198,7 @@ namespace SCJMapper_V2
} }
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "" )] // empty [DefaultSettingValueAttribute( "" )]
public String IgnoreJS8 public String IgnoreJS8
{ {
get { return ( String )this["IgnoreJS8"]; } get { return ( String )this["IgnoreJS8"]; }
@ -174,7 +206,7 @@ namespace SCJMapper_V2
} }
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "" )] // empty [DefaultSettingValueAttribute( "" )]
public String UserSCPath public String UserSCPath
{ {
get { return ( String )this["UserSCPath"]; } get { return ( String )this["UserSCPath"]; }
@ -182,7 +214,7 @@ namespace SCJMapper_V2
} }
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "False" )] // false [DefaultSettingValueAttribute( "False" )]
public Boolean UserSCPathUsed public Boolean UserSCPathUsed
{ {
get { return ( Boolean )this["UserSCPathUsed"]; } get { return ( Boolean )this["UserSCPathUsed"]; }
@ -199,7 +231,7 @@ namespace SCJMapper_V2
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "False" )] // false [DefaultSettingValueAttribute( "False" )]
public Boolean ForceIgnoreversion public Boolean ForceIgnoreversion
{ {
get { return ( Boolean )this["ForceIgnoreversion"]; } get { return ( Boolean )this["ForceIgnoreversion"]; }
@ -208,7 +240,7 @@ namespace SCJMapper_V2
[UserScopedSettingAttribute( )] [UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "False" )] // false [DefaultSettingValueAttribute( "False" )]
public Boolean DetectGamepad public Boolean DetectGamepad
{ {
get { return ( Boolean )this["DetectGamepad"]; } get { return ( Boolean )this["DetectGamepad"]; }

@ -15,21 +15,13 @@ namespace SCJMapper_V2
public const String BlendedInput = " "; public const String BlendedInput = " ";
static public Boolean IsDeviceClass( String deviceClass ) { return false; } static public Boolean IsDeviceClass( String deviceClass ) { return false; }
public enum InputKind
{
Other,
Kbd,
Joystick,
Gamepad,
}
public abstract String DevClass { get; } public abstract String DevClass { get; }
public abstract String DevName { get; } public abstract String DevName { get; }
public abstract System.Drawing.Color MapColor { get; } public abstract System.Drawing.Color MapColor { get; }
public abstract Boolean Activated { get; set; } public abstract Boolean Activated { get; set; }
public virtual void FinishDX( ) {} public virtual void FinishDX( ) { }
public virtual void ApplySettings( ){} public virtual void ApplySettings( ) { }
public abstract String GetLastChange( ); public abstract String GetLastChange( );
public abstract void GetCmdData( String cmd, out int data ); public abstract void GetCmdData( String cmd, out int data );

114
Form1.Designer.cs generated

@ -47,7 +47,6 @@
this.btGrab = new System.Windows.Forms.Button(); this.btGrab = new System.Windows.Forms.Button();
this.btDump = new System.Windows.Forms.Button(); this.btDump = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel();
this.cbxInvert = new System.Windows.Forms.CheckBox();
this.btJsKbd = new System.Windows.Forms.Button(); this.btJsKbd = new System.Windows.Forms.Button();
this.IL = new System.Windows.Forms.ImageList(this.components); this.IL = new System.Windows.Forms.ImageList(this.components);
this.btBlend = new System.Windows.Forms.Button(); this.btBlend = new System.Windows.Forms.Button();
@ -76,8 +75,6 @@
this.tlpanel = new System.Windows.Forms.TableLayoutPanel(); this.tlpanel = new System.Windows.Forms.TableLayoutPanel();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.txFilter = new System.Windows.Forms.TextBox();
this.btClearFilter = new System.Windows.Forms.Button();
this.btJSTuning = new System.Windows.Forms.Button(); this.btJSTuning = new System.Windows.Forms.Button();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.btSettings = new System.Windows.Forms.Button(); this.btSettings = new System.Windows.Forms.Button();
@ -92,6 +89,9 @@
this.cbxShowGamepad = new System.Windows.Forms.CheckBox(); this.cbxShowGamepad = new System.Windows.Forms.CheckBox();
this.cbxShowKeyboard = new System.Windows.Forms.CheckBox(); this.cbxShowKeyboard = new System.Windows.Forms.CheckBox();
this.cbxShowMappedOnly = new System.Windows.Forms.CheckBox(); this.cbxShowMappedOnly = new System.Windows.Forms.CheckBox();
this.label2 = new System.Windows.Forms.Label();
this.txFilter = new System.Windows.Forms.TextBox();
this.btClearFilter = new System.Windows.Forms.Button();
this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
this.tsDDbtProfiles = new System.Windows.Forms.ToolStripDropDownButton(); this.tsDDbtProfiles = new System.Windows.Forms.ToolStripDropDownButton();
this.tsBtReset = new System.Windows.Forms.ToolStripDropDownButton(); this.tsBtReset = new System.Windows.Forms.ToolStripDropDownButton();
@ -107,8 +107,10 @@
this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.cmAddDel = new System.Windows.Forms.ContextMenuStrip(this.components);
this.tsiAddBinding = new System.Windows.Forms.ToolStripMenuItem();
this.tdiDelBinding = new System.Windows.Forms.ToolStripMenuItem();
this.UC_JoyPanel = new SCJMapper_V2.UC_JoyPanel(); this.UC_JoyPanel = new SCJMapper_V2.UC_JoyPanel();
this.label2 = new System.Windows.Forms.Label();
this.cmCopyPaste.SuspendLayout(); this.cmCopyPaste.SuspendLayout();
this.panel2.SuspendLayout(); this.panel2.SuspendLayout();
this.tc1.SuspendLayout(); this.tc1.SuspendLayout();
@ -121,6 +123,7 @@
this.tableLayoutPanel3.SuspendLayout(); this.tableLayoutPanel3.SuspendLayout();
this.flowLayoutPanel2.SuspendLayout(); this.flowLayoutPanel2.SuspendLayout();
this.statusStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout();
this.cmAddDel.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// btDumpList // btDumpList
@ -232,7 +235,6 @@
// panel2 // panel2
// //
this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel2.Controls.Add(this.cbxInvert);
this.panel2.Controls.Add(this.btJsKbd); this.panel2.Controls.Add(this.btJsKbd);
this.panel2.Controls.Add(this.btBlend); this.panel2.Controls.Add(this.btBlend);
this.panel2.Controls.Add(this.lblLastJ); this.panel2.Controls.Add(this.lblLastJ);
@ -248,16 +250,6 @@
this.panel2.Size = new System.Drawing.Size(289, 142); this.panel2.Size = new System.Drawing.Size(289, 142);
this.panel2.TabIndex = 17; this.panel2.TabIndex = 17;
// //
// cbxInvert
//
this.cbxInvert.AutoSize = true;
this.cbxInvert.Location = new System.Drawing.Point(89, 86);
this.cbxInvert.Name = "cbxInvert";
this.cbxInvert.Size = new System.Drawing.Size(55, 17);
this.cbxInvert.TabIndex = 17;
this.cbxInvert.Text = "Invert";
this.cbxInvert.UseVisualStyleBackColor = true;
//
// btJsKbd // btJsKbd
// //
this.btJsKbd.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btJsKbd.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
@ -283,6 +275,7 @@
this.IL.Images.SetKeyName(4, "X"); this.IL.Images.SetKeyName(4, "X");
this.IL.Images.SetKeyName(5, "P"); this.IL.Images.SetKeyName(5, "P");
this.IL.Images.SetKeyName(6, "Z"); this.IL.Images.SetKeyName(6, "Z");
this.IL.Images.SetKeyName(7, "Add");
// //
// btBlend // btBlend
// //
@ -308,7 +301,7 @@
// cbxThrottle // cbxThrottle
// //
this.cbxThrottle.AutoSize = true; this.cbxThrottle.AutoSize = true;
this.cbxThrottle.Location = new System.Drawing.Point(89, 67); this.cbxThrottle.Location = new System.Drawing.Point(89, 72);
this.cbxThrottle.Name = "cbxThrottle"; this.cbxThrottle.Name = "cbxThrottle";
this.cbxThrottle.Size = new System.Drawing.Size(66, 17); this.cbxThrottle.Size = new System.Drawing.Size(66, 17);
this.cbxThrottle.TabIndex = 13; this.cbxThrottle.TabIndex = 13;
@ -375,6 +368,7 @@
// //
// treeView1 // treeView1
// //
this.treeView1.ContextMenuStrip = this.cmAddDel;
this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill; this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeView1.HotTracking = true; this.treeView1.HotTracking = true;
this.treeView1.ImageKey = "Map"; this.treeView1.ImageKey = "Map";
@ -572,26 +566,6 @@
this.tableLayoutPanel1.Size = new System.Drawing.Size(294, 131); this.tableLayoutPanel1.Size = new System.Drawing.Size(294, 131);
this.tableLayoutPanel1.TabIndex = 23; this.tableLayoutPanel1.TabIndex = 23;
// //
// txFilter
//
this.txFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.txFilter.Location = new System.Drawing.Point(92, 28);
this.txFilter.Name = "txFilter";
this.txFilter.Size = new System.Drawing.Size(120, 22);
this.txFilter.TabIndex = 25;
this.txFilter.WordWrap = false;
this.txFilter.TextChanged += new System.EventHandler(this.txFilter_TextChanged);
//
// btClearFilter
//
this.btClearFilter.Location = new System.Drawing.Point(218, 26);
this.btClearFilter.Name = "btClearFilter";
this.btClearFilter.Size = new System.Drawing.Size(120, 24);
this.btClearFilter.TabIndex = 26;
this.btClearFilter.Text = "Clear Filter";
this.btClearFilter.UseVisualStyleBackColor = true;
this.btClearFilter.Click += new System.EventHandler(this.btClearFilter_Click);
//
// btJSTuning // btJSTuning
// //
this.btJSTuning.Location = new System.Drawing.Point(3, 93); this.btJSTuning.Location = new System.Drawing.Point(3, 93);
@ -767,6 +741,36 @@
this.cbxShowMappedOnly.UseVisualStyleBackColor = true; this.cbxShowMappedOnly.UseVisualStyleBackColor = true;
this.cbxShowMappedOnly.CheckedChanged += new System.EventHandler(this.cbxShowTreeOptions_CheckedChanged); this.cbxShowMappedOnly.CheckedChanged += new System.EventHandler(this.cbxShowTreeOptions_CheckedChanged);
// //
// label2
//
this.label2.Location = new System.Drawing.Point(3, 26);
this.label2.Margin = new System.Windows.Forms.Padding(3);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(83, 24);
this.label2.TabIndex = 27;
this.label2.Text = "Action Filter:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// txFilter
//
this.txFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.txFilter.Location = new System.Drawing.Point(92, 28);
this.txFilter.Name = "txFilter";
this.txFilter.Size = new System.Drawing.Size(120, 22);
this.txFilter.TabIndex = 25;
this.txFilter.WordWrap = false;
this.txFilter.TextChanged += new System.EventHandler(this.txFilter_TextChanged);
//
// btClearFilter
//
this.btClearFilter.Location = new System.Drawing.Point(218, 26);
this.btClearFilter.Name = "btClearFilter";
this.btClearFilter.Size = new System.Drawing.Size(120, 24);
this.btClearFilter.TabIndex = 26;
this.btClearFilter.Text = "Clear Filter";
this.btClearFilter.UseVisualStyleBackColor = true;
this.btClearFilter.Click += new System.EventHandler(this.btClearFilter_Click);
//
// toolStripStatusLabel2 // toolStripStatusLabel2
// //
this.toolStripStatusLabel2.BackColor = System.Drawing.Color.DarkKhaki; this.toolStripStatusLabel2.BackColor = System.Drawing.Color.DarkKhaki;
@ -912,6 +916,29 @@
this.statusStrip1.TabIndex = 26; this.statusStrip1.TabIndex = 26;
this.statusStrip1.Text = "statusStrip1"; this.statusStrip1.Text = "statusStrip1";
// //
// cmAddDel
//
this.cmAddDel.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsiAddBinding,
this.tdiDelBinding});
this.cmAddDel.Name = "cmAddDel";
this.cmAddDel.Size = new System.Drawing.Size(159, 48);
this.cmAddDel.Opening += new System.ComponentModel.CancelEventHandler(this.cmAddDel_Opening);
//
// tsiAddBinding
//
this.tsiAddBinding.Name = "tsiAddBinding";
this.tsiAddBinding.Size = new System.Drawing.Size(158, 22);
this.tsiAddBinding.Text = "Add Mapping";
this.tsiAddBinding.Click += new System.EventHandler(this.tsiAddBinding_Click);
//
// tdiDelBinding
//
this.tdiDelBinding.Name = "tdiDelBinding";
this.tdiDelBinding.Size = new System.Drawing.Size(158, 22);
this.tdiDelBinding.Text = "Delete Mapping";
this.tdiDelBinding.Click += new System.EventHandler(this.tdiDelBinding_Click);
//
// UC_JoyPanel // UC_JoyPanel
// //
this.UC_JoyPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.UC_JoyPanel.Dock = System.Windows.Forms.DockStyle.Fill;
@ -921,16 +948,6 @@
this.UC_JoyPanel.Size = new System.Drawing.Size(275, 315); this.UC_JoyPanel.Size = new System.Drawing.Size(275, 315);
this.UC_JoyPanel.TabIndex = 0; this.UC_JoyPanel.TabIndex = 0;
// //
// label2
//
this.label2.Location = new System.Drawing.Point(3, 26);
this.label2.Margin = new System.Windows.Forms.Padding(3);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(83, 24);
this.label2.TabIndex = 27;
this.label2.Text = "Action Filter:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -964,6 +981,7 @@
this.flowLayoutPanel2.PerformLayout(); this.flowLayoutPanel2.PerformLayout();
this.statusStrip1.ResumeLayout(false); this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout(); this.statusStrip1.PerformLayout();
this.cmAddDel.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -1039,13 +1057,15 @@
private System.Windows.Forms.Button btJsKbd; private System.Windows.Forms.Button btJsKbd;
private System.Windows.Forms.Button btBlend; private System.Windows.Forms.Button btBlend;
private System.Windows.Forms.Button btClip; private System.Windows.Forms.Button btClip;
private System.Windows.Forms.CheckBox cbxInvert;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
private System.Windows.Forms.CheckBox cbxShowJoystick; private System.Windows.Forms.CheckBox cbxShowJoystick;
private System.Windows.Forms.CheckBox cbxShowGamepad; private System.Windows.Forms.CheckBox cbxShowGamepad;
private System.Windows.Forms.CheckBox cbxShowKeyboard; private System.Windows.Forms.CheckBox cbxShowKeyboard;
private System.Windows.Forms.CheckBox cbxShowMappedOnly; private System.Windows.Forms.CheckBox cbxShowMappedOnly;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.ContextMenuStrip cmAddDel;
private System.Windows.Forms.ToolStripMenuItem tsiAddBinding;
private System.Windows.Forms.ToolStripMenuItem tdiDelBinding;
} }
} }

@ -20,6 +20,8 @@ namespace SCJMapper_V2
private const String c_GithubLink = @"https://github.com/SCToolsfactory/SCJMapper-V2/releases"; private const String c_GithubLink = @"https://github.com/SCToolsfactory/SCJMapper-V2/releases";
private AppSettings m_AppSettings = new AppSettings( ); private AppSettings m_AppSettings = new AppSettings( );
private Boolean m_appLoading = true; // used to detect if we are loading (or running)
///<remarks> ///<remarks>
/// Holds the DXInput Joystick List /// Holds the DXInput Joystick List
@ -77,19 +79,19 @@ namespace SCJMapper_V2
/// <summary> /// <summary>
/// Detects and returns the current Input device /// Detects and returns the current Input device
/// </summary> /// </summary>
private DeviceCls.InputKind InputMode private ActionCls.ActionDevice InputMode
{ {
get get
{ {
if ( m_keyIn ) { if ( m_keyIn ) {
return DeviceCls.InputKind.Kbd; return ActionCls.ActionDevice.AD_Keyboard;
} }
else { else {
if ( IsGamepadTab( tc1.SelectedTab ) ) { if ( IsGamepadTab( tc1.SelectedTab ) ) {
return DeviceCls.InputKind.Gamepad; return ActionCls.ActionDevice.AD_Gamepad;
} }
else { else {
return DeviceCls.InputKind.Joystick; return ActionCls.ActionDevice.AD_Joystick;
} }
} }
} }
@ -240,9 +242,17 @@ namespace SCJMapper_V2
txMappingName.BackColor = MyColors.ErrorColor; txMappingName.BackColor = MyColors.ErrorColor;
} }
// load show checkboxes
cbxShowJoystick.Checked = m_AppSettings.ShowJoystick;
cbxShowGamepad.Checked = m_AppSettings.ShowGamepad;
cbxShowKeyboard.Checked = m_AppSettings.ShowKeyboard;
cbxShowMappedOnly.Checked = m_AppSettings.ShowMapped;
// poll the XInput // poll the XInput
log.Debug( "Start XInput polling" ); log.Debug( "Start XInput polling" );
timer1.Start( ); // this one polls the joysticks to show the props timer1.Start( ); // this one polls the joysticks to show the props
m_appLoading = false; // no longer
} }
@ -336,7 +346,7 @@ namespace SCJMapper_V2
m_AT.Ctrl = treeView1; // the ActionTree owns the TreeView control m_AT.Ctrl = treeView1; // the ActionTree owns the TreeView control
m_AT.IgnoreMaps = m_AppSettings.IgnoreActionmaps; m_AT.IgnoreMaps = m_AppSettings.IgnoreActionmaps;
m_AT.DefineShowOptions( cbxShowJoystick.Checked, cbxShowGamepad.Checked, cbxShowKeyboard.Checked, cbxShowMappedOnly.Checked ); m_AT.DefineShowOptions( cbxShowJoystick.Checked, cbxShowGamepad.Checked, cbxShowKeyboard.Checked, cbxShowMappedOnly.Checked );
m_AT.LoadTree( m_AppSettings.DefProfileName, addDefaultBinding ); // Init with default profile filepath m_AT.LoadProfileTree( m_AppSettings.DefProfileName, addDefaultBinding ); // Init with default profile filepath
// apply a default JS to Joystick mapping - can be changed and reloaded from XML mappings // 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...) // must take care of Gamepads if there are (but we take care of one only...)
@ -575,6 +585,7 @@ namespace SCJMapper_V2
private void timer1_Tick( object sender, System.EventArgs e ) private void timer1_Tick( object sender, System.EventArgs e )
{ {
if ( m_keyIn ) return; // allow keyboard / mouse input if ( m_keyIn ) return; // allow keyboard / mouse input
if ( tc1.SelectedTab.Tag == null ) return;
String ctrl = ""; String ctrl = "";
int jsIndex = ( int )tc1.SelectedTab.Tag; // gets the index into the JS list int jsIndex = ( int )tc1.SelectedTab.Tag; // gets the index into the JS list
@ -592,14 +603,9 @@ namespace SCJMapper_V2
lblLastJ.Text = ctrl; lblLastJ.Text = ctrl;
if ( JoystickCls.CanThrottle( ctrl ) ) { if ( JoystickCls.CanThrottle( ctrl ) ) {
cbxThrottle.Enabled = true; cbxThrottle.Enabled = true;
cbxInvert.Enabled = true;
}
else if ( GamepadCls.CanInvert( ctrl ) ) {
cbxInvert.Enabled = true;
} }
else { else {
cbxThrottle.Checked = false; cbxThrottle.Enabled = false; cbxThrottle.Checked = false; cbxThrottle.Enabled = false;
cbxInvert.Checked = false; cbxInvert.Enabled = false;
} }
} }
@ -608,15 +614,8 @@ namespace SCJMapper_V2
private void treeView1_AfterSelect( object sender, TreeViewEventArgs e ) private void treeView1_AfterSelect( object sender, TreeViewEventArgs e )
{ {
if ( e.Node.Level == 1 ) { String atx = m_AT.SelectedAction;
// actions cannot have a blank - if there is one it's mapped if ( !String.IsNullOrEmpty( atx ) ) lblAction.Text = atx;
if ( e.Node.Text.IndexOf( " ", 0 ) > 0 ) {
lblAction.Text = e.Node.Text.Substring( 0, e.Node.Text.IndexOf( " ", 0 ) ); // get only the action part as Cmd.
}
else {
lblAction.Text = e.Node.Text;
}
}
} }
@ -624,8 +623,13 @@ namespace SCJMapper_V2
private void cbxShowTreeOptions_CheckedChanged( object sender, EventArgs e ) private void cbxShowTreeOptions_CheckedChanged( object sender, EventArgs e )
{ {
if (m_AT==null) return; // on init
m_AT.DefineShowOptions( cbxShowJoystick.Checked, cbxShowGamepad.Checked, cbxShowKeyboard.Checked, cbxShowMappedOnly.Checked ); m_AT.DefineShowOptions( cbxShowJoystick.Checked, cbxShowGamepad.Checked, cbxShowKeyboard.Checked, cbxShowMappedOnly.Checked );
m_AT.ReloadTreeView( ); m_AT.ReloadTreeView( );
if ( m_appLoading ) return; // don't assign while loading defaults
m_AppSettings.ShowJoystick = cbxShowJoystick.Checked; m_AppSettings.ShowGamepad = cbxShowGamepad.Checked;
m_AppSettings.ShowKeyboard = cbxShowKeyboard.Checked; m_AppSettings.ShowMapped = cbxShowMappedOnly.Checked;
} }
@ -639,20 +643,33 @@ namespace SCJMapper_V2
private void btAssign_Click( object sender, EventArgs e ) private void btAssign_Click( object sender, EventArgs e )
{ {
m_AT.UpdateSelectedItem( JoystickCls.MakeThrottle( lblLastJ.Text, cbxThrottle.Checked ), cbxInvert.Checked, InputMode ); if ( m_AT.UpdateSelectedItem( JoystickCls.MakeThrottle( lblLastJ.Text, cbxThrottle.Checked ), InputMode ) ) {
if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor; if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor;
}
else MySounds.PlayNotfound( );
} }
private void btBlend_Click( object sender, EventArgs e )
// General Area Items {
if ( m_AT.CanBlendBinding ) {
m_AT.UpdateSelectedItem( DeviceCls.BlendedInput, InputMode );
if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor;
}
else MySounds.PlayCannot( );
}
private void btClear_Click( object sender, EventArgs e ) private void btClear_Click( object sender, EventArgs e )
{ {
if ( m_AT.CanClearBinding ) {
m_AT.UpdateSelectedItem( "", false, InputMode ); m_AT.UpdateSelectedItem( "", InputMode );
if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor; if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor;
}
else MySounds.PlayCannot( );
} }
// General Area Items
private void btDump_Click( object sender, EventArgs e ) private void btDump_Click( object sender, EventArgs e )
{ {
Dump( ); Dump( );
@ -766,6 +783,7 @@ namespace SCJMapper_V2
// Context Menu Items // Context Menu Items
// RTB Menu
private void tsiCopy_Click( object sender, EventArgs e ) private void tsiCopy_Click( object sender, EventArgs e )
{ {
rtb.Focus( ); rtb.Focus( );
@ -808,6 +826,28 @@ namespace SCJMapper_V2
} }
} }
// Node Menu
private void cmAddDel_Opening( object sender, CancelEventArgs e )
{
ContextMenuStrip cts = ( sender as ContextMenuStrip );
Boolean any=false;
cts.Items[0].Visible = m_AT.CanAddBinding; any = any || m_AT.CanAddBinding;
cts.Items[1].Visible = m_AT.CanDelBinding; any = any || m_AT.CanDelBinding;
e.Cancel = !any;
}
private void tsiAddBinding_Click( object sender, EventArgs e )
{
m_AT.AddBinding( );
if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor;
}
private void tdiDelBinding_Click( object sender, EventArgs e )
{
m_AT.DelBinding( );
if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor;
}
// rtb drop xml file // rtb drop xml file
@ -961,14 +1001,6 @@ namespace SCJMapper_V2
} }
// Blend
private void btBlend_Click( object sender, EventArgs e )
{
m_AT.UpdateSelectedItem( DeviceCls.BlendedInput, false, InputMode );
if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor;
}
// Joystick Tuning // Joystick Tuning
private void btJSTuning_Click( object sender, EventArgs e ) private void btJSTuning_Click( object sender, EventArgs e )
@ -983,22 +1015,15 @@ namespace SCJMapper_V2
DeviceCls dev = null; DeviceCls dev = null;
String find = ""; String find = "";
find = ActionTreeNode.ComposeNodeText( "v_yaw", ActionTreeNode.REG_MOD, "js" ); // find action item for yaw
find = ActionTreeNode.ComposeNodeText( "v_yaw", "js" );
nodeText = m_AT.FindText( "spaceship_movement", find ); // returns "" or a complete text ("action - command") nodeText = m_AT.FindText( "spaceship_movement", find ); // returns "" or a complete text ("action - command")
if ( String.IsNullOrWhiteSpace( nodeText ) ) {
find = ActionTreeNode.ComposeNodeText( "v_yaw", ActionTreeNode.INV_MOD, "js" );
nodeText = m_AT.FindText( "spaceship_movement", find ); // find inverted ones too
}
if ( !String.IsNullOrWhiteSpace( nodeText ) ) { if ( !String.IsNullOrWhiteSpace( nodeText ) ) {
dev = m_Joystick.Find_jsN( JoystickCls.JSNum( ActionTreeNode.CommandFromNodeText( nodeText ) ) ); dev = m_Joystick.Find_jsN( JoystickCls.JSNum( ActionTreeNode.CommandFromNodeText( nodeText ) ) );
} }
else { else {
find = ActionTreeNode.ComposeNodeText( "v_yaw", ActionTreeNode.REG_MOD, "xi" ); find = ActionTreeNode.ComposeNodeText( "v_yaw", "xi" );
nodeText = m_AT.FindText( "spaceship_movement", find ); nodeText = m_AT.FindText( "spaceship_movement", find );
if ( String.IsNullOrWhiteSpace( nodeText ) ) {
find = ActionTreeNode.ComposeNodeText( "v_yaw", ActionTreeNode.INV_MOD, "xi" );
nodeText = m_AT.FindText( "spaceship_movement", find ); // find inverted ones too
}
if ( !String.IsNullOrWhiteSpace( nodeText ) ) { if ( !String.IsNullOrWhiteSpace( nodeText ) ) {
dev = m_Gamepad; dev = m_Gamepad;
} }
@ -1008,21 +1033,21 @@ namespace SCJMapper_V2
// JS commands that are supported // JS commands that are supported
if ( nodeText.ToLowerInvariant( ).EndsWith( "_x" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotx" ) ) { if ( nodeText.ToLowerInvariant( ).EndsWith( "_x" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotx" ) ) {
m_AT.ActionMaps.TuningY.GameDevice = dev; m_AT.ActionMaps.TuningY.GameDevice = dev;
m_AT.ActionMaps.TuningY.ActionCommand = nodeText; m_AT.ActionMaps.TuningY.Action = nodeText;
m_AT.ActionMaps.DeadzoneX.GameDevice = dev; m_AT.ActionMaps.DeadzoneX.GameDevice = dev;
m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneX; m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneX;
JSCAL.YawTuning = m_AT.ActionMaps.TuningY; JSCAL.YawTuning = m_AT.ActionMaps.TuningY;
} }
else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) { else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) {
m_AT.ActionMaps.TuningY.GameDevice = dev; m_AT.ActionMaps.TuningY.GameDevice = dev;
m_AT.ActionMaps.TuningY.ActionCommand = nodeText; m_AT.ActionMaps.TuningY.Action = nodeText;
m_AT.ActionMaps.DeadzoneY.GameDevice = dev; m_AT.ActionMaps.DeadzoneY.GameDevice = dev;
m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneY; m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneY;
JSCAL.YawTuning = m_AT.ActionMaps.TuningY; JSCAL.YawTuning = m_AT.ActionMaps.TuningY;
} }
else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) { else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) {
m_AT.ActionMaps.TuningY.GameDevice = dev; m_AT.ActionMaps.TuningY.GameDevice = dev;
m_AT.ActionMaps.TuningY.ActionCommand = nodeText; m_AT.ActionMaps.TuningY.Action = nodeText;
m_AT.ActionMaps.DeadzoneZ.GameDevice = dev; m_AT.ActionMaps.DeadzoneZ.GameDevice = dev;
m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneZ; m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneZ;
JSCAL.YawTuning = m_AT.ActionMaps.TuningY; JSCAL.YawTuning = m_AT.ActionMaps.TuningY;
@ -1030,7 +1055,7 @@ namespace SCJMapper_V2
// GP commands that are supported - X // GP commands that are supported - X
else if ( nodeText.ToLowerInvariant( ).Contains( "_thumblx" ) || nodeText.ToLowerInvariant( ).Contains( "_thumbrx" ) ) { else if ( nodeText.ToLowerInvariant( ).Contains( "_thumblx" ) || nodeText.ToLowerInvariant( ).Contains( "_thumbrx" ) ) {
m_AT.ActionMaps.TuningY.GameDevice = dev; m_AT.ActionMaps.TuningY.GameDevice = dev;
m_AT.ActionMaps.TuningY.ActionCommand = nodeText; m_AT.ActionMaps.TuningY.Action = nodeText;
m_AT.ActionMaps.DeadzoneX.GameDevice = dev; m_AT.ActionMaps.DeadzoneX.GameDevice = dev;
m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneX; m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneX;
JSCAL.YawTuning = m_AT.ActionMaps.TuningY; JSCAL.YawTuning = m_AT.ActionMaps.TuningY;
@ -1039,22 +1064,14 @@ namespace SCJMapper_V2
// attach Pitch command // attach Pitch command
dev = null; dev = null;
find = ActionTreeNode.ComposeNodeText( "v_pitch", ActionTreeNode.REG_MOD, "js" ); find = ActionTreeNode.ComposeNodeText( "v_pitch", "js" );
nodeText = m_AT.FindText( "spaceship_movement", find ); // returns "" or a complete text ("action - command") nodeText = m_AT.FindText( "spaceship_movement", find ); // returns "" or a complete text ("action - command")
if ( String.IsNullOrWhiteSpace( nodeText ) ) {
find = ActionTreeNode.ComposeNodeText( "v_pitch", ActionTreeNode.INV_MOD, "js" );
nodeText = m_AT.FindText( "spaceship_movement", find ); // find inverted ones too
}
if ( !String.IsNullOrWhiteSpace( nodeText ) ) { if ( !String.IsNullOrWhiteSpace( nodeText ) ) {
dev = m_Joystick.Find_jsN( JoystickCls.JSNum( ActionTreeNode.CommandFromNodeText( nodeText ) ) ); dev = m_Joystick.Find_jsN( JoystickCls.JSNum( ActionTreeNode.CommandFromNodeText( nodeText ) ) );
} }
else { else {
find = ActionTreeNode.ComposeNodeText( "v_pitch", ActionTreeNode.REG_MOD, "xi" ); find = ActionTreeNode.ComposeNodeText( "v_pitch", "xi" );
nodeText = m_AT.FindText( "spaceship_movement", find ); nodeText = m_AT.FindText( "spaceship_movement", find );
if ( String.IsNullOrWhiteSpace( nodeText ) ) {
find = ActionTreeNode.ComposeNodeText( "v_pitch", ActionTreeNode.INV_MOD, "xi" );
nodeText = m_AT.FindText( "spaceship_movement", find ); // find inverted ones too
}
if ( !String.IsNullOrWhiteSpace( nodeText ) ) { if ( !String.IsNullOrWhiteSpace( nodeText ) ) {
dev = m_Gamepad; dev = m_Gamepad;
} }
@ -1064,21 +1081,21 @@ namespace SCJMapper_V2
// JS commands that are supported // JS commands that are supported
if ( nodeText.ToLowerInvariant( ).EndsWith( "_x" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotx" ) ) { if ( nodeText.ToLowerInvariant( ).EndsWith( "_x" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotx" ) ) {
m_AT.ActionMaps.TuningP.GameDevice = dev; m_AT.ActionMaps.TuningP.GameDevice = dev;
m_AT.ActionMaps.TuningP.ActionCommand = nodeText; m_AT.ActionMaps.TuningP.Action = nodeText;
m_AT.ActionMaps.DeadzoneX.GameDevice = dev; m_AT.ActionMaps.DeadzoneX.GameDevice = dev;
m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneX; m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneX;
JSCAL.PitchTuning = m_AT.ActionMaps.TuningP; JSCAL.PitchTuning = m_AT.ActionMaps.TuningP;
} }
else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) { else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) {
m_AT.ActionMaps.TuningP.GameDevice = dev; m_AT.ActionMaps.TuningP.GameDevice = dev;
m_AT.ActionMaps.TuningP.ActionCommand = nodeText; m_AT.ActionMaps.TuningP.Action = nodeText;
m_AT.ActionMaps.DeadzoneY.GameDevice = dev; m_AT.ActionMaps.DeadzoneY.GameDevice = dev;
m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneY; m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneY;
JSCAL.PitchTuning = m_AT.ActionMaps.TuningP; JSCAL.PitchTuning = m_AT.ActionMaps.TuningP;
} }
else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) { else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) {
m_AT.ActionMaps.TuningP.GameDevice = dev; m_AT.ActionMaps.TuningP.GameDevice = dev;
m_AT.ActionMaps.TuningP.ActionCommand = nodeText; m_AT.ActionMaps.TuningP.Action = nodeText;
m_AT.ActionMaps.DeadzoneZ.GameDevice = dev; m_AT.ActionMaps.DeadzoneZ.GameDevice = dev;
m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneZ; m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneZ;
JSCAL.PitchTuning = m_AT.ActionMaps.TuningP; JSCAL.PitchTuning = m_AT.ActionMaps.TuningP;
@ -1086,7 +1103,7 @@ namespace SCJMapper_V2
// GP commands that are supported - either Y // GP commands that are supported - either Y
else if ( nodeText.ToLowerInvariant( ).Contains( "_thumbly" ) || nodeText.ToLowerInvariant( ).Contains( "_thumbry" ) ) { else if ( nodeText.ToLowerInvariant( ).Contains( "_thumbly" ) || nodeText.ToLowerInvariant( ).Contains( "_thumbry" ) ) {
m_AT.ActionMaps.TuningP.GameDevice = dev; m_AT.ActionMaps.TuningP.GameDevice = dev;
m_AT.ActionMaps.TuningP.ActionCommand = nodeText; m_AT.ActionMaps.TuningP.Action = nodeText;
m_AT.ActionMaps.DeadzoneY.GameDevice = dev; m_AT.ActionMaps.DeadzoneY.GameDevice = dev;
m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneY; m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneY;
JSCAL.PitchTuning = m_AT.ActionMaps.TuningP; JSCAL.PitchTuning = m_AT.ActionMaps.TuningP;
@ -1095,12 +1112,8 @@ namespace SCJMapper_V2
// attach Roll command - cannot use gamepad here // attach Roll command - cannot use gamepad here
dev = null; dev = null;
find = ActionTreeNode.ComposeNodeText( "v_roll", ActionTreeNode.REG_MOD, "js" ); find = ActionTreeNode.ComposeNodeText( "v_roll", "js" );
nodeText = m_AT.FindText( "spaceship_movement", find ); // returns "" or a complete text ("action - command") nodeText = m_AT.FindText( "spaceship_movement", find ); // returns "" or a complete text ("action - command")
if ( String.IsNullOrWhiteSpace( nodeText ) ) {
find = ActionTreeNode.ComposeNodeText( "v_roll", ActionTreeNode.INV_MOD, "js" );
nodeText = m_AT.FindText( "spaceship_movement", find ); // find inverted ones too
}
if ( !String.IsNullOrWhiteSpace( nodeText ) ) { if ( !String.IsNullOrWhiteSpace( nodeText ) ) {
dev = m_Joystick.Find_jsN( JoystickCls.JSNum( ActionTreeNode.CommandFromNodeText( nodeText ) ) ); dev = m_Joystick.Find_jsN( JoystickCls.JSNum( ActionTreeNode.CommandFromNodeText( nodeText ) ) );
} }
@ -1109,21 +1122,21 @@ namespace SCJMapper_V2
// JS commands that are supported // JS commands that are supported
if ( nodeText.ToLowerInvariant( ).EndsWith( "_x" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotx" ) ) { if ( nodeText.ToLowerInvariant( ).EndsWith( "_x" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotx" ) ) {
m_AT.ActionMaps.TuningR.GameDevice = dev; m_AT.ActionMaps.TuningR.GameDevice = dev;
m_AT.ActionMaps.TuningR.ActionCommand = nodeText; m_AT.ActionMaps.TuningR.Action = nodeText;
m_AT.ActionMaps.DeadzoneX.GameDevice = dev; m_AT.ActionMaps.DeadzoneX.GameDevice = dev;
m_AT.ActionMaps.TuningR.Deadzone = m_AT.ActionMaps.DeadzoneX; m_AT.ActionMaps.TuningR.Deadzone = m_AT.ActionMaps.DeadzoneX;
JSCAL.RollTuning = m_AT.ActionMaps.TuningR; JSCAL.RollTuning = m_AT.ActionMaps.TuningR;
} }
else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) { else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) {
m_AT.ActionMaps.TuningR.GameDevice = dev; m_AT.ActionMaps.TuningR.GameDevice = dev;
m_AT.ActionMaps.TuningR.ActionCommand = nodeText; m_AT.ActionMaps.TuningR.Action = nodeText;
m_AT.ActionMaps.DeadzoneY.GameDevice = dev; m_AT.ActionMaps.DeadzoneY.GameDevice = dev;
m_AT.ActionMaps.TuningR.Deadzone = m_AT.ActionMaps.DeadzoneY; m_AT.ActionMaps.TuningR.Deadzone = m_AT.ActionMaps.DeadzoneY;
JSCAL.RollTuning = m_AT.ActionMaps.TuningR; JSCAL.RollTuning = m_AT.ActionMaps.TuningR;
} }
else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) { else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) {
m_AT.ActionMaps.TuningR.GameDevice = dev; m_AT.ActionMaps.TuningR.GameDevice = dev;
m_AT.ActionMaps.TuningR.ActionCommand = nodeText; m_AT.ActionMaps.TuningR.Action = nodeText;
m_AT.ActionMaps.DeadzoneZ.GameDevice = dev; m_AT.ActionMaps.DeadzoneZ.GameDevice = dev;
m_AT.ActionMaps.TuningR.Deadzone = m_AT.ActionMaps.DeadzoneZ; m_AT.ActionMaps.TuningR.Deadzone = m_AT.ActionMaps.DeadzoneZ;
JSCAL.RollTuning = m_AT.ActionMaps.TuningR; JSCAL.RollTuning = m_AT.ActionMaps.TuningR;
@ -1218,5 +1231,7 @@ namespace SCJMapper_V2
} }
} }

@ -384,6 +384,9 @@
x1//2Q== x1//2Q==
</value> </value>
</data> </data>
<metadata name="cmAddDel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>652, 17</value>
</metadata>
<metadata name="IL.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="IL.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>494, 17</value> <value>494, 17</value>
</metadata> </metadata>
@ -391,9 +394,9 @@
<value> <value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAg ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABK
DgAAAk1TRnQBSQFMAgEBBwEAATgBCwE4AQs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8B+AEPAeABAAGfAf0C/wHwAQcB4AEAAY8B+AHfAf0B4AED
AQMB/wHgAQcEAAEHA/8EAAHHA/8L AgABjwHwAY8B8AHAAQECAAEDAeABBwHwAYABAQUAAoABAQIAAYABAAGAAQABgAEBAgABgAEAAYABAAGA
AQEB4AEAAYABAAGAAQABgAEBAeABAAGAAQEBgAEAAYABAQHgAQABwAEBAcABAQGAAQEB4AEAAcABAQHD
AeEBwAEDAeABAAHgAQMB5wHjAeABBwHgAQAE/wHwAQ8B4AEBBv8B4AEDBv8B4AEHBAAB/AE/Av8EAAH4
AQ8B4AEDBAAB8AEPAcABAQQAAcABBwGAAQEEAAGAAQcBgAEBBAABgAEAAYABAQQAAcABAAGAAQEEAAHg
AQEBgAEBBAAB4AH/AYABAQQAAeAB/wHAAQEEAAHhAf8BwAEBBAABgAH/AcABAwQAAYEB/wHgAQMEAAED
Af8B4AEHBAABBwP/BAABxwP/Cw==
</value> </value>
</data> </data>
<data name="btSaveMyMapping.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="btSaveMyMapping.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">

@ -10,13 +10,10 @@ namespace SCJMapper_V2
private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType ); private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType );
private String m_actionCommand = ""; // v_pitch - js1_x ..
private String m_cmdCtrl = ""; // x, y, rotz ... private String m_cmdCtrl = ""; // x, y, rotz ...
private String m_type = ""; // joystick OR xboxpad private String m_type = ""; // joystick OR xboxpad
private int m_devInstanceNo = -1; // jsN - instance in XML private int m_devInstanceNo = -1; // jsN - instance in XML
String m_option = ""; // the option name (level where it applies)
private String m_deviceName = ""; private String m_deviceName = "";
private bool m_deadzoneEnabled = false; // default private bool m_deadzoneEnabled = false; // default
@ -33,18 +30,20 @@ namespace SCJMapper_V2
public DeviceCls GameDevice public DeviceCls GameDevice
{ {
get { return m_device; } get { return m_device; }
set { m_device = value; set
{
m_device = value;
m_type = ""; m_type = "";
m_devInstanceNo = -1; m_devInstanceNo = -1;
if ( JoystickCls.IsDeviceClass( m_device.DevClass ) ) { if ( JoystickCls.IsDeviceClass( m_device.DevClass ) ) {
m_type = m_device.DevClass; m_type = m_device.DevClass;
m_devInstanceNo = (m_device as JoystickCls).JSAssignment; m_devInstanceNo = ( m_device as JoystickCls ).JSAssignment;
} }
else if ( GamepadCls.IsDeviceClass( m_device.DevClass ) ) { else if ( GamepadCls.IsDeviceClass( m_device.DevClass ) ) {
m_type = m_device.DevClass; m_type = m_device.DevClass;
m_devInstanceNo = 1; // supports ONE gamepad m_devInstanceNo = 1; // supports ONE gamepad
} }
} }
} }
@ -104,6 +103,6 @@ namespace SCJMapper_V2
} }
} }
} }

@ -13,10 +13,10 @@ namespace SCJMapper_V2
{ {
private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType ); private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType );
private String m_actionCommand = ""; // v_pitch - js1_x .. private String m_action = ""; // v_pitch
private String m_cmdCtrl = ""; // x, y, rotz ... private String m_cmdCtrl = ""; // js1_x, js1_y, js1_rotz ...
private String m_type = ""; // joystick OR xboxpad private String m_type = ""; // joystick OR xboxpad
private int m_devInstanceNo = -1; // jsN - instance in XML private int m_devInstanceNo = -1; // jsN - instance in XML
String m_option = ""; // the option name (level where it applies) String m_option = ""; // the option name (level where it applies)
@ -38,7 +38,7 @@ namespace SCJMapper_V2
private DeviceDeadzoneParameter m_deadzone = null; private DeviceDeadzoneParameter m_deadzone = null;
public DeviceTuningParameter( ) public DeviceTuningParameter( )
{ {
} }
@ -47,18 +47,20 @@ namespace SCJMapper_V2
public DeviceCls GameDevice public DeviceCls GameDevice
{ {
get { return m_device; } get { return m_device; }
set { m_device = value; set
{
m_device = value;
m_type = ""; m_type = "";
m_devInstanceNo = -1; m_devInstanceNo = -1;
if ( JoystickCls.IsDeviceClass( m_device.DevClass ) ) { if ( JoystickCls.IsDeviceClass( m_device.DevClass ) ) {
m_type = m_device.DevClass; m_type = m_device.DevClass;
m_devInstanceNo = (m_device as JoystickCls).JSAssignment; m_devInstanceNo = ( m_device as JoystickCls ).JSAssignment;
} }
else if ( GamepadCls.IsDeviceClass( m_device.DevClass ) ) { else if ( GamepadCls.IsDeviceClass( m_device.DevClass ) ) {
m_type = m_device.DevClass; m_type = m_device.DevClass;
m_devInstanceNo = 1; // supports ONE gamepad m_devInstanceNo = 1; // supports ONE gamepad
} }
} }
} }
@ -73,10 +75,10 @@ namespace SCJMapper_V2
set { m_deviceName = value; } set { m_deviceName = value; }
} }
public String ActionCommand public String Action
{ {
get { return m_actionCommand; } get { return m_action; }
set { m_actionCommand = value; DecomposeCommand( ); } set { m_action = value; DecomposeCommand( ); }
} }
public String CommandCtrl public String CommandCtrl
@ -150,8 +152,8 @@ namespace SCJMapper_V2
{ {
// populate from input // populate from input
// something like "v_pitch - js1_x" OR "v_pitch - xi_thumbl" OR "v_pitch - ximod+xi_thumbl+xi_mod" // something like "v_pitch - js1_x" OR "v_pitch - xi_thumbl" OR "v_pitch - ximod+xi_thumbl+xi_mod"
String cmd = ActionTreeNode.CommandFromNodeText( ActionCommand ); String cmd = ActionTree.CommandFromNodeText( Action );
String action = ActionTreeNode.ActionFromNodeText( ActionCommand ); String action = ActionTreeNode.ActionFromNodeText( Action );
m_cmdCtrl = ""; m_cmdCtrl = "";
if ( !String.IsNullOrWhiteSpace( cmd ) ) { if ( !String.IsNullOrWhiteSpace( cmd ) ) {
// decomp gamepad entries - could have modifiers so check for contains... // decomp gamepad entries - could have modifiers so check for contains...

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Media;
namespace SCJMapper_V2
{
public class MySounds
{
/*
SystemSounds.Asterisk,
SystemSounds.Beep,
SystemSounds.Exclamation,
SystemSounds.Hand,
SystemSounds.Question
*
* Asterisk - the sound that is played when a popup alert is displayed, like a warning message.
Default Beep - this sound is played for multiple reasons, depending on what you do. For example, it will play if you try to select a parent window before closing the active one.
Exclamation - the sound that is played when you try to do something that is not supported by Windows.
*/
public static void PlayNotfound( )
{
SystemSounds.Beep.Play( );
}
public static void PlayCannot( )
{
SystemSounds.Beep.Play( );
}
public static void PlayError( )
{
SystemSounds.Exclamation.Play( );
}
}
}

@ -145,7 +145,6 @@ namespace SCJMapper_V2
private float m_liveYsense = 1.0f; private float m_liveYsense = 1.0f;
private float m_liveYexponent = 1.0f; private float m_liveYexponent = 1.0f;
private xyPoints m_liveYnonLinCurve = new xyPoints( 1000 ); // max val of Joystick Input private xyPoints m_liveYnonLinCurve = new xyPoints( 1000 ); // max val of Joystick Input
private bool m_YcmdInvert = false; // inverted by command (not as Tuning)
/// <summary> /// <summary>
/// Submit the tuning parameters /// Submit the tuning parameters
@ -163,8 +162,7 @@ namespace SCJMapper_V2
m_Ytuning = value; m_Ytuning = value;
m_Ydev = m_Ytuning.GameDevice; m_Ydev = m_Ytuning.GameDevice;
// populate from input // populate from input
lblYCmd.Text = m_Ytuning.ActionCommand; lblYCmd.Text = m_Ytuning.Action;
m_YcmdInvert = ActionTreeNode.CommandInvertFromNodeText( m_Ytuning.ActionCommand );
m_liveYawCommand = m_Ytuning.CommandCtrl; m_liveYawCommand = m_Ytuning.CommandCtrl;
log.Info( "FormJSCalCurve : Yaw Command is: " + value ); log.Info( "FormJSCalCurve : Yaw Command is: " + value );
@ -223,7 +221,6 @@ namespace SCJMapper_V2
private float m_livePsense = 1.0f; private float m_livePsense = 1.0f;
private float m_livePexponent = 1.0f; private float m_livePexponent = 1.0f;
private xyPoints m_livePnonLinCurve = new xyPoints( 1000 ); // max val of Joystick Input private xyPoints m_livePnonLinCurve = new xyPoints( 1000 ); // max val of Joystick Input
private bool m_PcmdInvert = false; // inverted by command (not as Tuning)
/// <summary> /// <summary>
/// Submit the tuning parameters /// Submit the tuning parameters
@ -242,9 +239,7 @@ namespace SCJMapper_V2
m_Ptuning = value; m_Ptuning = value;
m_Pdev = m_Ptuning.GameDevice; m_Pdev = m_Ptuning.GameDevice;
// populate from input // populate from input
lblPCmd.Text = m_Ptuning.ActionCommand; // lblPCmd.Text = m_Ptuning.Action; //
m_PcmdInvert = ActionTreeNode.CommandInvertFromNodeText( m_Ptuning.ActionCommand );
if ( GamepadCls.IsDeviceClass( m_Pdev.DevClass ) ) m_PcmdInvert = !m_PcmdInvert; // Gamepad Pitch Movement is inverted by default in AC
m_livePitchCommand = m_Ptuning.CommandCtrl; m_livePitchCommand = m_Ptuning.CommandCtrl;
log.Info( "FormJSCalCurve : Pitch Command is: " + value ); log.Info( "FormJSCalCurve : Pitch Command is: " + value );
@ -303,7 +298,6 @@ namespace SCJMapper_V2
private float m_liveRsense = 1.0f; private float m_liveRsense = 1.0f;
private float m_liveRexponent = 1.0f; private float m_liveRexponent = 1.0f;
private xyPoints m_liveRnonLinCurve = new xyPoints( 1000 ); // max val of Joystick Input private xyPoints m_liveRnonLinCurve = new xyPoints( 1000 ); // max val of Joystick Input
private bool m_RcmdInvert = false; // inverted by command (not as Tuning)
/// <summary> /// <summary>
/// Submit the tuning parameters /// Submit the tuning parameters
@ -322,8 +316,7 @@ namespace SCJMapper_V2
m_Rtuning = value; m_Rtuning = value;
m_Rdev = m_Rtuning.GameDevice; m_Rdev = m_Rtuning.GameDevice;
// populate from input // populate from input
lblRCmd.Text = m_Rtuning.ActionCommand; // lblRCmd.Text = m_Rtuning.Action; //
m_RcmdInvert = ActionTreeNode.CommandInvertFromNodeText( m_Rtuning.ActionCommand );
m_liveRollCommand = m_Rtuning.CommandCtrl; m_liveRollCommand = m_Rtuning.CommandCtrl;
log.Info( "FormJSCalCurve : Roll Command is: " + value ); log.Info( "FormJSCalCurve : Roll Command is: " + value );
@ -725,7 +718,7 @@ namespace SCJMapper_V2
// update in/out labels if active axis // update in/out labels if active axis
lblYInput.Text = ( i_x / 1000.0 ).ToString( "0.00" ); lblYOutput.Text = ( fout ).ToString( "0.00" ); lblYInput.Text = ( i_x / 1000.0 ).ToString( "0.00" ); lblYOutput.Text = ( fout ).ToString( "0.00" );
// calculate new direction vector // calculate new direction vector
m.X = ( ( m_YcmdInvert ) ? -1 : 1 ) * ( ( m_Ytuning.InvertUsed ) ? -1 : 1 ) * ( ( !cbYuse.Checked ) ? fout : 0 ) * m_msElapsed * DegPerMS; m.X = ( ( m_Ytuning.InvertUsed ) ? -1 : 1 ) * ( ( !cbYuse.Checked ) ? fout : 0 ) * m_msElapsed * DegPerMS;
} }
// Pitch // Pitch
@ -746,7 +739,7 @@ namespace SCJMapper_V2
} }
fout = ( fout > 1.0 ) ? 1.0 : fout; fout = ( fout > 1.0 ) ? 1.0 : fout;
lblPInput.Text = ( i_y / 1000.0 ).ToString( "0.00" ); lblPOutput.Text = ( fout ).ToString( "0.00" ); lblPInput.Text = ( i_y / 1000.0 ).ToString( "0.00" ); lblPOutput.Text = ( fout ).ToString( "0.00" );
m.Y = ( ( m_PcmdInvert ) ? -1 : 1 ) * ( ( m_Ptuning.InvertUsed ) ? -1 : 1 ) * ( ( !cbPuse.Checked ) ? -fout : 0 ) * m_msElapsed * DegPerMS; m.Y = ( ( m_Ptuning.InvertUsed ) ? -1 : 1 ) * ( ( !cbPuse.Checked ) ? -fout : 0 ) * m_msElapsed * DegPerMS;
} }
// Roll // Roll
@ -767,7 +760,7 @@ namespace SCJMapper_V2
} }
fout = ( fout > 1.0 ) ? 1.0 : fout; fout = ( fout > 1.0 ) ? 1.0 : fout;
lblRInput.Text = ( i_z / 1000.0 ).ToString( "0.00" ); lblROutput.Text = ( fout ).ToString( "0.00" ); lblRInput.Text = ( i_z / 1000.0 ).ToString( "0.00" ); lblROutput.Text = ( fout ).ToString( "0.00" );
m.Z = ( ( m_RcmdInvert ) ? -1 : 1 ) * ( ( m_Rtuning.InvertUsed ) ? -1 : 1 ) * ( ( !cbRuse.Checked ) ? fout : 0 ) * m_msElapsed * DegPerMS; m.Z = ( ( m_Rtuning.InvertUsed ) ? -1 : 1 ) * ( ( !cbRuse.Checked ) ? fout : 0 ) * m_msElapsed * DegPerMS;
} }
// finalize // finalize

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion( "2.8.0.37" )] [assembly: AssemblyVersion( "2.10.0.40" )]
[assembly: AssemblyFileVersion( "2.8.0.37" )] [assembly: AssemblyFileVersion( "2.10.0.40" )]

@ -26,8 +26,8 @@
<UpdatePeriodically>false</UpdatePeriodically> <UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired> <UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions> <MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>37</ApplicationRevision> <ApplicationRevision>40</ApplicationRevision>
<ApplicationVersion>2.8.0.%2a</ApplicationVersion> <ApplicationVersion>2.10.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
@ -116,6 +116,8 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="actions\ActionCommandCls.cs" />
<Compile Include="actions\ActionTreeInputNode.cs" />
<Compile Include="actions\ActionTreeNode.cs" /> <Compile Include="actions\ActionTreeNode.cs" />
<Compile Include="appConfiguration.cs" /> <Compile Include="appConfiguration.cs" />
<Compile Include="AppSettings.cs" /> <Compile Include="AppSettings.cs" />
@ -124,6 +126,7 @@
<Compile Include="Gamepad\GamepadCls.cs" /> <Compile Include="Gamepad\GamepadCls.cs" />
<Compile Include="Keyboard\KeyboardCls.cs" /> <Compile Include="Keyboard\KeyboardCls.cs" />
<Compile Include="Mouse\MouseCls.cs" /> <Compile Include="Mouse\MouseCls.cs" />
<Compile Include="MySounds.cs" />
<Compile Include="OGL\BezierSeries.cs" /> <Compile Include="OGL\BezierSeries.cs" />
<Compile Include="OGL\CalcBezierCurve.cs" /> <Compile Include="OGL\CalcBezierCurve.cs" />
<Compile Include="Joystick\DeviceTuningParameter.cs" /> <Compile Include="Joystick\DeviceTuningParameter.cs" />

@ -21,7 +21,7 @@ namespace SCJMapper_V2
/// </action> /// </action>
/// ///
/// </summary> /// </summary>
class ActionCls public class ActionCls
{ {
private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType ); private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType );
@ -34,6 +34,8 @@ namespace SCJMapper_V2
AD_Keyboard, AD_Keyboard,
} }
#region Static Items
static public ActionDevice ADevice( String device ) static public ActionDevice ADevice( String device )
{ {
switch ( device.ToLower( ) ) { switch ( device.ToLower( ) ) {
@ -79,28 +81,29 @@ namespace SCJMapper_V2
} }
} }
#endregion
// Class items // Class items
public String key { get; set; } // the key is the "Daction" formatted item (as we can have the same name multiple times) public String key { get; set; } // the key is the "Daction" formatted item (as we can have the same name multiple times)
public String name { get; set; } public String name { get; set; } // the plain action name e.g. v_yaw
public String device { get; set; } public ActionDevice actionDevice { get; set; } // the enum of the device
public String input { get; set; } public String device { get; set; } // name of the device (uses DeviceClass)
public String defBinding { get; set; } // the default binding public String defBinding { get; set; } // the default binding
public Boolean inverted { get; set; } public List<ActionCommandCls> inputList { get; set; }
public ActionDevice actionDevice { get; set; }
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public ActionCls( ) public ActionCls( )
{ {
device = JoystickCls.DeviceClass;
key = ""; key = "";
actionDevice = ActionDevice.AD_Unknown;
device = JoystickCls.DeviceClass;
name = ""; name = "";
input = "";
defBinding = ""; defBinding = "";
inverted = false; inputList = new List<ActionCommandCls>( ); // empty list
actionDevice = ActionDevice.AD_Unknown;
} }
@ -114,24 +117,39 @@ namespace SCJMapper_V2
ActionCls newAc = new ActionCls( ); ActionCls newAc = new ActionCls( );
// full copy from 'this' // full copy from 'this'
newAc.key = this.key; newAc.key = this.key;
newAc.name = this.name; newAc.actionDevice = this.actionDevice;
newAc.device = this.device; newAc.device = this.device;
newAc.name = this.name;
newAc.defBinding = this.defBinding; newAc.defBinding = this.defBinding;
newAc.input = this.input;
newAc.inverted = this.inverted; foreach ( ActionCommandCls acc in inputList ) {
newAc.inputList.Add( acc.ReassignJsN( newJsList ) );
// reassign the jsX part for Joystick commands
if ( JoystickCls.IsDeviceClass( this.device ) && JoystickCls.IsDeviceClass( newAc.device ) ) {
int oldJsN = JoystickCls.JSNum( this.input );
if ( JoystickCls.IsJSValid( oldJsN ) ) {
if ( newJsList.ContainsKey( oldJsN ) ) newAc.input = JoystickCls.ReassignJSTag( this.input, newJsList[oldJsN] );
}
} }
return newAc; return newAc;
} }
public ActionCommandCls AddCommand( String input, int index )
{
ActionCommandCls acc = new ActionCommandCls( );
acc.input = input; acc.nodeIndex = index;
inputList.Add( acc );
return acc;
}
public void DelCommand( int index )
{
int removeIt = -1;
for ( int i = 0; i < inputList.Count; i++ ) {
if ( inputList[i].nodeIndex == index ) removeIt = i;
if ( inputList[i].nodeIndex > index ) inputList[i].nodeIndex -= 1; // reorder trailing ones
}
if ( removeIt >= 0 ) inputList.RemoveAt( removeIt );
}
/// <summary> /// <summary>
/// Merge action is simply copying the new input control /// Merge action is simply copying the new input control
@ -139,8 +157,10 @@ namespace SCJMapper_V2
/// <param name="newAc"></param> /// <param name="newAc"></param>
public void Merge( ActionCls newAc ) public void Merge( ActionCls newAc )
{ {
input = newAc.input; this.inputList.Clear( );
inverted = newAc.inverted; foreach ( ActionCommandCls acc in newAc.inputList ) {
this.inputList.Add( acc );
}
} }
/// <summary> /// <summary>
@ -149,12 +169,21 @@ namespace SCJMapper_V2
/// <returns>the action as XML fragment</returns> /// <returns>the action as XML fragment</returns>
public String toXML( ) public String toXML( )
{ {
String r = ""; String r = ""; String
if ( !String.IsNullOrEmpty( input ) ) { bindCmd = "rebind";
if ( inverted ) r = String.Format( "\t<action name=\"{0}\">\n\t\t\t<rebind device=\"{1}\" input=\"{2}\" invert=\"1\" />\n\t\t</action>\n", name, device, input ); if ( inputList.Count > 0 ) {
else r = String.Format( "\t<action name=\"{0}\">\n\t\t\t<rebind device=\"{1}\" input=\"{2}\" />\n\t\t</action>\n", name, device, input ); if ( !String.IsNullOrEmpty( inputList[0].input ) ) {
r = String.Format( "\t<action name=\"{0}\">\n", name );
foreach ( ActionCommandCls acc in inputList ) {
if ( !String.IsNullOrEmpty( acc.input ) ) {
r += String.Format( "\t\t\t<{0} device=\"{1}\" {2}", bindCmd, device, acc.toXML( ) );
bindCmd = "addbind";
}
}
r += String.Format( "\t\t</action>\n" );
}
} }
return r; return r;
} }
@ -176,34 +205,43 @@ namespace SCJMapper_V2
if ( reader.Name == "action" ) { if ( reader.Name == "action" ) {
if ( reader.HasAttributes ) { if ( reader.HasAttributes ) {
name = reader["name"]; name = reader["name"];
// Move the reader back to the element node. reader.ReadStartElement( "action" ); // Checks that the current content node is an element with the given Name and advances the reader to the next node
reader.ReadStartElement( "action" );
} }
else { else {
return false; return false;
} }
} }
if ( reader.Name == "rebind" ) { do {
if ( reader.HasAttributes ) { if ( reader.Name == "rebind" ) {
device = reader["device"]; if ( reader.HasAttributes ) {
input = reader["input"]; device = reader["device"];
if ( ( input == JoystickCls.BlendedInput ) || ( input == GamepadCls.BlendedInput ) ) input = ""; // don't carry jsx_reserved or xi_reserved into the action ActionCommandCls acc = new ActionCommandCls( );
key = DevID( device ) + name; // unique id of the action acc.input = reader["input"];
actionDevice = ADevice( device ); // get the enum of the input device if ( ( acc.input == JoystickCls.BlendedInput ) || ( acc.input == GamepadCls.BlendedInput ) ) acc.input = ""; // don't carry jsx_reserved or xi_reserved into the action
String inv = reader["invert"]; key = DevID( device ) + name; // unique id of the action
if ( String.IsNullOrWhiteSpace( inv ) ) { actionDevice = ADevice( device ); // get the enum of the input device
inverted = false; inputList.Add( acc );
// advances the reader to the next node
reader.ReadStartElement( "rebind" );
} }
else { }
inverted = ( inv == "1" ) ? true : false; else if ( reader.Name == "addbind" ) {
if ( reader.HasAttributes ) {
device = reader["device"];
ActionCommandCls acc = new ActionCommandCls( );
acc.input = reader["input"];
if ( ( acc.input == JoystickCls.BlendedInput ) || ( acc.input == GamepadCls.BlendedInput ) ) acc.input = ""; // don't carry jsx_reserved or xi_reserved into the action
key = DevID( device ) + name; // unique id of the action
actionDevice = ADevice( device ); // get the enum of the input device
inputList.Add( acc );
// advances the reader to the next node
reader.ReadStartElement( "addbind" );
} }
// Move the reader back to the element node.
reader.ReadStartElement( "rebind" );
} }
} else {
else { return false;
return false; }
} } while ( reader.Name == "addbind" );
return true; return true;
} }

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SCJMapper_V2
{
public class ActionCommandCls
{
public String input { get; set; } // input command name e.g. js1_x
/// <summary>
/// The index of the visible child node (-1 -> shown in ActionNode)
/// </summary>
public int nodeIndex { get; set; } // index of the vis treenode
// ctor
public ActionCommandCls( )
{
input = "UNDEF";
nodeIndex = -1;
}
/// <summary>
/// Copy return the action while reassigning the JsN Tag
/// </summary>
/// <param name="newJsList">The JsN reassign list</param>
/// <returns>The action copy with reassigned input</returns>
public ActionCommandCls ReassignJsN( Dictionary<int, int> newJsList )
{
ActionCommandCls newAc = new ActionCommandCls( );
// full copy from 'this'
newAc.input = this.input;
// reassign the jsX part for Joystick commands (silly but rather fast comparison)
if ( this.input.Contains( "js1_" ) || this.input.Contains( "js2_" ) || this.input.Contains( "js3_" ) || this.input.Contains( "js4_" ) ) {
int oldJsN = JoystickCls.JSNum( this.input );
if ( JoystickCls.IsJSValid( oldJsN ) ) {
if ( newJsList.ContainsKey( oldJsN ) ) newAc.input = JoystickCls.ReassignJSTag( this.input, newJsList[oldJsN] );
}
}
return newAc;
}
/// <summary>
/// Dump the action as partial XML nicely formatted
/// </summary>
/// <returns>the action as XML fragment</returns>
public String toXML( )
{
String r = "";
if ( !String.IsNullOrEmpty( input ) ) {
r = String.Format( "input=\"{0}\" />\n", input );
}
else {
r = String.Format( " />\n" ); // actually an ERROR...
}
return r;
}
}
}

@ -35,6 +35,8 @@ namespace SCJMapper_V2
#endregion Static Part of ActionMaps #endregion Static Part of ActionMaps
private const String ACM_VERSION = "1"; // the default version
private String version { get; set; } private String version { get; set; }
private String ignoreversion { get; set; } private String ignoreversion { get; set; }
@ -125,7 +127,7 @@ namespace SCJMapper_V2
/// </summary> /// </summary>
public ActionMapsCls( JoystickList jsList ) public ActionMapsCls( JoystickList jsList )
{ {
version = "0"; version = ACM_VERSION;
m_joystickList = jsList; // have to save this for Reassign m_joystickList = jsList; // have to save this for Reassign
// create the Joystick assignments // create the Joystick assignments
@ -216,7 +218,7 @@ namespace SCJMapper_V2
r += String.Format( "version=\"{0}\" \n", version ); r += String.Format( "version=\"{0}\" \n", version );
} }
else { else {
version = "0"; // preset if missing version = ACM_VERSION; // preset if missing
r += String.Format( "version=\"{0}\" \n", version ); r += String.Format( "version=\"{0}\" \n", version );
} }
@ -270,6 +272,8 @@ namespace SCJMapper_V2
if ( reader.Name == "ActionMaps" ) { if ( reader.Name == "ActionMaps" ) {
if ( reader.HasAttributes ) { if ( reader.HasAttributes ) {
version = reader["version"]; version = reader["version"];
if ( version == "0" ) version = ACM_VERSION; // update from legacy to actual version
ignoreversion = reader["ignoreVersion"]; // could be either / or .. ignoreversion = reader["ignoreVersion"]; // could be either / or ..
// get the joystick mapping if there is one // get the joystick mapping if there is one

@ -97,6 +97,82 @@ namespace SCJMapper_V2
} }
public Boolean CanBlendBinding
{
get
{
if ( Ctrl.SelectedNode == null ) return false;
else return ( Ctrl.SelectedNode.Level == 1 );
}
}
public Boolean CanClearBinding
{
get
{
if ( Ctrl.SelectedNode == null ) return false;
else return ( Ctrl.SelectedNode.Level == 1 );
}
}
public Boolean CanAddBinding
{
get
{
if ( Ctrl.SelectedNode == null ) return false;
else return ( Ctrl.SelectedNode.Level == 1 );
}
}
public Boolean CanDelBinding
{
get {
if ( Ctrl.SelectedNode == null ) return false;
else return ( Ctrl.SelectedNode.Level == 2 );
}
}
/// <summary>
/// Add a new Action Child to the selected Node to apply an addtional mapping
/// </summary>
public void AddBinding( )
{
if ( Ctrl.SelectedNode == null ) return;
if ( Ctrl.SelectedNode.Level != 1 ) return; // can only add to level 1 nodes
ActionTreeNode matn = FindMasterAction( ( ActionTreeNode )Ctrl.SelectedNode );
ActionCls ac = FindActionObject( matn.Parent.Name, matn.Name ); // the related action
// make new items
ActionTreeInputNode matin = new ActionTreeInputNode( "UNDEF" ); matin.ImageKey = "Add";
matn.Nodes.Add( matin ); // add to master tree
ActionCommandCls acc = ac.AddCommand( "", matin.Index );
// show stuff
FilterTree( );
FindAndSelectCtrlByName( matn.Name );
}
/// <summary>
/// Delete the selected ActionChild and remove corresponding ActionCommands
/// </summary>
public void DelBinding( )
{
if ( Ctrl.SelectedNode == null ) return;
if ( Ctrl.SelectedNode.Level != 2 ) return; // can only delete level 2 nodes
ActionTreeNode matn = FindMasterAction( ( ActionTreeNode )Ctrl.SelectedNode.Parent ); // the parent treenode
ActionCls ac = FindActionObject( matn.Parent.Name, matn.Name ); // the related action
// delete items
ac.DelCommand( m_ctrl.SelectedNode.Index );
matn.Nodes.RemoveAt( m_ctrl.SelectedNode.Index );
Dirty = true;
// show stuff
FilterTree( );
FindAndSelectCtrlByName( matn.Name );
}
private void UpdateMasterNode( ActionTreeNode node ) private void UpdateMasterNode( ActionTreeNode node )
{ {
// copy to master node // copy to master node
@ -105,12 +181,47 @@ namespace SCJMapper_V2
// could return more than one if the action is the same in different actionmaps // could return more than one if the action is the same in different actionmaps
foreach ( ActionTreeNode mtn in masterNode ) { foreach ( ActionTreeNode mtn in masterNode ) {
if ( mtn.Parent.Name == node.Parent.Name ) { if ( mtn.Parent.Name == node.Parent.Name ) {
mtn.Command = node.Command; mtn.InvertCommand = node.InvertCommand; mtn.BackColor = node.BackColor; mtn.Command = node.Command; mtn.BackColor = node.BackColor;
}
}
}
private void UpdateMasterNode( ActionTreeInputNode node )
{
// copy to master node
TreeNode[] masterNode = m_MasterTree.Nodes.Find( node.Name, true ); // find the same node in master
if ( masterNode.Length == 0 ) throw new IndexOutOfRangeException( "ActionTree ERROR - cannot find synched node in master" ); // OUT OF SYNC
// could return more than one if the action is the same in different actionmaps
foreach ( ActionTreeInputNode mtn in masterNode ) {
if ( mtn.Parent.Name == node.Parent.Name ) {
mtn.Command = node.Command; mtn.BackColor = node.BackColor;
} }
} }
} }
/// <summary>
/// Find the master element for the given ActionNode
/// </summary>
/// <param name="atn">The ActionNode to find</param>
/// <returns>The sought node or null</returns>
private ActionTreeNode FindMasterAction( ActionTreeNode atn )
{
if ( atn.Level != 1 ) return null; // sanity
TreeNode[] masterNode = m_MasterTree.Nodes.Find( atn.Name, true ); // find the same node in master
if ( masterNode.Length == 0 ) throw new IndexOutOfRangeException( "ActionTree ERROR - cannot find synched node in master" ); // OUT OF SYNC
// could return more than one if the action is the same in different actionmaps
foreach ( ActionTreeNode mtn in masterNode ) {
if ( mtn.Parent.Name == atn.Parent.Name ) {
return mtn;
}
}
return null;
}
/// <summary> /// <summary>
/// Apply the filter to the GUI TreeView /// Apply the filter to the GUI TreeView
/// </summary> /// </summary>
@ -136,12 +247,15 @@ namespace SCJMapper_V2
} }
else { else {
ActionTreeNode tnAction = new ActionTreeNode( stn ); tnMap.Nodes.Add( tnAction ); // copy level 1 nodes ActionTreeNode tnAction = new ActionTreeNode( stn ); tnMap.Nodes.Add( tnAction ); // copy level 1 nodes
foreach ( ActionTreeInputNode istn in stn.Nodes ) {
ActionTreeInputNode tnActionInput = new ActionTreeInputNode( istn ); tnAction.Nodes.Add( tnActionInput ); // copy level 2 nodes
}
allHidden = false; allHidden = false;
} }
} }
// make it tidier.. // make it tidier..
if ( allHidden ) tnMap.Collapse( ); if ( allHidden ) tnMap.Collapse( );
else tnMap.Expand( ); else tnMap.ExpandAll( );
} }
if ( topNode != null ) Ctrl.TopNode = topNode; // set view to topnode if ( topNode != null ) Ctrl.TopNode = topNode; // set view to topnode
@ -187,17 +301,18 @@ namespace SCJMapper_V2
/// </summary> /// </summary>
/// <param name="defaultProfileName">The name of the profile to load (w/o extension)</param> /// <param name="defaultProfileName">The name of the profile to load (w/o extension)</param>
/// <param name="applyDefaults">True if default mappings should be carried on</param> /// <param name="applyDefaults">True if default mappings should be carried on</param>
public void LoadTree( String defaultProfileName, Boolean applyDefaults ) public void LoadProfileTree( String defaultProfileName, Boolean applyDefaults )
{ {
log.Debug( "LoadTree - Entry" ); log.Debug( "LoadProfileTree - Entry" );
ActionTreeNode tn = null; ActionTreeNode tn = null;
ActionTreeNode[] cnl = { }; ActionTreeNode[] cnl = { };
ActionTreeNode cn = null; ActionTreeNode cn = null;
ActionTreeNode topNode = null; ActionTreeNode topNode = null;
ActionCls ac = null;
ActionMapCls acm = null; ActionMapCls acm = null;
ActionCls ac = null;
ActionCommandCls acc = null;
ActionMaps = new ActionMapsCls( m_jsList ); ActionMaps = new ActionMapsCls( m_jsList );
m_MasterTree.Nodes.Clear( ); m_MasterTree.Nodes.Clear( );
@ -212,6 +327,9 @@ namespace SCJMapper_V2
txReader = new StringReader( dpReader.CSVMap ); txReader = new StringReader( dpReader.CSVMap );
} }
// we assume no addbind items in the profile
// so all actions are shown in the ActionTreeNode and no ActionTreeNode childs must be created here
// however we create the ActionCommand for each entry that is supported - even if it is not mapped (input= "")
using ( TextReader sr = txReader ) { using ( TextReader sr = txReader ) {
String buf = sr.ReadLine( ); String buf = sr.ReadLine( );
while ( !String.IsNullOrEmpty( buf ) ) { while ( !String.IsNullOrEmpty( buf ) ) {
@ -227,59 +345,64 @@ namespace SCJMapper_V2
// default assignments // default assignments
String action = elem[ei].Substring( 1 ); String action = elem[ei].Substring( 1 );
String defBinding = elem[ei + 1].Substring( 0 ); String defBinding = elem[ei + 1].Substring( 0 );
cn = new ActionTreeNode( "UNDEF" ); cn.Name = elem[ei]; cn.Action = action; cn.BackColor = Color.White; // name with the key it to find it..
String devID = elem[ei].Substring( 0, 1 ); String devID = elem[ei].Substring( 0, 1 );
String device = ActionCls.DeviceFromID( devID ); String device = ActionCls.DeviceFromID( devID );
cn.ImageKey = devID;
cn.BackColor = Color.White; // some stuff does not work properly...
// visual item for the action
cn = new ActionTreeNode( "UNDEF" ); cn.Name = elem[ei]; cn.Action = action; cn.BackColor = Color.White; // name with the key it to find it..
cn.ImageKey = devID; cn.BackColor = Color.White; // some stuff does not work properly...
Array.Resize( ref cnl, cnl.Length + 1 ); cnl[cnl.Length - 1] = cn; Array.Resize( ref cnl, cnl.Length + 1 ); cnl[cnl.Length - 1] = cn;
// derive content tree
ac = new ActionCls( ); ac.key = cn.Name; ac.name = action; ac.device = device; ac.actionDevice = ActionCls.ADevice( device ); ac.defBinding = defBinding; ac = new ActionCls( ); ac.key = cn.Name; ac.name = action; ac.device = device; ac.actionDevice = ActionCls.ADevice( device ); ac.defBinding = defBinding;
cn.ActionDevice = ac.actionDevice; // should be known now
acm.Add( ac ); // add to our map acm.Add( ac ); // add to our map
cn.ActionDevice = ac.actionDevice; // should be known now
// create just an unmapped ActionCommand item
acc = new ActionCommandCls( ); acc.input = ""; acc.nodeIndex = -1; // profile items are shown in the ActionTreeNode (not in a child)
ac.inputList.Add( acc );// add to our Action
// modify defaults and blendings
if ( applyDefaults ) { if ( applyDefaults ) {
// apply the default mappings // apply the default mappings
if ( JoystickCls.IsDeviceClass( ac.device ) ) { if ( ac.actionDevice == ActionCls.ActionDevice.AD_Joystick ) {
int jNum = JoystickCls.JSNum( ac.defBinding ); int jNum = JoystickCls.JSNum( ac.defBinding );
if ( JoystickCls.IsJSValid( jNum ) ) { if ( JoystickCls.IsJSValid( jNum ) ) {
ac.input = ac.defBinding; acc.input = ac.defBinding;
cn.Command = ac.defBinding; cn.BackColor = JoystickCls.JsNColor( jNum ); cn.Command = ac.defBinding; cn.BackColor = JoystickCls.JsNColor( jNum );
} }
else if ( BlendUnmappedJS ) { else if ( BlendUnmappedJS ) {
// jsx_reserved gets here // jsx_reserved gets here
ac.input = JoystickCls.BlendedInput; acc.input = JoystickCls.BlendedInput;
cn.Command = JoystickCls.BlendedInput; cn.BackColor = MyColors.BlendedColor; cn.Command = JoystickCls.BlendedInput; cn.BackColor = MyColors.BlendedColor;
} }
} }
else if ( GamepadCls.IsDeviceClass( ac.device ) ) { else if ( ac.actionDevice == ActionCls.ActionDevice.AD_Gamepad ) {
if ( GamepadCls.IsXiValid( ac.defBinding ) ) { if ( GamepadCls.IsXiValid( ac.defBinding ) ) {
ac.input = ac.defBinding; acc.input = ac.defBinding;
cn.Command = ac.defBinding; cn.BackColor = GamepadCls.XiColor( ); cn.Command = ac.defBinding; cn.BackColor = GamepadCls.XiColor( );
} }
else if ( BlendUnmappedGP ) { else if ( BlendUnmappedGP ) {
// xi_reserved gets here // xi_reserved gets here
ac.input = GamepadCls.BlendedInput; acc.input = GamepadCls.BlendedInput;
cn.Command = GamepadCls.BlendedInput; cn.BackColor = MyColors.BlendedColor; cn.Command = GamepadCls.BlendedInput; cn.BackColor = MyColors.BlendedColor;
} }
} }
else if ( KeyboardCls.IsDeviceClass( ac.device ) ) { else if ( ac.actionDevice == ActionCls.ActionDevice.AD_Keyboard ) {
if ( !String.IsNullOrEmpty( ac.defBinding ) ) { if ( !String.IsNullOrEmpty( ac.defBinding ) ) {
ac.input = ac.defBinding; acc.input = ac.defBinding;
cn.Command = ac.defBinding; cn.BackColor = KeyboardCls.KbdColor( ); cn.Command = ac.defBinding; cn.BackColor = KeyboardCls.KbdColor( );
} }
} }
} }
// Don't apply defaults - but blend if checked // Don't apply defaults - but blend if checked
else { else {
// init empty if ( ( ac.actionDevice == ActionCls.ActionDevice.AD_Joystick ) && BlendUnmappedJS ) {
if ( JoystickCls.IsDeviceClass( ac.device ) && BlendUnmappedJS ) {
ac.input = JoystickCls.BlendedInput;
cn.Command = JoystickCls.BlendedInput; cn.BackColor = MyColors.BlendedColor; cn.Command = JoystickCls.BlendedInput; cn.BackColor = MyColors.BlendedColor;
acc.input = JoystickCls.BlendedInput;
} }
else if ( GamepadCls.IsDeviceClass( ac.device ) && BlendUnmappedGP ) { else if ( ( ac.actionDevice == ActionCls.ActionDevice.AD_Gamepad ) && BlendUnmappedGP ) {
ac.input = GamepadCls.BlendedInput;
cn.Command = GamepadCls.BlendedInput; cn.BackColor = MyColors.BlendedColor; cn.Command = GamepadCls.BlendedInput; cn.BackColor = MyColors.BlendedColor;
acc.input = GamepadCls.BlendedInput;
} }
} }
} }
@ -319,15 +442,105 @@ namespace SCJMapper_V2
/// First apply to the GUI tree where the selection happend then copy it over to master tree /// First apply to the GUI tree where the selection happend then copy it over to master tree
/// </summary> /// </summary>
/// <param name="input">The new Text property</param> /// <param name="input">The new Text property</param>
public void UpdateSelectedItem( String input, Boolean invert, DeviceCls.InputKind inKind ) public Boolean UpdateSelectedItem( String input, ActionCls.ActionDevice inKind )
{ {
if ( Ctrl.SelectedNode == null ) return; if ( ( Ctrl.SelectedNode.Level == 0 ) || ( Ctrl.SelectedNode.Level > 2 ) ) return false; // ERROR exit
if ( Ctrl.SelectedNode == null ) return false; // ERROR exit
if ( Ctrl.SelectedNode.Parent == null ) return false; // ERROR exit
// has a parent - must be level 1 or 2
if ( Ctrl.SelectedNode.Level == 1 ) {
// this is the main node with Action Cmd
ActionCls ac = FindActionObject( Ctrl.SelectedNode.Parent.Name, Ctrl.SelectedNode.Name );
if ( ac == null ) return false; // ERROR exit
if ( ac.actionDevice != inKind ) return false; // ERROR exit
ActionCommandCls acc = FindActionInputObject( Ctrl.SelectedNode.Parent.Name, Ctrl.SelectedNode.Name, CommandFromNodeText( Ctrl.SelectedNode.Text ) );
if ( acc == null ) return false; // ERROR exit
UpdateActionCommandFromInput( input, acc, inKind );
UpdateNodeFromAction( ( ActionTreeNode )Ctrl.SelectedNode, acc, inKind );
}
else if ( Ctrl.SelectedNode.Level == 2 ) {
// this is a child of an action with further commands
ActionTreeNode atn = ( m_ctrl.SelectedNode.Parent as ActionTreeNode ); // the parent treenode
ActionCls ac = FindActionObject( atn.Parent.Name, atn.Name ); // the related action
if ( ac == null ) return false; // ERROR exit
if ( ac.actionDevice != inKind ) return false; // ERROR exit
ActionCommandCls acc = FindActionInputObject( ac, m_ctrl.SelectedNode.Index );
if ( acc == null ) return false; // ERROR exit
UpdateActionCommandFromInput( input, acc, inKind );
UpdateInputNodeFromAction( ( ActionTreeInputNode )Ctrl.SelectedNode, acc, inKind );
}
return true;
}
ActionCls ac = FindActionObject( Ctrl.SelectedNode.Parent.Name, Ctrl.SelectedNode.Name ); /// <summary>
UpdateActionFromInput( input, invert, ac ); /// Find an action with name in a actionmap
UpdateNodeFromAction( ( ActionTreeNode )Ctrl.SelectedNode, ac, inKind ); /// </summary>
/// <param name="actionMap">The actionmap name</param>
/// <param name="action">The action</param>
/// <param name="input">The input</param>
/// <returns>An actionCommand or null if not found</returns>
private ActionCommandCls FindActionInputObject( String actionMap, String action, String input )
{
log.Debug( "FindActionInputObject - Entry" );
// Apply the input to the ActionTree
ActionCls ac = null; ActionCommandCls acc = null;
ActionMapCls ACM = ActionMaps.Find( delegate( ActionMapCls _ACM ) { return _ACM.name == actionMap; } );
if ( ACM != null ) ac = ACM.Find( delegate( ActionCls _AC ) { return _AC.key == action; } );
if ( ac != null ) acc = ac.inputList.Find( delegate( ActionCommandCls _ACC ) { return _ACC.input == input; } );
if ( acc == null ) {
log.Error( "FindActionInputObject - Action Input not found in tree" );
return null; // ERROR - Action Input not found in tree
}
return acc;
} }
/// <summary>
/// Find an action with name in a actionmap
/// </summary>
/// <param name="actionMap">The actionmap name</param>
/// <param name="action">The action</param>
/// <param name="input">The input</param>
/// <returns>An actionCommand or null if not found</returns>
private ActionCommandCls FindActionInputObject( String actionMap, String action, int index )
{
log.Debug( "FindActionInputObject - Entry" );
// Apply the input to the ActionTree
ActionCls ac = null; ActionCommandCls acc = null;
ActionMapCls ACM = ActionMaps.Find( delegate( ActionMapCls _ACM ) { return _ACM.name == actionMap; } );
if ( ACM != null ) ac = ACM.Find( delegate( ActionCls _AC ) { return _AC.key == action; } );
if ( ac != null ) acc = ac.inputList.Find( delegate( ActionCommandCls _ACC ) { return _ACC.nodeIndex == index; } );
if ( acc == null ) {
log.Error( "FindActionInputObject - Action Input not found in tree" );
return null; // ERROR - Action Input not found in tree
}
return acc;
}
/// <summary>
/// Find an ActionCommand with index in an Action
/// </summary>
/// <param name="actionMap">The actionmap name</param>
/// <param name="action">The action</param>
/// <param name="input">The input</param>
/// <returns>An actionCommand or null if not found</returns>
private ActionCommandCls FindActionInputObject( ActionCls ac, int index )
{
log.Debug( "FindActionInputObject - Entry" );
// Apply the input to the ActionTree
ActionCommandCls acc = null;
if ( ac != null ) acc = ac.inputList.Find( delegate( ActionCommandCls _ACC ) { return _ACC.nodeIndex == index; } );
if ( acc == null ) {
log.Error( "FindActionInputObject - Action Input not found in Action" );
return null; // ERROR - Action Input not found in tree
}
return acc;
}
/// <summary> /// <summary>
/// Find an action with name in a actionmap /// Find an action with name in a actionmap
/// </summary> /// </summary>
@ -350,28 +563,26 @@ namespace SCJMapper_V2
/// <summary> /// <summary>
/// Updates an action with a new input (command) /// Updates an actionCommand with a new input (command)
/// </summary> /// </summary>
/// <param name="input">The input command</param> /// <param name="input">The input command</param>
/// <param name="action">The action to update</param> /// <param name="action">The action to containing the command</param>
/// <param name="inKind">The input device</param> /// <param name="actionCmd">The actionCommand to update</param>
private void UpdateActionFromInput( String input, Boolean invert, ActionCls action ) private void UpdateActionCommandFromInput( String input, ActionCommandCls actionCmd, ActionCls.ActionDevice inKind )
{ {
log.Debug( "UpdateActionFromInput - Entry" ); log.Debug( "UpdateActionCommandFromInput - Entry" );
if ( action == null ) return; if ( actionCmd == null ) return;
// Apply the input to the ActionTree // Apply the input to the ActionTree
if ( String.IsNullOrEmpty( input ) ) { if ( String.IsNullOrEmpty( input ) ) {
// unmapped - handle the blended ones from setting // unmapped - handle the blended ones from setting
action.inverted = false; // reset in any case if ( ( inKind == ActionCls.ActionDevice.AD_Joystick ) && BlendUnmappedJS ) actionCmd.input = JoystickCls.BlendedInput;
if ( JoystickCls.IsDeviceClass( action.device ) && BlendUnmappedJS ) action.input = JoystickCls.BlendedInput; else if ( ( inKind == ActionCls.ActionDevice.AD_Gamepad ) && BlendUnmappedGP ) actionCmd.input = GamepadCls.BlendedInput;
else if ( GamepadCls.IsDeviceClass( action.device ) && BlendUnmappedGP ) action.input = GamepadCls.BlendedInput; else actionCmd.input = "";
else action.input = "";
} }
else { else {
// mapped ones // mapped ones
action.input = input; actionCmd.input = input;
action.inverted = invert;
} }
Dirty = true; Dirty = true;
} }
@ -384,43 +595,42 @@ namespace SCJMapper_V2
/// <param name="node">The TreeNode to update</param> /// <param name="node">The TreeNode to update</param>
/// <param name="action">The action that carries the update</param> /// <param name="action">The action that carries the update</param>
/// <param name="inKind">The input device</param> /// <param name="inKind">The input device</param>
private void UpdateNodeFromAction( ActionTreeNode node, ActionCls action, DeviceCls.InputKind inKind ) private void UpdateNodeFromAction( ActionTreeNode node, ActionCommandCls actionCmd, ActionCls.ActionDevice inKind )
{ {
log.Debug( "UpdateNodeFromAction - Entry" ); log.Debug( "UpdateNodeFromAction - Entry" );
if ( action == null ) return; if ( actionCmd == null ) return;
// applies only to ActionNodes // applies only to ActionTreeNode
if ( node.Level == 1 ) { if ( node.Level == 1 ) {
// input is either "" or a valid mapping or a blended mapping // input is either "" or a valid mapping or a blended mapping
if ( String.IsNullOrEmpty( action.input ) ) { if ( String.IsNullOrEmpty( actionCmd.input ) ) {
// new unmapped // new unmapped
node.Command = ""; node.InvertCommand = false; node.BackColor = MyColors.UnassignedColor; node.Command = ""; node.BackColor = MyColors.UnassignedColor;
} }
// blended mapped ones - can only get a Blend Background // blended mapped ones - can only get a Blend Background
else if ( JoystickCls.IsDeviceClass( action.device ) && ( action.input == JoystickCls.BlendedInput ) ) { else if ( ( inKind == ActionCls.ActionDevice.AD_Joystick ) && ( actionCmd.input == JoystickCls.BlendedInput ) ) {
node.Command = action.input; node.InvertCommand = false; node.BackColor = MyColors.BlendedColor; node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
} }
else if ( GamepadCls.IsDeviceClass( action.device ) && ( action.input == GamepadCls.BlendedInput ) ) { else if ( ( inKind == ActionCls.ActionDevice.AD_Gamepad ) && ( actionCmd.input == GamepadCls.BlendedInput ) ) {
node.Command = action.input; node.InvertCommand = false; node.BackColor = MyColors.BlendedColor; node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
} }
else if ( action.input == DeviceCls.BlendedInput ) { else if ( actionCmd.input == DeviceCls.BlendedInput ) {
// Manually Blended input // Manually Blended input
node.Command = action.input; node.InvertCommand = false; node.BackColor = MyColors.BlendedColor; node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
} }
else { else {
// mapped ( regular ones ) // mapped ( regular ones )
node.Command = action.input; node.Command = actionCmd.input;
node.InvertCommand = action.inverted;
// background is along the input // background is along the input
if ( inKind == DeviceCls.InputKind.Joystick ) { if ( inKind == ActionCls.ActionDevice.AD_Joystick ) {
int jNum = JoystickCls.JSNum( action.input ); int jNum = JoystickCls.JSNum( actionCmd.input );
node.BackColor = JoystickCls.JsNColor( jNum ); node.BackColor = JoystickCls.JsNColor( jNum );
} }
else if ( inKind == DeviceCls.InputKind.Gamepad ) { else if ( inKind == ActionCls.ActionDevice.AD_Gamepad ) {
node.BackColor = GamepadCls.XiColor( ); node.BackColor = GamepadCls.XiColor( );
} }
else if ( inKind == DeviceCls.InputKind.Kbd ) { else if ( inKind == ActionCls.ActionDevice.AD_Keyboard ) {
node.BackColor = KeyboardCls.KbdColor( ); node.BackColor = KeyboardCls.KbdColor( );
} }
else { else {
@ -433,6 +643,62 @@ namespace SCJMapper_V2
} }
} }
/// <summary>
/// Apply an update from the action to the treenode
/// First apply to the GUI tree where the selection happend then copy it over to master tree
/// </summary>
/// <param name="input">The input command</param>
/// <param name="node">The TreeNode to update</param>
/// <param name="actionCmd">The actionCommand that carries the update</param>
/// <param name="inKind">The input device</param>
private void UpdateInputNodeFromAction( ActionTreeInputNode node, ActionCommandCls actionCmd, ActionCls.ActionDevice inKind )
{
log.Debug( "UpdateInputNodeFromAction - Entry" );
if ( actionCmd == null ) return;
if ( node.Level != 2 ) return; // applies only to ActionTreeInputNode
// input is either "" or a valid mapping or a blended mapping
if ( String.IsNullOrEmpty( actionCmd.input ) ) {
// new unmapped
node.Command = ""; node.BackColor = MyColors.UnassignedColor;
}
// blended mapped ones - can only get a Blend Background
else if ( ( inKind == ActionCls.ActionDevice.AD_Joystick ) && ( actionCmd.input == JoystickCls.BlendedInput ) ) {
node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
}
else if ( ( inKind == ActionCls.ActionDevice.AD_Gamepad ) && ( actionCmd.input == GamepadCls.BlendedInput ) ) {
node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
}
else if ( actionCmd.input == DeviceCls.BlendedInput ) {
// Manually Blended input
node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
}
else {
// mapped ( regular ones )
node.Command = actionCmd.input;
// background is along the input
if ( inKind == ActionCls.ActionDevice.AD_Joystick ) {
int jNum = JoystickCls.JSNum( actionCmd.input );
node.BackColor = JoystickCls.JsNColor( jNum );
}
else if ( inKind == ActionCls.ActionDevice.AD_Gamepad ) {
node.BackColor = GamepadCls.XiColor( );
}
else if ( inKind == ActionCls.ActionDevice.AD_Keyboard ) {
node.BackColor = KeyboardCls.KbdColor( );
}
else {
// ?? what else
node.BackColor = MyColors.UnassignedColor;
}
}
UpdateMasterNode( node );
}
/// <summary> /// <summary>
/// Defines what to show in the tree /// Defines what to show in the tree
/// </summary> /// </summary>
@ -440,7 +706,7 @@ namespace SCJMapper_V2
/// <param name="showGamepad">True to show Gamepad actions</param> /// <param name="showGamepad">True to show Gamepad actions</param>
/// <param name="showKeyboard">True to show Keyboard actions</param> /// <param name="showKeyboard">True to show Keyboard actions</param>
/// <param name="showMappedOnly">True to show mapped actions only </param> /// <param name="showMappedOnly">True to show mapped actions only </param>
public void DefineShowOptions(Boolean showJoystick, Boolean showGamepad, Boolean showKeyboard, Boolean showMappedOnly) public void DefineShowOptions( Boolean showJoystick, Boolean showGamepad, Boolean showKeyboard, Boolean showMappedOnly )
{ {
m_showJoy = showJoystick; m_showJoy = showJoystick;
m_showGameP = showGamepad; m_showGameP = showGamepad;
@ -460,37 +726,32 @@ namespace SCJMapper_V2
foreach ( ActionMapCls acm in ActionMaps ) { foreach ( ActionMapCls acm in ActionMaps ) {
if ( IgnoreMaps.Contains( "," + acm.name + "," ) ) break; // next if ( IgnoreMaps.Contains( "," + acm.name + "," ) ) break; // next
try { try {
ActionTreeNode amTn = ( ActionTreeNode )m_MasterTree.Nodes[acm.name]; // get the map node ActionTreeNode mtn = ( ActionTreeNode )m_MasterTree.Nodes[acm.name]; // get the map node
// find the item to reload into the treeview // find the item to reload into the treeview
foreach ( ActionCls ac in acm ) { foreach ( ActionCls ac in acm ) {
try { ActionTreeNode matn = ( ActionTreeNode )mtn.Nodes[ac.key]; // get the action node
ActionTreeNode tnl = ( ActionTreeNode )amTn.Nodes[ac.key]; Boolean first=true;
UpdateActionFromInput( ac.input, ac.inverted, ac ); // this may apply (un)Blending if needed // refresh commands
// input kind priority first foreach ( ActionCommandCls acc in ac.inputList ) {
if ( JoystickCls.IsJsN( ac.input ) ) { try {
UpdateNodeFromAction( tnl, ac, DeviceCls.InputKind.Joystick ); UpdateActionCommandFromInput( acc.input, acc, ac.actionDevice ); // this may apply (un)Blending if needed
} // the first one goes into the node, further must be created if not existing
else if ( GamepadCls.IsXiValid( ac.input ) ) { if ( first ) {
UpdateNodeFromAction( tnl, ac, DeviceCls.InputKind.Gamepad ); UpdateNodeFromAction( matn, acc, ac.actionDevice );
} matn.Nodes.Clear( ); // clear add childs - those don't persist from newly loaded actionmaps
// device priority second first = false;
else if ( JoystickCls.IsDeviceClass( ac.device ) ) { }
UpdateNodeFromAction( tnl, ac, DeviceCls.InputKind.Joystick ); else {
} // have to recreate the action child nodes
else if ( GamepadCls.IsDeviceClass( ac.device ) ) { ActionTreeInputNode matin = new ActionTreeInputNode( "UNDEF" ); matin.ImageKey = "Add";
UpdateNodeFromAction( tnl, ac, DeviceCls.InputKind.Gamepad ); acc.nodeIndex = matin.Index; // assign visual reference
} matn.Nodes.Add( matin ); // add to master tree
else if ( KeyboardCls.IsDeviceClass( ac.device ) ) { UpdateInputNodeFromAction( matin, acc, ac.actionDevice );
UpdateNodeFromAction( tnl, ac, DeviceCls.InputKind.Kbd ); }
} }
else { catch {
// ?? defaults to unassigned color ; // key not found
UpdateNodeFromAction( tnl, ac, DeviceCls.InputKind.Other );
} }
}
catch {
; // key not found
} }
} }
} }
@ -513,24 +774,59 @@ namespace SCJMapper_V2
{ {
log.Debug( "FindAndSelectCtrl - Entry" ); log.Debug( "FindAndSelectCtrl - Entry" );
Boolean found = false;
foreach ( ActionTreeNode tn in Ctrl.Nodes ) { foreach ( ActionTreeNode tn in Ctrl.Nodes ) {
// have to search nodes of nodes // have to search nodes of nodes
foreach ( ActionTreeNode stn in tn.Nodes ) { foreach ( ActionTreeNode stn in tn.Nodes ) {
if ( stn.Text.Contains( ctrl ) ) { if ( stn.Text.Contains( ctrl ) ) {
Ctrl.SelectedNode = stn; Ctrl.SelectedNode = stn;
Ctrl.SelectedNode.EnsureVisible( ); Ctrl.SelectedNode.EnsureVisible( );
found = true; return; // exit all loops
break; }
// have to search nodes of nodes
foreach ( ActionTreeInputNode sstn in stn.Nodes ) {
if ( sstn.Text.Contains( ctrl ) ) {
Ctrl.SelectedNode = sstn;
Ctrl.SelectedNode.EnsureVisible( );
return; // exit all loops
}
} }
} }
if ( found ) break; // exit all loops
} }
} }
/// <summary> /// <summary>
/// Find a control that contains the Command /// Find a control that contains the string and mark it
/// this method is applied to the GUI TreeView only
/// </summary>
/// <param name="m_MasterTree">The string to find</param>
public void FindAndSelectCtrlByName( String ctrlName )
{
log.Debug( "FindAndSelectCtrlByName - Entry" );
foreach ( ActionTreeNode tn in Ctrl.Nodes ) {
// have to search nodes of nodes
foreach ( ActionTreeNode stn in tn.Nodes ) {
if ( stn.Name == ctrlName ) {
Ctrl.SelectedNode = stn;
Ctrl.SelectedNode.EnsureVisible( );
return; // exit all loops
}
// have to search nodes of nodes
foreach ( ActionTreeInputNode sstn in stn.Nodes ) {
if ( sstn.Name == ctrlName ) {
Ctrl.SelectedNode = sstn;
Ctrl.SelectedNode.EnsureVisible( );
return; // exit all loops
}
}
}
}
}
/// <summary>
/// Find a control that contains the Action
/// </summary> /// </summary>
/// <param name="actionmap">The actionmap to find the string</param> /// <param name="actionmap">The actionmap to find the string</param>
/// <param name="text">The string to find</param> /// <param name="text">The string to find</param>
@ -561,6 +857,14 @@ namespace SCJMapper_V2
} }
static public String CommandFromNodeText( String actionCommand )
{
String[] e = actionCommand.Split( new char[] { '-' } );
if ( e.Length > 1 ) return e[1].Substring( 1 );
return "";
}
/// <summary> /// <summary>
/// Find a control that contains the Command /// Find a control that contains the Command
/// </summary> /// </summary>
@ -574,8 +878,10 @@ namespace SCJMapper_V2
if ( String.IsNullOrEmpty( actionmap ) || ( tn.Text == actionmap ) ) { if ( String.IsNullOrEmpty( actionmap ) || ( tn.Text == actionmap ) ) {
// have to search nodes of nodes // have to search nodes of nodes
foreach ( ActionTreeNode stn in tn.Nodes ) { foreach ( ActionTreeNode stn in tn.Nodes ) {
if ( stn.Command.Contains( command ) ) { foreach ( ActionTreeInputNode istn in stn.Nodes ) {
return stn.Text; if ( istn.Command.Contains( command ) ) {
return stn.Text + " - " + istn.Text;
}
} }
} }
} }
@ -625,6 +931,23 @@ namespace SCJMapper_V2
} }
public String SelectedAction
{
get {
if ( Ctrl.SelectedNode == null ) return "";
if ( Ctrl.SelectedNode.Level == 1 ) {
ActionTreeNode matn = FindMasterAction( ( ActionTreeNode )Ctrl.SelectedNode );
return ActionTreeNode.ActionFromNodeText( matn.Text );
}
else if ( Ctrl.SelectedNode.Level == 2 ) {
ActionTreeNode matn = FindMasterAction( ( ActionTreeNode )Ctrl.SelectedNode.Parent ); // the parent treenode
return ActionTreeNode.ActionFromNodeText( matn.Text );
}
else return "";
}
}
/// <summary> /// <summary>
/// Reports a summary list of the mapped items /// Reports a summary list of the mapped items
/// </summary> /// </summary>
@ -644,9 +967,11 @@ namespace SCJMapper_V2
String rep = String.Format( "*** {0}\n", acm.name ); String rep = String.Format( "*** {0}\n", acm.name );
repList += rep; repList += rep;
foreach ( ActionCls ac in acm ) { foreach ( ActionCls ac in acm ) {
if ( !String.IsNullOrEmpty( ac.input ) && !( ac.input == JoystickCls.BlendedInput ) ) { foreach ( ActionCommandCls acc in ac.inputList ) {
rep = String.Format( " {0} - {1} - ({2})\n", ac.name.PadRight( 35 ), ac.input.PadRight( 30 ), ac.device ); if ( !String.IsNullOrEmpty( acc.input ) && !( acc.input == JoystickCls.BlendedInput ) ) {
repList += rep; rep = String.Format( " {0} - {1} - ({2})\n", ac.name.PadRight( 35 ), acc.input.PadRight( 30 ), ac.device );
repList += rep;
}
} }
} }
repList += String.Format( "\n" ); repList += String.Format( "\n" );

@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SCJMapper_V2
{
/// <summary>
/// Our INPUT TreeNode - inherits a regular one and adds some functionality
///
/// contains the input command i.e. - js2_button3 OR ! js1_x (MODs applies at the very beginning of the string)
/// </summary>
class ActionTreeInputNode : TreeNode
{
#region Static items
// Handle all text label composition and extraction here
public static String ComposeNodeText( String cmd )
{
if ( String.IsNullOrEmpty( cmd ) ) {
return "";
}
else {
return cmd;
}
}
public static void DecompNodeText( String nodeText, out String cmd )
{
cmd = nodeText;
}
/// <summary>
/// Returns the command part from a node text
/// i.e. v_pitch - js1_x returns js1_x
/// </summary>
/// <param name="nodeText">The node text in 'action - command' notation</param>
/// <returns>the command part or an empty string</returns>
public static String CommandFromNodeText( String nodeText )
{
String cmd;
DecompNodeText( nodeText, out cmd );
return cmd;
}
#endregion
// Object defs
// ctor
public ActionTreeInputNode( )
: base( )
{
}
// ctor
public ActionTreeInputNode( ActionTreeInputNode srcNode )
: base( )
{
if ( srcNode == null ) return;
this.Name = srcNode.Name;
this.Text = srcNode.Text;
this.BackColor = srcNode.BackColor;
this.ForeColor = srcNode.ForeColor;
this.NodeFont = srcNode.NodeFont;
this.ImageKey = srcNode.ImageKey;
this.Tag = srcNode.Tag;
this.m_command = srcNode.m_command;
}
// ctor
public ActionTreeInputNode( string text )
{
this.Text = text;
}
// ctor
public ActionTreeInputNode( string text, ActionTreeInputNode[] children )
: base( text, children )
{
}
private String m_command ="";
public new String Text
{
get { return base.Text; }
set
{
DecompNodeText( value, out m_command );
base.Text = ComposeNodeText( m_command );
}
}
public String Command
{
get { return m_command; }
set
{
m_command = value;
base.Text = ComposeNodeText( m_command );
}
}
public Boolean IsMappedAction
{
get
{
return !( String.IsNullOrEmpty( m_command )
|| ( m_command == JoystickCls.BlendedInput )
|| ( m_command == GamepadCls.BlendedInput ) );
}
}
}
}

@ -14,27 +14,23 @@ namespace SCJMapper_V2
#region Static items #region Static items
public const char REG_MOD = '-';
public const char INV_MOD = '!';
// Handle all text label composition and extraction here // Handle all text label composition and extraction here
public static String ComposeNodeText( String action, char mod, String cmd ) public static String ComposeNodeText( String action, String cmd )
{ {
if ( String.IsNullOrEmpty( cmd ) ) { if ( String.IsNullOrEmpty( cmd ) ) {
return action; return action;
} }
else { else {
return action + " " + mod + " " + cmd; return action + " - " + cmd;
} }
} }
public static void DecompNodeText( String nodeText, out String action, out char mod, out String cmd ) public static void DecompNodeText( String nodeText, out String action, out String cmd )
{ {
action = ""; cmd = ""; mod = ( nodeText.Contains( INV_MOD ) ) ? INV_MOD : REG_MOD; action = ""; cmd = "";
String[] e = nodeText.Split( new char[] { REG_MOD, INV_MOD }, StringSplitOptions.RemoveEmptyEntries ); String[] e = nodeText.Split( new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries );
if ( e.Length > 1 ) { if ( e.Length > 1 ) {
action = e[0].TrimEnd( ); action = e[0].TrimEnd( );
if ( e[1] == " " + DeviceCls.BlendedInput ) { if ( e[1] == " " + DeviceCls.BlendedInput ) {
@ -59,8 +55,8 @@ namespace SCJMapper_V2
/// <returns>the action part or an empty string</returns> /// <returns>the action part or an empty string</returns>
public static String ActionFromNodeText( String nodeText ) public static String ActionFromNodeText( String nodeText )
{ {
String action, cmd; char mod; String action, cmd;
DecompNodeText( nodeText, out action, out mod, out cmd ); DecompNodeText( nodeText, out action, out cmd );
return action; return action;
} }
@ -72,24 +68,11 @@ namespace SCJMapper_V2
/// <returns>the command part or an empty string</returns> /// <returns>the command part or an empty string</returns>
public static String CommandFromNodeText( String nodeText ) public static String CommandFromNodeText( String nodeText )
{ {
String action, cmd; char mod; String action, cmd;
DecompNodeText( nodeText, out action, out mod, out cmd ); DecompNodeText( nodeText, out action, out cmd );
return cmd; return cmd;
} }
/// <summary>
/// Returns the invert modifier of the command part from a node text
/// i.e. v_pitch - js1_x returns false v_pitch ! js1_x returns true
/// </summary>
/// <param name="nodeText">The node text in 'action - command' notation</param>
/// <returns>True if there is a command and if it contains an inverter else false</returns>
public static Boolean CommandInvertFromNodeText( String nodeText )
{
String action, cmd; char mod;
DecompNodeText( nodeText, out action, out mod, out cmd );
return ( mod == INV_MOD );
}
#endregion #endregion
@ -115,8 +98,6 @@ namespace SCJMapper_V2
this.Tag = srcNode.Tag; this.Tag = srcNode.Tag;
this.m_action = srcNode.m_action; this.m_action = srcNode.m_action;
this.m_actionDevice = srcNode.m_actionDevice; this.m_actionDevice = srcNode.m_actionDevice;
this.m_command = srcNode.m_command;
this.m_modifier = srcNode.m_modifier;
} }
// ctor // ctor
@ -134,7 +115,6 @@ namespace SCJMapper_V2
private String m_action = ""; private String m_action = "";
private String m_command =""; private String m_command ="";
private char m_modifier = REG_MOD;
private ActionCls.ActionDevice m_actionDevice = ActionCls.ActionDevice.AD_Unknown; private ActionCls.ActionDevice m_actionDevice = ActionCls.ActionDevice.AD_Unknown;
public new String Text public new String Text
@ -142,8 +122,8 @@ namespace SCJMapper_V2
get { return base.Text; } get { return base.Text; }
set set
{ {
DecompNodeText( value, out m_action, out m_modifier, out m_command ); DecompNodeText( value, out m_action, out m_command );
base.Text = ComposeNodeText( m_action, m_modifier, m_command ); base.Text = ComposeNodeText( m_action, m_command );
} }
} }
@ -154,7 +134,7 @@ namespace SCJMapper_V2
set set
{ {
m_action = value; m_action = value;
base.Text = ComposeNodeText( m_action, m_modifier, m_command ); base.Text = ComposeNodeText( m_action, m_command );
} }
} }
@ -164,17 +144,7 @@ namespace SCJMapper_V2
set set
{ {
m_command = value; m_command = value;
base.Text = ComposeNodeText( m_action, m_modifier, m_command ); base.Text = ComposeNodeText( m_action, m_command );
}
}
public Boolean InvertCommand
{
get { return ( m_modifier == INV_MOD ); }
set
{
m_modifier = ( value ) ? INV_MOD : REG_MOD;
base.Text = ComposeNodeText( m_action, m_modifier, m_command );
} }
} }
@ -204,9 +174,11 @@ namespace SCJMapper_V2
public Boolean IsMappedAction public Boolean IsMappedAction
{ {
get { return !( String.IsNullOrEmpty(m_command) get
|| ( m_command == JoystickCls.BlendedInput ) {
|| ( m_command == GamepadCls.BlendedInput ) ); return !( String.IsNullOrEmpty( m_command )
|| ( m_command == JoystickCls.BlendedInput )
|| ( m_command == GamepadCls.BlendedInput ) );
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Loading…
Cancel
Save