SC 2.0 Alpha Update - second push

- more fixings with new maps
- blending and profile import cleanup
- profile import of nested structures
- support of pre SC2.0 map import
- removed global JS or GP blend options in Settings
- removed ignoreversion from Settings
pull/104/head
bm98 9 years ago
parent d1e77e3564
commit 2158bcf8b7

@ -82,22 +82,6 @@ namespace SCJMapper_V2
set { this["MyMappingName"] = value; }
}
[UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "False" )]
public Boolean BlendUnmapped // Joystick (back compatibility)
{
get { return ( Boolean )this["BlendUnmapped"]; }
set { this["BlendUnmapped"] = value; }
}
[UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "False" )]
public Boolean BlendUnmappedGP
{
get { return ( Boolean )this["BlendUnmappedGP"]; }
set { this["BlendUnmappedGP"] = value; }
}
[UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "True" )]
public Boolean ShowJoystick
@ -230,15 +214,6 @@ namespace SCJMapper_V2
}
[UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "False" )]
public Boolean ForceIgnoreversion
{
get { return ( Boolean )this["ForceIgnoreversion"]; }
set { this["ForceIgnoreversion"] = value; }
}
[UserScopedSettingAttribute( )]
[DefaultSettingValueAttribute( "False" )]
public Boolean DetectGamepad

@ -12,6 +12,7 @@ namespace SCJMapper_V2
public abstract class DeviceCls
{
public const String DeviceClass ="UNDEF";
public const String DeviceID = "NA0_";
static public Boolean IsUndefined( String deviceClass )
{
return ( deviceClass == DeviceClass );
@ -19,17 +20,11 @@ namespace SCJMapper_V2
public const String BlendedInput = "~"; // internal used only
static public Boolean IsBlendedInput( String input ) { return ( input == BlendedInput ); }
static public String toXML( String blendedInput )
{
return blendedInput.Replace( BlendedInput, " " ); // must make spaces (tilde is for internal processing only)
}
static public String fromXML( String blendedInput )
{
return blendedInput.Replace( " ", BlendedInput ); // must make tilde (spaces is for external processing only)
}
static public Boolean IsDeviceClass( String deviceClass ) { return false; }
static public String DeviceClassFromInput( String input ) { return DeviceClass; }
static public Boolean DevMatch( String devInput ) { return false; }
public abstract String DevClass { get; }
public abstract String DevName { get; }
@ -42,5 +37,15 @@ namespace SCJMapper_V2
public abstract String GetLastChange( );
public abstract void GetCmdData( String cmd, out int data );
public abstract void GetData( );
static public String toXML( String blendedInput )
{
return blendedInput.Replace( BlendedInput, " " ); // must make spaces (tilde is for internal processing only)
}
static public String fromXML( String blendedInput )
{
return blendedInput.Replace( " ", BlendedInput ); // must make tilde (spaces is for external processing only)
}
}
}

37
Form1.Designer.cs generated

@ -168,7 +168,7 @@
this.rtb.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.rtb.Location = new System.Drawing.Point(676, 81);
this.rtb.Name = "rtb";
this.rtb.Size = new System.Drawing.Size(372, 529);
this.rtb.Size = new System.Drawing.Size(372, 531);
this.rtb.TabIndex = 21;
this.rtb.Text = "";
this.rtb.WordWrap = false;
@ -267,9 +267,10 @@
this.panel2.Controls.Add(this.btClear);
this.panel2.Controls.Add(this.lblAction);
this.panel2.Controls.Add(this.btAssign);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(3, 358);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(289, 142);
this.panel2.Size = new System.Drawing.Size(289, 170);
this.panel2.TabIndex = 17;
//
// btJsKbd
@ -277,7 +278,7 @@
this.btJsKbd.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btJsKbd.ImageKey = "J";
this.btJsKbd.ImageList = this.IL;
this.btJsKbd.Location = new System.Drawing.Point(104, 112);
this.btJsKbd.Location = new System.Drawing.Point(104, 125);
this.btJsKbd.Name = "btJsKbd";
this.btJsKbd.Size = new System.Drawing.Size(79, 25);
this.btJsKbd.TabIndex = 16;
@ -302,7 +303,7 @@
//
// btBlend
//
this.btBlend.Location = new System.Drawing.Point(10, 112);
this.btBlend.Location = new System.Drawing.Point(10, 125);
this.btBlend.Name = "btBlend";
this.btBlend.Size = new System.Drawing.Size(73, 25);
this.btBlend.TabIndex = 16;
@ -313,7 +314,7 @@
// lblLastJ
//
this.lblLastJ.ContextMenuStrip = this.cmMouseEntry;
this.lblLastJ.Location = new System.Drawing.Point(52, 38);
this.lblLastJ.Location = new System.Drawing.Point(52, 42);
this.lblLastJ.Name = "lblLastJ";
this.lblLastJ.ShortcutsEnabled = false;
this.lblLastJ.Size = new System.Drawing.Size(222, 22);
@ -331,7 +332,7 @@
this.tmeWDown,
this.toolStripSeparator4});
this.cmMouseEntry.Name = "cmMouseEntry";
this.cmMouseEntry.Size = new System.Drawing.Size(172, 126);
this.cmMouseEntry.Size = new System.Drawing.Size(172, 104);
this.cmMouseEntry.Opening += new System.ComponentModel.CancelEventHandler(this.cmMouseEntry_Opening);
//
// tmeXAxis
@ -379,7 +380,7 @@
// cbxThrottle
//
this.cbxThrottle.AutoSize = true;
this.cbxThrottle.Location = new System.Drawing.Point(89, 72);
this.cbxThrottle.Location = new System.Drawing.Point(89, 86);
this.cbxThrottle.Name = "cbxThrottle";
this.cbxThrottle.Size = new System.Drawing.Size(66, 17);
this.cbxThrottle.TabIndex = 13;
@ -388,7 +389,7 @@
//
// btFind
//
this.btFind.Location = new System.Drawing.Point(201, 67);
this.btFind.Location = new System.Drawing.Point(201, 81);
this.btFind.Name = "btFind";
this.btFind.Size = new System.Drawing.Size(73, 25);
this.btFind.TabIndex = 12;
@ -399,7 +400,7 @@
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(7, 41);
this.label7.Location = new System.Drawing.Point(7, 45);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(28, 13);
this.label7.TabIndex = 3;
@ -416,7 +417,7 @@
//
// btClear
//
this.btClear.Location = new System.Drawing.Point(201, 112);
this.btClear.Location = new System.Drawing.Point(201, 125);
this.btClear.Name = "btClear";
this.btClear.Size = new System.Drawing.Size(73, 25);
this.btClear.TabIndex = 2;
@ -436,7 +437,7 @@
//
// btAssign
//
this.btAssign.Location = new System.Drawing.Point(10, 67);
this.btAssign.Location = new System.Drawing.Point(10, 81);
this.btAssign.Name = "btAssign";
this.btAssign.Size = new System.Drawing.Size(73, 25);
this.btAssign.TabIndex = 15;
@ -663,8 +664,8 @@
this.tlpanel.Padding = new System.Windows.Forms.Padding(3);
this.tlpanel.RowCount = 5;
this.tlpanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 75F));
this.tlpanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 535F));
this.tlpanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tlpanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 155F));
this.tlpanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 84F));
this.tlpanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F));
this.tlpanel.Size = new System.Drawing.Size(1054, 892);
@ -678,7 +679,7 @@
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel1.Location = new System.Drawing.Point(376, 81);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(294, 529);
this.flowLayoutPanel1.Size = new System.Drawing.Size(294, 531);
this.flowLayoutPanel1.TabIndex = 22;
//
// tableLayoutPanel1
@ -693,7 +694,7 @@
this.tableLayoutPanel1.Controls.Add(this.btJSTuning, 0, 4);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize;
this.tableLayoutPanel1.Location = new System.Drawing.Point(376, 616);
this.tableLayoutPanel1.Location = new System.Drawing.Point(376, 618);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 5;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
@ -701,7 +702,7 @@
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(294, 151);
this.tableLayoutPanel1.Size = new System.Drawing.Size(294, 149);
this.tableLayoutPanel1.TabIndex = 23;
//
// btDumpLog
@ -718,7 +719,7 @@
//
this.btJSTuning.Location = new System.Drawing.Point(3, 123);
this.btJSTuning.Name = "btJSTuning";
this.btJSTuning.Size = new System.Drawing.Size(120, 24);
this.btJSTuning.Size = new System.Drawing.Size(120, 23);
this.btJSTuning.TabIndex = 17;
this.btJSTuning.Text = "Device Tuning";
this.btJSTuning.Click += new System.EventHandler(this.btJSTuning_Click);
@ -944,9 +945,9 @@
this.flowLayoutPanel3.Controls.Add(this.cbxInvStrafeLon);
this.flowLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel3.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel3.Location = new System.Drawing.Point(676, 616);
this.flowLayoutPanel3.Location = new System.Drawing.Point(676, 618);
this.flowLayoutPanel3.Name = "flowLayoutPanel3";
this.flowLayoutPanel3.Size = new System.Drawing.Size(372, 151);
this.flowLayoutPanel3.Size = new System.Drawing.Size(372, 149);
this.flowLayoutPanel3.TabIndex = 27;
//
// cbxInvAimPitch

@ -359,7 +359,7 @@ namespace SCJMapper_V2
log.Debug( "InitActionTree - Entry" );
// build TreeView and the ActionMaps
m_AT = new ActionTree( m_AppSettings.BlendUnmapped, m_AppSettings.BlendUnmappedGP, m_Joystick, m_Gamepad );
m_AT = new ActionTree( m_Joystick, m_Gamepad );
m_AT.Ctrl = treeView1; // the ActionTree owns the TreeView control
m_AT.IgnoreMaps = m_AppSettings.IgnoreActionmaps;
// provide the display items (init)

@ -128,7 +128,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAA8
EAAAAk1TRnQBSQFMAgEBCQEAAdgBDQHYAQ0BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
EAAAAk1TRnQBSQFMAgEBCQEAAfgBDQH4AQ0BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

@ -57,9 +57,6 @@
this.label1 = new System.Windows.Forms.Label();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.cbxDetectGamepad = new System.Windows.Forms.CheckBox();
this.cbxForceIgnoreversion = new System.Windows.Forms.CheckBox();
this.cbxBlendJS = new System.Windows.Forms.CheckBox();
this.cbxBlendGP = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@ -336,10 +333,7 @@
//
// groupBox4
//
this.groupBox4.Controls.Add(this.cbxBlendGP);
this.groupBox4.Controls.Add(this.cbxBlendJS);
this.groupBox4.Controls.Add(this.cbxDetectGamepad);
this.groupBox4.Controls.Add(this.cbxForceIgnoreversion);
this.groupBox4.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.groupBox4.Location = new System.Drawing.Point(12, 340);
this.groupBox4.Name = "groupBox4";
@ -351,43 +345,13 @@
// cbxDetectGamepad
//
this.cbxDetectGamepad.AutoSize = true;
this.cbxDetectGamepad.Location = new System.Drawing.Point(145, 27);
this.cbxDetectGamepad.Location = new System.Drawing.Point(9, 21);
this.cbxDetectGamepad.Name = "cbxDetectGamepad";
this.cbxDetectGamepad.Size = new System.Drawing.Size(98, 17);
this.cbxDetectGamepad.TabIndex = 6;
this.cbxDetectGamepad.Text = "Use Gamepad";
this.cbxDetectGamepad.UseVisualStyleBackColor = true;
//
// cbxForceIgnoreversion
//
this.cbxForceIgnoreversion.AutoSize = true;
this.cbxForceIgnoreversion.Location = new System.Drawing.Point(6, 27);
this.cbxForceIgnoreversion.Name = "cbxForceIgnoreversion";
this.cbxForceIgnoreversion.Size = new System.Drawing.Size(133, 17);
this.cbxForceIgnoreversion.TabIndex = 5;
this.cbxForceIgnoreversion.Text = "force \'ignoreversion\'";
this.cbxForceIgnoreversion.UseVisualStyleBackColor = true;
//
// cbxBlendJS
//
this.cbxBlendJS.AutoSize = true;
this.cbxBlendJS.Location = new System.Drawing.Point(439, 13);
this.cbxBlendJS.Name = "cbxBlendJS";
this.cbxBlendJS.Size = new System.Drawing.Size(100, 17);
this.cbxBlendJS.TabIndex = 16;
this.cbxBlendJS.Text = "Blend Joystick";
this.cbxBlendJS.UseVisualStyleBackColor = true;
//
// cbxBlendGP
//
this.cbxBlendGP.AutoSize = true;
this.cbxBlendGP.Location = new System.Drawing.Point(439, 36);
this.cbxBlendGP.Name = "cbxBlendGP";
this.cbxBlendGP.Size = new System.Drawing.Size(109, 17);
this.cbxBlendGP.TabIndex = 16;
this.cbxBlendGP.Text = "Blend Gamepad";
this.cbxBlendGP.UseVisualStyleBackColor = true;
//
// FormSettings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -405,7 +369,7 @@
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FormSettings";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Settings";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormSettings_FormClosing);
this.Load += new System.EventHandler(this.FormSettings_Load);
@ -450,9 +414,6 @@
private System.Windows.Forms.Button btCancel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.CheckBox cbxForceIgnoreversion;
private System.Windows.Forms.CheckBox cbxDetectGamepad;
private System.Windows.Forms.CheckBox cbxBlendGP;
private System.Windows.Forms.CheckBox cbxBlendJS;
}
}

@ -60,13 +60,6 @@ namespace SCJMapper_V2
}
}
// Blend options
cbxBlendJS.Checked = m_owner.BlendUnmapped;
cbxBlendGP.Checked = m_owner.BlendUnmappedGP;
// ForceIgnoreversion
cbxForceIgnoreversion.Checked = m_owner.ForceIgnoreversion;
// DetectGamepad
cbxDetectGamepad.Checked = m_owner.DetectGamepad;
}
@ -97,13 +90,6 @@ namespace SCJMapper_V2
}
m_owner.IgnoreActionmaps = ignore;
// Blend options
m_owner.BlendUnmapped = cbxBlendJS.Checked;
m_owner.BlendUnmappedGP = cbxBlendGP.Checked;
// ForceIgnoreversion
m_owner.ForceIgnoreversion = cbxForceIgnoreversion.Checked;
// DetectGamepad
if ( m_owner.DetectGamepad != cbxDetectGamepad.Checked ) {
MessageBox.Show( "Changing the Gamepad option needs a restart of the application !!", "Settings Notification", MessageBoxButtons.OK, MessageBoxIcon.Information );

@ -23,10 +23,11 @@ namespace SCJMapper_V2
#region Static Items
public new const String DeviceClass = "xboxpad"; // the device name used throughout this app
public new const String DeviceID = "xi1_";
static public int RegisteredDevices = 0;
public const String JsUnknown = "xi_";
public new const String BlendedInput = "xi1_" + DeviceCls.BlendedInput;
public new const String BlendedInput = DeviceID + DeviceCls.BlendedInput;
static public new Boolean IsBlendedInput( String input )
{
if ( input == BlendedInput ) return true;
@ -56,11 +57,11 @@ namespace SCJMapper_V2
/// <summary>
/// Return this deviceClass if the input string contains something like xiN_
/// </summary>
/// <param name="input"></param>
/// <param name="devInput"></param>
/// <returns></returns>
static public new String DeviceClassFromInput( String input )
static public new String DeviceClassFromInput( String devInput )
{
if ( IsXi( input ) )
if ( DevMatch( devInput ) )
return DeviceClass; // this
else
return DeviceCls.DeviceClass; // unknown
@ -68,32 +69,18 @@ namespace SCJMapper_V2
/// <summary>
/// Returns true if the input is an xi_ but not xi_reserved
/// Returns true if the input matches this device
/// </summary>
/// <param name="device"></param>
/// <returns></returns>
static public Boolean IsXiValid( String input )
/// <param name="devInput">A devInput string</param>
/// <returns>True for a match</returns>
static public new Boolean DevMatch( String devInput )
{
return (IsXi(input) && (String.Compare(input, BlendedInput)!= 0));
}
const string xi_pattern = @"^xi_*";
static Regex rgx_xi = new Regex( xi_pattern, RegexOptions.IgnoreCase );
/// <summary>
/// Returns true if the input starts with a valid xi_ formatting (TODO can we have kbd modifiers here?)
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
static public Boolean IsXi( String input )
{
return rgx_xi.IsMatch( input );
return devInput.StartsWith( DeviceID );
}
const string xil_pattern = @"^xi_thumb[lr][xy]$";
static Regex rgx_xil = new Regex( xil_pattern, RegexOptions.IgnoreCase );
/// <summary>
/// returns true if the ctrl can be inverted - for now this is thumb[lr][xyz]
/// </summary>
@ -114,6 +101,7 @@ namespace SCJMapper_V2
// input is something like a xi_something or compositions like triggerl_btn+thumbrx
// try easy: add xi1_ at the beginning; if xi_start subst with xi1_
String retVal = input.Replace(" ","");
if ( IsBlendedInput( input ) ) return input;
if ( retVal.StartsWith( "xi_" ) )
retVal = retVal.Insert( 2, "1" );

@ -397,7 +397,7 @@
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FormReassign";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Reassign Joystick Numbers";
this.Load += new System.EventHandler(this.FormReassign_Load);
this.groupBox1.ResumeLayout(false);

@ -23,6 +23,7 @@ namespace SCJMapper_V2
#region Static Items
public new const String DeviceClass = "joystick"; // the device name used throughout this app
public new const String DeviceID = "js1_";
static public int RegisteredDevices = 0;
@ -31,7 +32,7 @@ namespace SCJMapper_V2
public const String JsUnknown = "jsx_";
public new const String BlendedInput = "js1_" + DeviceCls.BlendedInput; //AC2 ..
public new const String BlendedInput = DeviceID + DeviceCls.BlendedInput; //AC2 ..
static public new Boolean IsBlendedInput( String input )
{
if ( input == BlendedInput ) return true;
@ -97,16 +98,27 @@ namespace SCJMapper_V2
/// <summary>
/// Return this deviceClass if the input string contains something like jsN_
/// </summary>
/// <param name="input"></param>
/// <param name="devInput"></param>
/// <returns></returns>
static public new String DeviceClassFromInput( String input )
static public new String DeviceClassFromInput( String devInput )
{
if ( JSNum( input ) != JSnum_UNKNOWN )
if ( JSNum( devInput ) != JSnum_UNKNOWN )
return DeviceClass; // this
else
return DeviceCls.DeviceClass; // unknown
}
/// <summary>
/// Returns true if the input matches this device
/// </summary>
/// <param name="devInput">A devInput string</param>
/// <returns>True for a match</returns>
static public new Boolean DevMatch( String devInput )
{
return devInput.StartsWith( DeviceID );
}
/// <summary>
/// Returns the jsN part from a joystick command
@ -144,7 +156,7 @@ namespace SCJMapper_V2
/// <returns>The formatted JS name for the CryEngine XML</returns>
static public String JSTag( int jsNum )
{
if ( IsJSValid( jsNum ) ) return "js" + jsNum.ToString( ) + "_";
if ( IsJSValid( jsNum ) ) return "js" + jsNum.ToString( );
return JsUnknown;
}
@ -200,8 +212,7 @@ namespace SCJMapper_V2
/// <summary>
/// Returns an adjusted jsN_ tag with the new number
/// AC 1.1 can be something as "rctrl+js2_nn"
/// Returns an adjusted jsN tag with the new number
/// </summary>
/// <param name="input">An input directive</param>
/// <param name="newJsN">the new JsN number</param>
@ -209,13 +220,8 @@ namespace SCJMapper_V2
static public String ReassignJSTag( String input, int newJsN )
{
// find jsN start
int jsPos = input.IndexOf( "+js" );
String inputValidateJsN = input;
if ( jsPos > 0 ) {
inputValidateJsN = input.Substring( jsPos + 1, 5 );
}
if ( IsJsN( inputValidateJsN ) ) {
return input.Replace( input.Substring( jsPos + 1, 4 ), JSTag( newJsN ) ); // jsPos=-1 + 1 => 0 (case of no modifier)
if ( IsJsN( input ) ) {
return input.Replace( input.Substring( 0, 3 ), JSTag( newJsN ) ); // jsPos=-1 + 1 => 0 (case of no modifier)
}
else {
return input;

@ -276,7 +276,7 @@ namespace SCJMapper_V2
public String JsName
{
get { return JoystickCls.JSTag(m_jsAssignment); }
get { return JoystickCls.JSTag(m_jsAssignment) + "_"; }
}
#endregion

@ -20,12 +20,12 @@ namespace SCJMapper_V2
#region Static Items
public new const String DeviceClass = "keyboard"; // the device name used throughout this app
public const String DeviceTag = "kb1_";
public new const String DeviceID = "kb1_";
static public int RegisteredDevices = 0; // devices add here once they are created (though will not decrement as they are not deleted)
public const String ClearMods = "escape";
public new const String BlendedInput = DeviceTag + DeviceCls.BlendedInput;
public new const String BlendedInput = DeviceID + DeviceCls.BlendedInput;
static public new Boolean IsBlendedInput ( String input )
{
if ( input == BlendedInput ) return true;
@ -53,29 +53,27 @@ namespace SCJMapper_V2
}
/// <summary>
/// Return this deviceClass if the input string contains something like kbN_
/// Return this deviceClass if the input string starts with kb1_
/// </summary>
/// <param name="input"></param>
/// <param name="devInput"></param>
/// <returns></returns>
static public new String DeviceClassFromInput( String input )
static public new String DeviceClassFromInput( String devInput )
{
if ( IsKbN( input ) )
if ( DevMatch( devInput ) )
return DeviceClass; // this
else
return DeviceCls.DeviceClass; // unknown
}
const string kbN_pattern = @"^*kb[1..9]_*";
static Regex rgx_kbN = new Regex( kbN_pattern, RegexOptions.IgnoreCase );
/// <summary>
/// Returns true if the input starts with a valid kbN_ formatting (TODO what kind of kbd modifiers here?)
/// Returns true if the input matches this device
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
static public Boolean IsKbN( String input )
/// <param name="devInput">A devInput string</param>
/// <returns>True for a match</returns>
static public new Boolean DevMatch( String devInput )
{
return rgx_kbN.IsMatch( input );
return devInput.StartsWith( DeviceID );
}
@ -89,6 +87,8 @@ namespace SCJMapper_V2
// input is something like a letter or a composition like lctrl+c
// try easy: add kb1_ at the beginning and before any +; first remove spaces
String retVal = input.Replace(" ","");
if ( IsBlendedInput( input ) ) return input;
int plPos = retVal.IndexOf("+");
while (plPos>0) {
retVal.Insert( plPos + 1, "kb1_" );

@ -23,10 +23,10 @@ namespace SCJMapper_V2
#region Static Items
public new const String DeviceClass = "mouse"; // the device name used throughout this app
public const String DeviceTag = "mo1_";
public new const String DeviceID = "mo1_";
static public int RegisteredDevices = 0; // devices add here once they are created (though will not decrement as they are not deleted)
public new const String BlendedInput = DeviceTag + DeviceCls.BlendedInput;
public new const String BlendedInput = DeviceID + DeviceCls.BlendedInput;
static public new Boolean IsBlendedInput( String input )
{
if ( input == BlendedInput ) return true;
@ -55,31 +55,29 @@ namespace SCJMapper_V2
}
/// <summary>
/// Return this deviceClass if the input string contains something like moN_
/// Return this deviceClass if the input string starts with mo1_
/// </summary>
/// <param name="input"></param>
/// <param name="devInput"></param>
/// <returns></returns>
static public new String DeviceClassFromInput( String input )
static public new String DeviceClassFromInput( String devInput )
{
if ( IsMoN( input ) )
if ( DevMatch( devInput ) )
return DeviceClass; // this
else
return DeviceCls.DeviceClass; // unknown
}
const string moN_pattern = @"^*mo[1..9]_*";
static Regex rgx_moN = new Regex( moN_pattern, RegexOptions.IgnoreCase );
/// <summary>
/// Returns true if the input starts with a valid kbN_ formatting (TODO what kind of kbd modifiers here?)
/// Returns true if the input matches this device
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
static public Boolean IsMoN( String input )
/// <param name="devInput">A devInput string</param>
/// <returns>True for a match</returns>
static public new Boolean DevMatch( String devInput )
{
return rgx_moN.IsMatch( input );
return devInput.StartsWith( DeviceID );
}
/// <summary>
/// Reformat the input from AC1 style to AC2 style
/// </summary>
@ -90,6 +88,8 @@ namespace SCJMapper_V2
// input is something like a mouse1 (TODO compositions like lctrl+mouse1 ??)
// try easy: add mo1_ at the beginning
String retVal = input.Replace(" ","");
if ( IsBlendedInput( input ) ) return input;
return "mo1_" + retVal;
}
@ -102,7 +102,7 @@ namespace SCJMapper_V2
/// <returns></returns>
static public String MakeCtrl( String input, String modifiers )
{
return DeviceTag + modifiers + input;
return DeviceID + modifiers + input;
}
#endregion

@ -85,7 +85,7 @@ namespace SCJMapper_V2
/// retrieves the attributes and collects the various control=binding pairs
/// </summary>
/// <param name="xr">An XML reader @ StartElement</param>
private void CollectActions( XmlReader xr, Dictionary<string, string> attr )
private void CollectActions( Dictionary<string, string> attr )
{
// we collect actions for each input ie for K,J,X and P
if ( attr.ContainsKey( "joystick" ) ) {
@ -93,46 +93,62 @@ namespace SCJMapper_V2
ac.name = attr["name"];
ac.devID = "J";
ac.defBinding = attr["joystick"];
if ( ac.defBinding == " " ) ac.defBinding = JoystickCls.BlendedInput;
if ( !String.IsNullOrEmpty( ac.defBinding ) ) {
if ( !ac.defBinding.StartsWith( "js1_" ) && !ac.defBinding.StartsWith( "jsx_" ) ) ac.defBinding = "js1_" + ac.defBinding; // fix AC 1.3
if ( ac.defBinding == " " ) {
ac.defBinding = JoystickCls.BlendedInput;
m_currentMap.Add( ac ); // finally add it to the current map if it was bound
}
else if ( !String.IsNullOrEmpty( ac.defBinding ) ) {
ac.defBinding = "js1_" + ac.defBinding;
m_currentMap.Add( ac ); // finally add it to the current map if it was bound
}
}
if ( attr.ContainsKey( "keyboard" ) ) {
Action ac = new Action( );
ac.name = attr["name"];
ac.devID = "K";
ac.defBinding = attr["keyboard"];
if ( ac.defBinding == " " ) ac.defBinding = KeyboardCls.BlendedInput;
if ( !String.IsNullOrEmpty( ac.defBinding ) ) m_currentMap.Add( ac ); // finally add it to the current map if it was bound
if ( ac.defBinding == " " ) {
ac.defBinding = KeyboardCls.BlendedInput;
m_currentMap.Add( ac ); // finally add it to the current map if it was bound
}
else if ( !String.IsNullOrEmpty( ac.defBinding ) ) {
ac.defBinding = "kb1_" + ac.defBinding;
m_currentMap.Add( ac ); // finally add it to the current map if it was bound
}
}
if ( attr.ContainsKey( "mouse" ) ) { // 20151220BM: add mouse device (from AC 2.0 defaultProfile usage)
Action ac = new Action( );
ac.name = attr["name"];
ac.devID = "M";
ac.defBinding = attr["mouse"];
if ( ac.defBinding == " " ) ac.defBinding = MouseCls.BlendedInput;
if ( !String.IsNullOrEmpty( ac.defBinding ) ) m_currentMap.Add( ac ); // finally add it to the current map if it was bound
if ( ac.defBinding == " " ) {
ac.defBinding = MouseCls.BlendedInput;
m_currentMap.Add( ac ); // finally add it to the current map if it was bound
}
else if ( !String.IsNullOrEmpty( ac.defBinding ) ) {
ac.defBinding = "mo1_" + ac.defBinding;
m_currentMap.Add( ac ); // finally add it to the current map if it was bound
}
}
if ( attr.ContainsKey( "xboxpad" ) ) {
Action ac = new Action( );
ac.name = attr["name"];
ac.devID = "X";
ac.defBinding = attr["xboxpad"];
if ( ac.defBinding == " " ) ac.defBinding = GamepadCls.BlendedInput;
if ( !String.IsNullOrEmpty( ac.defBinding ) ) {
if ( !ac.defBinding.StartsWith( "xi_" ) ) ac.defBinding = "xi_" + ac.defBinding; // fix AC 1.3
if ( ac.defBinding == " " ) {
ac.defBinding = GamepadCls.BlendedInput;
m_currentMap.Add( ac ); // finally add it to the current map if it was bound
}
else if ( !String.IsNullOrEmpty( ac.defBinding ) ) {
ac.defBinding = "xi1_" + ac.defBinding;
m_currentMap.Add( ac ); // finally add it to the current map if it was bound
}
}
if ( attr.ContainsKey( "ps3pad" ) ) {
Action ac = new Action( );
ac.name = attr["name"];
ac.devID = "P";
ac.defBinding = attr["ps3pad"];
if ( ac.defBinding == " " ) ac.defBinding = GamepadCls.BlendedInput;
if ( !String.IsNullOrEmpty( ac.defBinding ) ) m_currentMap.Add( ac ); // finally add it to the current map if it was bound
// ignore
}
}
@ -160,7 +176,7 @@ namespace SCJMapper_V2
// processing a valid action map - collect actions
if ( eName.ToLower( ) == "action" ) {
// this is an action.. - collect it
CollectActions( xr, attr );
CollectActions( attr );
}
}// if inmap
//Console.Write( ">\n" );
@ -198,32 +214,29 @@ namespace SCJMapper_V2
xr.Read( ); // get next element
Dictionary<String, String> attr = new Dictionary<string, string>( );
String eName = xr.Name;
// read attributes if any
while ( xr.MoveToNextAttribute( ) ) {
attr.Add( xr.Name, xr.Value ); // save the attributes
//Console.Write( " {0}='{1}'", xr.Name, xr.Value );
}
xr.MoveToElement( ); // backup
Action ac = new Action( );
ac.name = actionName;
// the element name is a control
if ( xr.NodeType == XmlNodeType.EndElement ) {
done = ( xr.Name == "action" );
done = ( xr.Name == m_nodeNameStack.Peek() ); // EXIT if the end element matches the entry
}
else if ( xr.IsEmptyElement ) {
// an attribute only element
ac.devID = ActionCls.DevID( eName );
ac.defBinding = attr["input"];
if ( !String.IsNullOrEmpty( ac.defBinding ) ) m_currentMap.Add( ac ); // finally add it to the current map if it was bound
CollectActions( attr );
}
else {
// one with subelements again
xr.Read( );
ac.devID = ActionCls.DevID( eName );
ac.defBinding = xr["input"];
if ( !String.IsNullOrEmpty( ac.defBinding ) ) m_currentMap.Add( ac ); // finally add it to the current map if it was bound
m_nodeNameStack.Push( xr.Name ); // recursive .. push element name to terminate later
ReadActionSub( xr, actionName );
}
} while ( !done );
m_nodeNameStack.Pop( ); // action is finished
}
@ -269,7 +282,7 @@ namespace SCJMapper_V2
// processing a valid action map - collect actions
if ( eName.ToLower( ) == "action" ) {
// this is an action.. - collect it
CollectActions( xr, attr );
CollectActions( attr );
ReadActionSub( xr, attr["name"] ); // a non empty action element may have a sub element
}
}

@ -106,7 +106,7 @@ namespace SCJMapper_V2
{
String deviceClass = DeviceCls.DeviceClass;
deviceClass = JoystickCls.DeviceClassFromInput(input);
deviceClass = JoystickCls.DeviceClassFromInput( input );
if ( !DeviceCls.IsUndefined( deviceClass ) ) return deviceClass;
deviceClass = GamepadCls.DeviceClassFromInput( input );
if ( !DeviceCls.IsUndefined( deviceClass ) ) return deviceClass;
@ -124,7 +124,7 @@ namespace SCJMapper_V2
/// </summary>
/// <param name="input">The input command</param>
/// <returns>True if blended input</returns>
static public Boolean IsBlendedInput (String input )
static public Boolean IsBlendedInput( String input )
{
Boolean blendedInput = false;
@ -198,6 +198,7 @@ namespace SCJMapper_V2
newAc.name = this.name;
newAc.defBinding = this.defBinding;
// creates a copy of the list with reassigned jsN devs
foreach ( ActionCommandCls acc in inputList ) {
newAc.inputList.Add( acc.ReassignJsN( newJsList ) );
}
@ -210,20 +211,18 @@ namespace SCJMapper_V2
/// Created and adds the inputCommand list with given input string
/// AC2 style input is used i.e. with device tag in front
/// </summary>
/// <param name="input"></param>
/// <param name="devInput"></param>
/// <returns>Returns the ActionCommand created</returns>
public ActionCommandCls AddCommand( String input )
public ActionCommandCls AddCommand( String devInput )
{
ActionCommandCls acc = new ActionCommandCls( );
acc.input = input; acc.nodeIndex = inputList.Count - 1; // starts from -1 ...
inputList.Add( acc );
ActionCommandCls acc = new ActionCommandCls( devInput, inputList.Count - 1 ); // starts from -1 ...
inputList.Add( acc );
return acc;
}
public ActionCommandCls AddCommand( String input, int index )
public ActionCommandCls AddCommand( String devInput, int index )
{
ActionCommandCls acc = new ActionCommandCls( );
acc.input = input; acc.nodeIndex = index;
ActionCommandCls acc = new ActionCommandCls( devInput, index );
inputList.Add( acc );
return acc;
}
@ -233,14 +232,13 @@ namespace SCJMapper_V2
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 ( 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>
/// Merge action is simply copying the new input control
/// </summary>
@ -253,21 +251,75 @@ namespace SCJMapper_V2
}
}
/// <summary>
/// Updates an actionCommand with a new input (command)
/// </summary>
/// <param name="devInput">The input command</param>
/// <param name="actionCmd">The actionCommand to update</param>
public void UpdateCommandFromInput( String devInput, ActionCommandCls actionCmd )
{
//log.Debug( "UpdateCommandFromInput - Entry" );
if ( actionCmd == null ) return;
// Apply the input to the ActionTree
actionCmd.DevInput = BlendInput( devInput, this.actionDevice );
}
/// <summary>
/// Find an ActionCommand with input in an Action
/// </summary>
/// <param name="input">The input</param>
/// <returns>An actionCommand or null if not found</returns>
public ActionCommandCls FindActionInputObject( String devInput )
{
log.Debug( "FindActionInputObject - Entry" );
// Apply the input to the ActionTree
ActionCommandCls acc = null;
acc = this.inputList.Find( delegate ( ActionCommandCls _ACC ) { return _ACC.DevInput == devInput; } );
if ( acc == null ) {
log.Error( "FindActionInputObject - Action Input not found in Action" );
return null; // ERROR - Action Input not found in tree
}
return acc;
}
/// <summary>
/// Find an ActionCommand with index in an Action
/// </summary>
/// <param name="input">The input</param>
/// <returns>An actionCommand or null if not found</returns>
public ActionCommandCls FindActionInputObject( int index )
{
log.Debug( "FindActionInputObject - Entry" );
// Apply the input to the ActionTree
ActionCommandCls acc = null;
acc = this.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>
/// Dump the action as partial XML nicely formatted
/// </summary>
/// <returns>the action as XML fragment</returns>
public String toXML( )
{
String r = ""; String
String r = ""; String
bindCmd = "rebind";
if ( inputList.Count > 0 ) {
if ( !String.IsNullOrEmpty( inputList[0].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 ) ) {
if ( !String.IsNullOrEmpty( acc.Input ) ) {
// r += String.Format( "\t\t\t<{0} device=\"{1}\" {2}", bindCmd, device, acc.toXML( ) ); // OLD style
r += String.Format( "\t\t\t<{0} {1}", bindCmd, acc.toXML( actionDevice ) ); // 20151220BM: format for AC2 style
r += String.Format( "\t\t\t<{0} {1}", bindCmd, acc.toXML( ) ); // 20151220BM: format for AC2 style
bindCmd = "addbind"; // switch to addbind
}
}

@ -8,26 +8,104 @@ namespace SCJMapper_V2
/// <summary>
/// Maintains one ActionCommand
/// AC2 style input is used i.e. with device tag in front
/// commands are a built from as devID_input where ..
/// devID: jsN, mo1, xi1, kb1, thumbl_down and modified ones: ralt+button1 (modifier+deviceinput)
/// input: x, mouse1, r, and ~ as internal blend (defined in DeviceCls)
/// </summary>
public class ActionCommandCls
{
/// <summary>
/// The Input commands used incl. modifiers (mod+command)
/// </summary>
public String Input { get; set; } // AC2 style: input command name AC2 e.g. x, mouse1, r, "~" to blend
/// <summary>
/// The device ID of the device (jsN, mo1, kb1, xi1)
/// </summary>
public String DevID { get; set; } // the device ID (jsN, mo1, xi1, kb1)
/// <summary>
/// The complete input string (devID_input)
/// Assuming internally blended ones only (i.e. no space blends contained)
/// Can derive if a device tag is given
/// </summary>
public String DevInput {
get {
if ( string.IsNullOrEmpty( Input ) )
return Input; // no Input - return empty
else if ( string.IsNullOrEmpty( DevID ) )
return Input; // no devID - return input only
else
return String.Format( "{0}_{1}", DevID, Input ); // fully qualified only if both exist
}
set {
// decompose the deviceInput into parts
if ( string.IsNullOrEmpty( value ) ) { // no Input - insert input empty
Input = ""; // empty one
}
else if ( value.IndexOf("_") == 3 ) { // fully qualified only if both exist
DevID = value.Substring( 0, 3 );
Input = value.Substring( 4 );
}
else { // no device - insert input empty
// treat as input only
Input = value;
}
}
}
public String input { get; set; } // AC2 style: input command name AC2 e.g. js1_x, mo1_button1, kb1_r, "kb1_ " to blend
/// <summary>
/// The index of the visible child node (-1 -> shown in ActionNode)
/// </summary>
public int nodeIndex { get; set; } // index of the vis treenode
public int NodeIndex { get; set; } // index of the vis treenode
// ctor
public ActionCommandCls( )
{
input = "UNDEF";
nodeIndex = -1;
// init with something to debug if needed
Input = "UNDEF";
DevID = "NA0";
NodeIndex = -1;
}
// ctor
public ActionCommandCls( ActionCommandCls other )
{
Input = other.Input;
DevID = other.DevID;
NodeIndex = other.NodeIndex;
}
// ctor
public ActionCommandCls( String devInp )
{
DevInput = devInp;
NodeIndex = -1;
}
// ctor
public ActionCommandCls( String devInp, int nodeIx )
{
DevInput = devInp;
NodeIndex = nodeIx;
}
// ctor
public ActionCommandCls( String dev, String inp )
{
Input = inp;
DevID = dev;
NodeIndex = -1;
}
// ctor
public ActionCommandCls( String dev, String inp, int nodeIx )
{
Input = inp;
DevID = dev;
NodeIndex = nodeIx;
}
@ -38,16 +116,14 @@ namespace SCJMapper_V2
/// <returns>The action copy with reassigned input</returns>
public ActionCommandCls ReassignJsN( JsReassingList 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_" )
|| this.input.Contains( "js5_" ) || this.input.Contains( "js6_" ) || this.input.Contains( "js7_" ) || this.input.Contains( "js8_" ) ) {
int oldJsN = JoystickCls.JSNum( this.input );
ActionCommandCls newAc = new ActionCommandCls( this );
// reassign the jsX part for Joystick commands
if ( this.DevID.StartsWith( "js" ) ) {
int oldJsN = JoystickCls.JSNum( this.DevID );
if ( JoystickCls.IsJSValid( oldJsN ) ) {
if ( newJsList.ContainsOldJs( oldJsN ) ) newAc.input = JoystickCls.ReassignJSTag( this.input, newJsList.newJsFromOldJs(oldJsN) );
if ( newJsList.ContainsOldJs( oldJsN ) ) newAc.DevID = JoystickCls.ReassignJSTag( this.DevID, newJsList.newJsFromOldJs( oldJsN ) );
}
}
@ -59,15 +135,15 @@ namespace SCJMapper_V2
/// Dump the action as partial XML nicely formatted
/// </summary>
/// <returns>the action as XML fragment</returns>
public String toXML( ActionCls.ActionDevice aDev )
public String toXML( )
{
String r = "";
if ( String.IsNullOrEmpty( input ) ) {
if ( String.IsNullOrEmpty( Input ) ) {
r = String.Format( " />\n" ); // actually an ERROR...
}
else {
// regular - first get device dependend blending if needed then apply XML formatting to internally blended items
r = String.Format( "input=\"{0}\" />\n", DeviceCls.toXML( ActionCls.BlendInput( input, aDev ) ) );
// regular - apply XML formatting to internally blended items
r = String.Format( "input=\"{0}_{1}\" />\n", DevID, DeviceCls.toXML( Input ) );
}
return r;

@ -46,15 +46,6 @@ namespace SCJMapper_V2
/// </summary>
public Boolean Dirty { get; set; }
/// <summary>
/// Blend (insert jsx_reserved") into undmapped Joystick items
/// </summary>
public Boolean BlendUnmappedJS { get; set; }
/// <summary>
/// Blend (insert xi_reserved") into undmapped Gamepad items
/// </summary>
public Boolean BlendUnmappedGP { get; set; }
/// <summary>
/// a comma separated list of actionmaps to ignore
/// </summary>
@ -67,11 +58,8 @@ namespace SCJMapper_V2
/// <summary>
/// ctor
/// </summary>
public ActionTree( Boolean blendUnmappedJS, Boolean blendUnmappedGP, JoystickList jsList, GamepadCls gamepad )
public ActionTree( JoystickList jsList, GamepadCls gamepad )
{
BlendUnmappedJS = blendUnmappedJS;
BlendUnmappedGP = blendUnmappedGP;
m_jsList = jsList;
m_gamepad = gamepad;
@ -86,7 +74,7 @@ namespace SCJMapper_V2
/// <returns>The ActionTree Copy with reassigned input</returns>
public ActionTree ReassignJsN( JsReassingList newJsList )
{
ActionTree nTree = new ActionTree( BlendUnmappedJS, BlendUnmappedGP, m_jsList, m_gamepad );
ActionTree nTree = new ActionTree( m_jsList, m_gamepad );
// full copy from 'this'
nTree.m_MasterTree = this.m_MasterTree;
nTree.m_ctrl = this.m_ctrl;
@ -248,7 +236,7 @@ namespace SCJMapper_V2
private void UpdateDeviceInformation( )
{
// must get the jsN information used for Options Inverters
for ( int item=0; item < ( int )OptionsInvert.Inversions.I_LAST; item++ ) {
for ( int item = 0; item < ( int )OptionsInvert.Inversions.I_LAST; item++ ) {
ActionMaps.Options.Inverter( ( OptionsInvert.Inversions )item ).GameDevice = GetActionInstance( ( OptionsInvert.Inversions )item );
}
}
@ -442,17 +430,13 @@ namespace SCJMapper_V2
Array.Resize( ref cnl, 0 );
acm = new ActionMapCls( ); acm.name = elem[0]; // get actionmap name
// process items
for ( int ei=1; ei < elem.Length; ei += 2 ) { // step 2 - action;defaultBinding come in pairs
for ( int ei = 1; ei < elem.Length; ei += 2 ) { // step 2 - action;defaultBinding come in pairs
if ( !String.IsNullOrEmpty( elem[ei] ) ) {
// default assignments
String action = elem[ei].Substring( 1 );
String defBinding = elem[ei + 1].Substring( 0 );
String devID = elem[ei].Substring( 0, 1 );
String device = ActionCls.DeviceFromID( devID );
// Format for AC2 style inputs - reformat mouse/kbd
if ( KeyboardCls.IsDeviceClass( device ) ) defBinding = KeyboardCls.FromAC1( defBinding );
else if ( MouseCls.IsDeviceClass( device ) ) defBinding = MouseCls.FromAC1( defBinding );
else if ( GamepadCls.IsDeviceClass( device ) ) defBinding = GamepadCls.FromAC1( defBinding );
// 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..
@ -464,59 +448,46 @@ namespace SCJMapper_V2
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 ) {
// apply the default mappings
if ( ac.actionDevice == ActionCls.ActionDevice.AD_Joystick ) {
int jNum = JoystickCls.JSNum( ac.defBinding );
acc = ac.AddCommand( "" ); // profile items are shown in the ActionTreeNode (not in a child)
// init and apply the default mappings if requested
if ( ac.actionDevice == ActionCls.ActionDevice.AD_Joystick ) {
acc.DevID = JoystickCls.DeviceID;
int jNum = JoystickCls.JSNum( ac.defBinding );
if ( applyDefaults ) {
if ( JoystickCls.IsJSValid( jNum ) ) {
acc.input = ac.defBinding;
acc.DevInput = ac.defBinding;
cn.Command = ac.defBinding; cn.BackColor = JoystickCls.JsNColor( jNum );
}
else if ( BlendUnmappedJS ) {
// jsx_reserved gets here
acc.input = JoystickCls.BlendedInput;
cn.Command = JoystickCls.BlendedInput; cn.BackColor = MyColors.BlendedColor;
}
}
else if ( ac.actionDevice == ActionCls.ActionDevice.AD_Gamepad ) {
if ( GamepadCls.IsXiValid( ac.defBinding ) ) {
acc.input = ac.defBinding;
}
else if ( ac.actionDevice == ActionCls.ActionDevice.AD_Gamepad ) {
acc.DevID = GamepadCls.DeviceID;
if ( applyDefaults ) {
if ( !String.IsNullOrEmpty( ac.defBinding ) ) {
acc.DevInput = ac.defBinding;
cn.Command = ac.defBinding; cn.BackColor = GamepadCls.XiColor( );
}
else if ( BlendUnmappedGP ) {
// xi_reserved gets here
acc.input = GamepadCls.BlendedInput;
cn.Command = GamepadCls.BlendedInput; cn.BackColor = MyColors.BlendedColor;
}
}
else if ( ac.actionDevice == ActionCls.ActionDevice.AD_Keyboard ) {
}
else if ( ac.actionDevice == ActionCls.ActionDevice.AD_Keyboard ) {
acc.DevID = KeyboardCls.DeviceID;
if ( applyDefaults ) {
if ( !String.IsNullOrEmpty( ac.defBinding ) ) {
acc.input = ac.defBinding;
acc.DevInput = ac.defBinding;
cn.Command = ac.defBinding; cn.BackColor = KeyboardCls.KbdColor( );
}
}
else if ( ac.actionDevice == ActionCls.ActionDevice.AD_Mouse ) { // 20151220BM: add mouse device (from AC 2.0 defaultProfile usage)
}
else if ( ac.actionDevice == ActionCls.ActionDevice.AD_Mouse ) { // 20151220BM: add mouse device (from AC 2.0 defaultProfile usage)
acc.DevID = MouseCls.DeviceID;
if ( applyDefaults ) {
if ( !String.IsNullOrEmpty( ac.defBinding ) ) {
acc.input = ac.defBinding;
acc.DevInput = ac.defBinding;
cn.Command = ac.defBinding; cn.BackColor = MouseCls.MouseColor( );
}
}
}
// Don't apply defaults - but blend if checked
else {
if ( ( ac.actionDevice == ActionCls.ActionDevice.AD_Joystick ) && BlendUnmappedJS ) {
cn.Command = JoystickCls.BlendedInput; cn.BackColor = MyColors.BlendedColor;
acc.input = JoystickCls.BlendedInput;
}
else if ( ( ac.actionDevice == ActionCls.ActionDevice.AD_Gamepad ) && BlendUnmappedGP ) {
cn.Command = GamepadCls.BlendedInput; cn.BackColor = MyColors.BlendedColor;
acc.input = GamepadCls.BlendedInput;
}
}
}
}//for
@ -567,10 +538,11 @@ namespace SCJMapper_V2
if ( ac == null ) return false; // ERROR exit
if ( checkKind && ( ac.actionDevice != inKind ) ) return false; // ERROR exit
ActionCommandCls acc = FindActionInputObject( Ctrl.SelectedNode.Parent.Name, Ctrl.SelectedNode.Name, CommandFromNodeText( Ctrl.SelectedNode.Text ) );
ActionCommandCls acc = ac.FindActionInputObject( CommandFromNodeText( Ctrl.SelectedNode.Text ) );
if ( acc == null ) return false; // ERROR exit
UpdateActionCommandFromInput( input, acc, inKind );
UpdateNodeFromAction( ( ActionTreeNode )Ctrl.SelectedNode, acc, inKind );
ac.UpdateCommandFromInput( input, acc );
UpdateNodeFromAction( ( ActionTreeNode )Ctrl.SelectedNode, acc );
Dirty = true;
}
else if ( Ctrl.SelectedNode.Level == 2 ) {
// this is a child of an action with further commands
@ -579,10 +551,11 @@ namespace SCJMapper_V2
if ( ac == null ) return false; // ERROR exit
if ( checkKind && ( ac.actionDevice != inKind ) ) return false; // ERROR exit
ActionCommandCls acc = FindActionInputObject( ac, m_ctrl.SelectedNode.Index );
ActionCommandCls acc = ac.FindActionInputObject( m_ctrl.SelectedNode.Index );
if ( acc == null ) return false; // ERROR exit
UpdateActionCommandFromInput( input, acc, inKind );
ac.UpdateCommandFromInput( input, acc );
UpdateInputNodeFromAction( ( ActionTreeInputNode )Ctrl.SelectedNode, acc, inKind );
Dirty = true;
}
return true;
}
@ -592,16 +565,16 @@ namespace SCJMapper_V2
/// </summary>
/// <param name="actionMap">The actionmap name</param>
/// <param name="action">The action</param>
/// <param name="input">The input</param>
/// <param name="devInput">The input</param>
/// <returns>An actionCommand or null if not found</returns>
private ActionCommandCls FindActionInputObject( String actionMap, String action, String input )
private ActionCommandCls FindActionInputObject( String actionMap, String action, String devInput )
{
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 ( ACM != null ) ac = ACM.Find( delegate ( ActionCls _AC ) { return _AC.key == action; } );
if ( ac != null ) acc = ac.inputList.Find( delegate ( ActionCommandCls _ACC ) { return _ACC.DevInput == devInput; } );
if ( acc == null ) {
log.Error( "FindActionInputObject - Action Input not found in tree" );
return null; // ERROR - Action Input not found in tree
@ -622,8 +595,8 @@ namespace SCJMapper_V2
// 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 ( 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
@ -632,25 +605,6 @@ namespace SCJMapper_V2
}
/// <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>
@ -665,7 +619,7 @@ namespace SCJMapper_V2
// Apply the input to the ActionTree
ActionCls ac = 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 ( ACM != null ) ac = ACM.Find( delegate ( ActionCls _AC ) { return _AC.key == action; } );
if ( ac == null ) {
log.Error( "FindActionObject - Action Not found in tree" );
return null; // ERROR - Action Not found in tree
@ -674,31 +628,6 @@ namespace SCJMapper_V2
}
/// <summary>
/// Updates an actionCommand with a new input (command)
/// </summary>
/// <param name="input">The input command</param>
/// <param name="action">The action to containing the command</param>
/// <param name="actionCmd">The actionCommand to update</param>
private void UpdateActionCommandFromInput( String input, ActionCommandCls actionCmd, ActionCls.ActionDevice inKind )
{
//log.Debug( "UpdateActionCommandFromInput - Entry" );
if ( actionCmd == null ) return;
// Apply the input to the ActionTree
if ( String.IsNullOrEmpty( input ) ) {
// unmapped - handle the blended ones from setting
if ( ( inKind == ActionCls.ActionDevice.AD_Joystick ) && BlendUnmappedJS ) actionCmd.input = JoystickCls.BlendedInput;
else if ( ( inKind == ActionCls.ActionDevice.AD_Gamepad ) && BlendUnmappedGP ) actionCmd.input = GamepadCls.BlendedInput;
else actionCmd.input = "";
}
else {
// mapped ones
actionCmd.input = input;
}
Dirty = true;
}
/// <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
@ -707,7 +636,7 @@ namespace SCJMapper_V2
/// <param name="node">The TreeNode to update</param>
/// <param name="action">The action that carries the update</param>
/// <param name="inKind">The input device</param>
private void UpdateNodeFromAction( ActionTreeNode node, ActionCommandCls actionCmd, ActionCls.ActionDevice inKind )
private void UpdateNodeFromAction( ActionTreeNode node, ActionCommandCls actionCmd )
{
//log.Debug( "UpdateNodeFromAction - Entry" );
if ( actionCmd == null ) return;
@ -715,43 +644,30 @@ namespace SCJMapper_V2
// applies only to ActionTreeNode
if ( node.Level == 1 ) {
// input is either "" or a valid mapping or a blended mapping
if ( String.IsNullOrEmpty( actionCmd.input ) ) {
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 ( ( inKind == ActionCls.ActionDevice.AD_Keyboard ) && ( actionCmd.input == KeyboardCls.BlendedInput ) ) {
node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
}
else if ( ( inKind == ActionCls.ActionDevice.AD_Mouse ) && ( actionCmd.input == MouseCls.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 if ( actionCmd.Input == DeviceCls.BlendedInput ) {
node.Command = actionCmd.DevInput; node.BackColor = MyColors.BlendedColor;
}
else {
// mapped ( regular ones )
node.Command = actionCmd.input;
node.Command = actionCmd.DevInput;
// background is along the input
if ( inKind == ActionCls.ActionDevice.AD_Joystick ) {
int jNum = JoystickCls.JSNum( actionCmd.input );
if ( node.ActionDevice == ActionCls.ActionDevice.AD_Joystick ) {
int jNum = JoystickCls.JSNum( actionCmd.DevID );
node.BackColor = JoystickCls.JsNColor( jNum );
}
else if ( inKind == ActionCls.ActionDevice.AD_Gamepad ) {
else if ( node.ActionDevice == ActionCls.ActionDevice.AD_Gamepad ) {
node.BackColor = GamepadCls.XiColor( );
}
else if ( inKind == ActionCls.ActionDevice.AD_Keyboard ) {
else if ( node.ActionDevice == ActionCls.ActionDevice.AD_Keyboard ) {
node.BackColor = KeyboardCls.KbdColor( );
}
else if ( inKind == ActionCls.ActionDevice.AD_Mouse ) { // 20151220BM: add mouse device (from AC 2.0 defaultProfile usage)
else if ( node.ActionDevice == ActionCls.ActionDevice.AD_Mouse ) { // 20151220BM: add mouse device (from AC 2.0 defaultProfile usage)
node.BackColor = MouseCls.MouseColor( );
}
else {
@ -780,35 +696,22 @@ namespace SCJMapper_V2
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 ) ) {
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 ( ( inKind == ActionCls.ActionDevice.AD_Keyboard ) && ( actionCmd.input == KeyboardCls.BlendedInput ) ) {
node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
}
else if ( ( inKind == ActionCls.ActionDevice.AD_Mouse ) && ( actionCmd.input == MouseCls.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 if ( actionCmd.Input == DeviceCls.BlendedInput ) {
node.Command = actionCmd.DevInput; node.BackColor = MyColors.BlendedColor;
}
else {
// mapped ( regular ones )
node.Command = actionCmd.input;
node.Command = actionCmd.DevInput;
// background is along the input
if ( inKind == ActionCls.ActionDevice.AD_Joystick ) {
int jNum = JoystickCls.JSNum( actionCmd.input );
int jNum = JoystickCls.JSNum( actionCmd.DevID );
node.BackColor = JoystickCls.JsNColor( jNum );
}
else if ( inKind == ActionCls.ActionDevice.AD_Gamepad ) {
@ -865,17 +768,17 @@ namespace SCJMapper_V2
// refresh commands
foreach ( ActionCommandCls acc in ac.inputList ) {
try {
UpdateActionCommandFromInput( acc.input, acc, ac.actionDevice ); // this may apply (un)Blending if needed
ac.UpdateCommandFromInput( acc.DevInput, acc ); // this may apply (un)Blending if needed
// the first one goes into the node, further must be created if not existing
if ( first ) {
UpdateNodeFromAction( matn, acc, ac.actionDevice );
UpdateNodeFromAction( matn, acc );
matn.Nodes.Clear( ); // clear add childs - those don't persist from newly loaded actionmaps
first = false;
}
else {
// have to recreate the action child nodes
ActionTreeInputNode matin = new ActionTreeInputNode( "UNDEF" ); matin.ImageKey = "Add";
acc.nodeIndex = matin.Index; // assign visual reference
acc.NodeIndex = matin.Index; // assign visual reference
matn.Nodes.Add( matin ); // add to master tree
UpdateInputNodeFromAction( matin, acc, ac.actionDevice );
}
@ -883,7 +786,8 @@ namespace SCJMapper_V2
catch {
; // key not found
}
}
Dirty = true;
} // foreach
}
}
catch {
@ -1090,7 +994,7 @@ namespace SCJMapper_V2
String repList = "";
// JS assignments
for ( int i=0; i < JoystickCls.JSnum_MAX; i++ ) {
for ( int i = 0; i < JoystickCls.JSnum_MAX; i++ ) {
if ( !String.IsNullOrEmpty( ActionMaps.jsN[i] ) ) repList += String.Format( "** js{0} = {1}\n", i + 1, ActionMaps.jsN[i] );
}
// now the mapped actions
@ -1100,8 +1004,8 @@ namespace SCJMapper_V2
repList += rep;
foreach ( ActionCls ac in acm ) {
foreach ( ActionCommandCls acc in ac.inputList ) {
if ( !String.IsNullOrEmpty( acc.input ) && !( acc.input == JoystickCls.BlendedInput ) ) {
rep = String.Format( " {0} - {1} - ({2})\n", ac.name.PadRight( 35 ), acc.input.PadRight( 30 ), ac.device );
if ( !String.IsNullOrEmpty( acc.Input ) && !( acc.Input == DeviceCls.BlendedInput ) ) {
rep = String.Format( " {0} - {1} - {2}\n", ac.name.PadRight( 42 ), acc.DevID, acc.Input.PadRight( 30 ) );
repList += rep;
}
}

@ -189,11 +189,8 @@ namespace SCJMapper_V2
public Boolean IsMappedAction
{
get
{
return !( String.IsNullOrEmpty( m_command )
|| ( m_command == JoystickCls.BlendedInput )
|| ( m_command == GamepadCls.BlendedInput ) );
get {
return !( string.IsNullOrEmpty( m_command ) || ActionCls.IsBlendedInput( m_command ) );
}
}

Loading…
Cancel
Save