fixed bugs in deadzone handling, addbind command reading, config file read,

default mapping handling when starting the app
Created 2.11 Build 44 BETA
pull/104/head v2.11beta
bm98 10 years ago
parent 3272d48513
commit e209baced6

@ -192,8 +192,8 @@ namespace SCJMapper_V2
String version = Application.ProductVersion; // get the version information
// BETA VERSION; TODO - comment out if not longer
lblTitle.Text += " - V " + version.Substring( 0, version.IndexOf( ".", version.IndexOf( "." ) + 1 ) ); // PRODUCTION
//lblTitle.Text += " - V " + version + " beta"; // BETA
//lblTitle.Text += " - V " + version.Substring( 0, version.IndexOf( ".", version.IndexOf( "." ) + 1 ) ); // PRODUCTION
lblTitle.Text += " - V " + version + " beta"; // BETA
log.InfoFormat( "Application Version: {0}", version.ToString( ) );
@ -223,7 +223,13 @@ namespace SCJMapper_V2
log.Debug( "Loading Other" );
txMappingName.Text = m_AppSettings.MyMappingName;
SetRebindField( txMappingName.Text );
foreach ( ToolStripDropDownItem d in tsDDbtMappings.DropDownItems ) {
if ( d.Text == txMappingName.Text ) {
tsDDbtMappings.Text = txMappingName.Text;
m_AppSettings.DefMappingName = txMappingName.Text; m_AppSettings.Save( ); // update if it exists
break;
}
}
// Init X things
log.Debug( "Loading DirectX" );
if ( !InitDirectInput( ) ) {
@ -237,7 +243,7 @@ namespace SCJMapper_V2
rtb.LoadFile( SCMappings.MappingFileName( txMappingName.Text ), RichTextBoxStreamType.PlainText );
InitActionTree( false );
Grab( );
m_AppSettings.MyMappingName = txMappingName.Text; // last used - persist
m_AppSettings.MyMappingName = txMappingName.Text; m_AppSettings.Save( );// last used - persist
txMappingName.BackColor = MyColors.SuccessColor;
}
else {
@ -575,7 +581,7 @@ namespace SCJMapper_V2
{
log.Debug( "Dump - Entry" );
rtb.Text = String.Format( "<!-- {0} - SC Joystick Mapping -->\n{1}", DateTime.Now, m_AT.toXML( ) );
rtb.Text = String.Format( "<!-- {0} - SC Joystick Mapping - {1} -->\n{2}", DateTime.Now, txMappingName.Text, m_AT.toXML( ) );
btDump.BackColor = btClear.BackColor; btDump.UseVisualStyleBackColor = btClear.UseVisualStyleBackColor; // neutral again
btGrab.BackColor = btClear.BackColor; btGrab.UseVisualStyleBackColor = btClear.UseVisualStyleBackColor; // neutral again
@ -961,7 +967,7 @@ namespace SCJMapper_V2
rtb.LoadFile( SCMappings.MappingFileName( txMappingName.Text ), RichTextBoxStreamType.PlainText );
InitActionTree( false );
Grab( );
m_AppSettings.MyMappingName = txMappingName.Text; // last used - persist
m_AppSettings.MyMappingName = txMappingName.Text; m_AppSettings.Save( );// last used - persist
txMappingName.BackColor = MyColors.SuccessColor;
}
else {
@ -985,7 +991,7 @@ namespace SCJMapper_V2
// get the new one into the list
LoadMappingDD( );
m_AppSettings.MyMappingName = txMappingName.Text; // last used - persist
m_AppSettings.MyMappingName = txMappingName.Text; m_AppSettings.Save( );// last used - persist
txMappingName.BackColor = MyColors.SuccessColor;
}
}
@ -1105,21 +1111,18 @@ namespace SCJMapper_V2
if ( nodeText.ToLowerInvariant( ).EndsWith( "_x" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotx" ) ) {
m_AT.ActionMaps.TuningY.GameDevice = dev;
m_AT.ActionMaps.TuningY.Action = nodeText;
m_AT.ActionMaps.DeadzoneX.GameDevice = dev;
m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneX;
JSCAL.YawTuning = m_AT.ActionMaps.TuningY;
}
else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) {
m_AT.ActionMaps.TuningY.GameDevice = dev;
m_AT.ActionMaps.TuningY.Action = nodeText;
m_AT.ActionMaps.DeadzoneY.GameDevice = dev;
m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneY;
JSCAL.YawTuning = m_AT.ActionMaps.TuningY;
}
else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) {
m_AT.ActionMaps.TuningY.GameDevice = dev;
m_AT.ActionMaps.TuningY.Action = nodeText;
m_AT.ActionMaps.DeadzoneZ.GameDevice = dev;
m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneZ;
JSCAL.YawTuning = m_AT.ActionMaps.TuningY;
}
@ -1127,7 +1130,6 @@ namespace SCJMapper_V2
else if ( nodeText.ToLowerInvariant( ).Contains( "_thumblx" ) || nodeText.ToLowerInvariant( ).Contains( "_thumbrx" ) ) {
m_AT.ActionMaps.TuningY.GameDevice = dev;
m_AT.ActionMaps.TuningY.Action = nodeText;
m_AT.ActionMaps.DeadzoneX.GameDevice = dev;
m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneX;
JSCAL.YawTuning = m_AT.ActionMaps.TuningY;
}
@ -1154,21 +1156,18 @@ namespace SCJMapper_V2
if ( nodeText.ToLowerInvariant( ).EndsWith( "_x" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotx" ) ) {
m_AT.ActionMaps.TuningP.GameDevice = dev;
m_AT.ActionMaps.TuningP.Action = nodeText;
m_AT.ActionMaps.DeadzoneX.GameDevice = dev;
m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneX;
JSCAL.PitchTuning = m_AT.ActionMaps.TuningP;
}
else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) {
m_AT.ActionMaps.TuningP.GameDevice = dev;
m_AT.ActionMaps.TuningP.Action = nodeText;
m_AT.ActionMaps.DeadzoneY.GameDevice = dev;
m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneY;
JSCAL.PitchTuning = m_AT.ActionMaps.TuningP;
}
else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) {
m_AT.ActionMaps.TuningP.GameDevice = dev;
m_AT.ActionMaps.TuningP.Action = nodeText;
m_AT.ActionMaps.DeadzoneZ.GameDevice = dev;
m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneZ;
JSCAL.PitchTuning = m_AT.ActionMaps.TuningP;
}
@ -1176,7 +1175,6 @@ namespace SCJMapper_V2
else if ( nodeText.ToLowerInvariant( ).Contains( "_thumbly" ) || nodeText.ToLowerInvariant( ).Contains( "_thumbry" ) ) {
m_AT.ActionMaps.TuningP.GameDevice = dev;
m_AT.ActionMaps.TuningP.Action = nodeText;
m_AT.ActionMaps.DeadzoneY.GameDevice = dev;
m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneY;
JSCAL.PitchTuning = m_AT.ActionMaps.TuningP;
}
@ -1196,21 +1194,18 @@ namespace SCJMapper_V2
if ( nodeText.ToLowerInvariant( ).EndsWith( "_x" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotx" ) ) {
m_AT.ActionMaps.TuningR.GameDevice = dev;
m_AT.ActionMaps.TuningR.Action = nodeText;
m_AT.ActionMaps.DeadzoneX.GameDevice = dev;
m_AT.ActionMaps.TuningR.Deadzone = m_AT.ActionMaps.DeadzoneX;
JSCAL.RollTuning = m_AT.ActionMaps.TuningR;
}
else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) {
m_AT.ActionMaps.TuningR.GameDevice = dev;
m_AT.ActionMaps.TuningR.Action = nodeText;
m_AT.ActionMaps.DeadzoneY.GameDevice = dev;
m_AT.ActionMaps.TuningR.Deadzone = m_AT.ActionMaps.DeadzoneY;
JSCAL.RollTuning = m_AT.ActionMaps.TuningR;
}
else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) {
m_AT.ActionMaps.TuningR.GameDevice = dev;
m_AT.ActionMaps.TuningR.Action = nodeText;
m_AT.ActionMaps.DeadzoneZ.GameDevice = dev;
m_AT.ActionMaps.TuningR.Deadzone = m_AT.ActionMaps.DeadzoneZ;
JSCAL.RollTuning = m_AT.ActionMaps.TuningR;
}

@ -10,16 +10,12 @@ namespace SCJMapper_V2
private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType );
private String m_cmdCtrl = ""; // x, y, rotz ...
private String m_type = ""; // joystick OR xboxpad
private int m_devInstanceNo = -1; // jsN - instance in XML
private String m_deviceName = "";
private String m_cmdCtrl = ""; // x, y, rotz ...
private bool m_deadzoneEnabled = false; // default
private String m_deadzone = "0.000";
private DeviceCls m_device = null;
public DeviceDeadzoneParameter( )
{
@ -27,30 +23,6 @@ namespace SCJMapper_V2
#region Properties
public DeviceCls GameDevice
{
get { return m_device; }
set
{
m_device = value;
m_type = "";
m_devInstanceNo = -1;
if ( JoystickCls.IsDeviceClass( m_device.DevClass ) ) {
m_type = m_device.DevClass;
m_devInstanceNo = ( m_device as JoystickCls ).JSAssignment;
}
else if ( GamepadCls.IsDeviceClass( m_device.DevClass ) ) {
m_type = m_device.DevClass;
m_devInstanceNo = 1; // supports ONE gamepad
}
}
}
public int DevInstanceNo
{
get { return m_devInstanceNo; }
}
public String DeviceName
{
@ -80,6 +52,7 @@ namespace SCJMapper_V2
#endregion
/// <summary>
/// Format an XML -deviceoptions- node from the tuning contents
/// </summary>

@ -94,7 +94,14 @@ namespace SCJMapper_V2
public DeviceDeadzoneParameter Deadzone
{
get { return m_deadzone; }
set { m_deadzone = value; }
set
{
m_deadzone = value;
if ( m_deadzone != null ) {
m_deadzone.DeviceName = DeviceName; // must know too
m_deadzone.CommandCtrl = CommandCtrl; // must know too
}
}
}
public bool SensitivityUsed
@ -111,7 +118,7 @@ namespace SCJMapper_V2
public bool InvertUsed
{
get { return ( m_cbInvert == null ) ? false : m_cbInvert.Checked; }
get { return ( m_cbInvert == null ) ? false : m_cbInvert.Checked; }
set { if ( m_cbInvert != null ) m_cbInvert.Checked = value; }
}
public CheckBox CBInvert
@ -152,7 +159,7 @@ namespace SCJMapper_V2
#endregion
// reset some defaults
public void Reset()
public void Reset( )
{
GameDevice = null;
Deadzone = null;

@ -156,17 +156,35 @@ namespace SCJMapper_V2
if ( input.ToLowerInvariant( ).EndsWith("x") ) {
if ( String.IsNullOrWhiteSpace( m_deadzoneX.CommandCtrl ) ) m_deadzoneX.CommandCtrl = input; // if no options have been given...
if ( String.IsNullOrWhiteSpace( m_deadzoneX.DeviceName ) ) m_deadzoneX.DeviceName = name; // if no devicename has been given...
m_deadzoneX.DeadzoneUsed = true; m_deadzoneX.Deadzone = deadzone;
float testF;
if ( float.TryParse( deadzone, out testF ) ) { // check for valid number in string
m_deadzoneX.DeadzoneUsed = true; m_deadzoneX.Deadzone = deadzone;
}
else {
m_deadzoneX.DeadzoneUsed = false; m_deadzoneX.Deadzone = "0.00";
}
}
else if ( input.ToLowerInvariant( ).EndsWith("y") ) {
if ( String.IsNullOrWhiteSpace( m_deadzoneY.CommandCtrl ) ) m_deadzoneY.CommandCtrl = input; // if no options have been given...
if ( String.IsNullOrWhiteSpace( m_deadzoneY.DeviceName ) ) m_deadzoneY.DeviceName = name; // if no devicename has been given...
float testF;
if ( float.TryParse( deadzone, out testF ) ) { // check for valid number in string
m_deadzoneY.DeadzoneUsed = true; m_deadzoneY.Deadzone = deadzone;
}
else {
m_deadzoneY.DeadzoneUsed = false; m_deadzoneY.Deadzone = "0.00";
}
}
else if ( input.ToLowerInvariant( ).EndsWith( "z" ) ) {
if ( String.IsNullOrWhiteSpace( m_deadzoneZ.CommandCtrl )) m_deadzoneZ.CommandCtrl=input; // if no options have been given...
if ( String.IsNullOrWhiteSpace( m_deadzoneZ.DeviceName ) ) m_deadzoneZ.DeviceName = name; // if no devicename has been given...
float testF;
if ( float.TryParse( deadzone, out testF ) ) { // check for valid number in string
m_deadzoneZ.DeadzoneUsed = true; m_deadzoneZ.Deadzone = deadzone;
}
else {
m_deadzoneZ.DeadzoneUsed = false; m_deadzoneZ.Deadzone = "0.00";
}
}
else {
//?? option node refers to unknown axis (not x,y,rotz)

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

@ -26,8 +26,8 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>43</ApplicationRevision>
<ApplicationVersion>2.10.0.%2a</ApplicationVersion>
<ApplicationRevision>44</ApplicationRevision>
<ApplicationVersion>2.11.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>

@ -130,6 +130,14 @@ namespace SCJMapper_V2
}
public ActionCommandCls AddCommand( String input )
{
ActionCommandCls acc = new ActionCommandCls( );
acc.input = input; acc.nodeIndex = inputList.Count - 1; // starts from -1 ...
inputList.Add( acc );
return acc;
}
public ActionCommandCls AddCommand( String input, int index )
{
ActionCommandCls acc = new ActionCommandCls( );
@ -215,12 +223,11 @@ namespace SCJMapper_V2
if ( reader.Name == "rebind" ) {
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
String input = reader["input"];
if ( ( input == JoystickCls.BlendedInput ) || ( input == GamepadCls.BlendedInput ) ) 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 );
AddCommand( input );
// advances the reader to the next node
reader.ReadStartElement( "rebind" );
}
@ -228,12 +235,11 @@ namespace SCJMapper_V2
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 );
String input = reader["input"];
if ( ( input == JoystickCls.BlendedInput ) || ( input == GamepadCls.BlendedInput ) ) 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
AddCommand( input );
// advances the reader to the next node
reader.ReadStartElement( "addbind" );
}

@ -670,7 +670,7 @@ namespace SCJMapper_V2
/// <param name="actionCmd">The actionCommand to update</param>
private void UpdateActionCommandFromInput( String input, ActionCommandCls actionCmd, ActionCls.ActionDevice inKind )
{
log.Debug( "UpdateActionCommandFromInput - Entry" );
//log.Debug( "UpdateActionCommandFromInput - Entry" );
if ( actionCmd == null ) return;
// Apply the input to the ActionTree
@ -697,7 +697,7 @@ namespace SCJMapper_V2
/// <param name="inKind">The input device</param>
private void UpdateNodeFromAction( ActionTreeNode node, ActionCommandCls actionCmd, ActionCls.ActionDevice inKind )
{
log.Debug( "UpdateNodeFromAction - Entry" );
//log.Debug( "UpdateNodeFromAction - Entry" );
if ( actionCmd == null ) return;
// applies only to ActionTreeNode

@ -99,7 +99,7 @@ namespace SCJMapper_V2
set
{
ActionTreeInputNode.DecompNodeText( value, out m_command );
base.Text = ActionTreeInputNode.ComposeNodeText( m_command );
base.Text = ActionTreeInputNode.ComposeNodeText( "$" + m_command ); // tag for the node processing
}
}
@ -110,7 +110,7 @@ namespace SCJMapper_V2
set
{
m_command = value;
base.Text = ActionTreeInputNode.ComposeNodeText( m_command );
Text = ActionTreeInputNode.ComposeNodeText( m_command ); // compose - later it will be decomposed again
}
}
/*

@ -21,6 +21,9 @@ namespace SCJMapper_V2
if ( String.IsNullOrEmpty( cmd ) ) {
return action;
}
else if ( String.IsNullOrEmpty( action ) ) {
return cmd;
}
else {
return action + " - " + cmd;
}
@ -43,6 +46,13 @@ namespace SCJMapper_V2
else if ( e.Length > 0 ) {
action = e[0].TrimEnd( );
cmd = "";
// consider if the single item is not an action but a command (from ActionTreeInputNode)
// it is then starting with the tag $ (that must be removed)
if ( action.StartsWith( "$" ) ) {
cmd = action.Substring( 1 );
action = "";
}
}
}

@ -33,6 +33,7 @@ namespace SCJMapper_V2
// initialization
_Properties = new ConfigurationPropertyCollection( );
_Properties.Add( _jsSenseLimit );
_Properties.Add( _gpSenseLimit );
_Properties.Add( _scActionmaps );
}

Loading…
Cancel
Save