2016-05-27 15:13:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define USE_DS_ACTIONMAPS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2014-06-22 12:31:57 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Xml;
|
2014-12-22 17:05:21 +00:00
|
|
|
|
using System.Windows.Forms;
|
2015-12-22 00:47:23 +00:00
|
|
|
|
using System.IO;
|
2016-05-27 15:13:24 +00:00
|
|
|
|
using System.Data;
|
|
|
|
|
|
|
|
|
|
using SCJMapper_V2.SC;
|
|
|
|
|
using SCJMapper_V2.Table;
|
|
|
|
|
using SCJMapper_V2.Keyboard;
|
|
|
|
|
using SCJMapper_V2.Mouse;
|
|
|
|
|
using SCJMapper_V2.Gamepad;
|
|
|
|
|
using SCJMapper_V2.Joystick;
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
|
|
|
|
|
namespace SCJMapper_V2
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Maintains the complete ActionMaps - something like:
|
|
|
|
|
///
|
2015-12-22 00:47:23 +00:00
|
|
|
|
/// <ActionMaps ActionMaps version="1" optionsVersion="2" rebindVersion="2" profileName="sdsd" > // AC2
|
2014-06-22 12:31:57 +00:00
|
|
|
|
/// <actionmap name="spaceship_view">
|
|
|
|
|
/// <action name="v_view_cycle_fwd">
|
|
|
|
|
/// <rebind device="joystick" input="js2_button2" />
|
|
|
|
|
/// </action>
|
|
|
|
|
/// ...
|
|
|
|
|
/// </actionmap>
|
|
|
|
|
/// </ActionMaps>
|
|
|
|
|
/// </summary>
|
|
|
|
|
class ActionMapsCls : List<ActionMapCls>
|
|
|
|
|
{
|
2014-07-05 20:46:58 +00:00
|
|
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType );
|
|
|
|
|
|
2014-09-19 23:07:53 +00:00
|
|
|
|
#region Static Part of ActionMaps
|
|
|
|
|
|
2014-08-02 20:28:13 +00:00
|
|
|
|
// actionmap names to gather (do we need them to be cofigurable ??)
|
2014-09-19 23:07:53 +00:00
|
|
|
|
public static String[] ActionMaps = { };
|
2016-12-23 15:13:09 +00:00
|
|
|
|
|
|
|
|
|
public static void LoadSupportedActionMaps( SCActionMapList aml )
|
2014-09-19 23:07:53 +00:00
|
|
|
|
{
|
|
|
|
|
// load actionmaps
|
2016-12-23 15:13:09 +00:00
|
|
|
|
ActionMaps = aml.ActionMaps;
|
2014-09-19 23:07:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Static Part of ActionMaps
|
2014-08-02 20:28:13 +00:00
|
|
|
|
|
2015-12-22 00:47:23 +00:00
|
|
|
|
private const String ACM_VERSION = "version=\"1\" optionsVersion=\"2\" rebindVersion=\"2\""; //AC2 the FIXED version
|
2014-12-22 00:34:09 +00:00
|
|
|
|
|
2014-09-19 23:07:53 +00:00
|
|
|
|
private String version { get; set; }
|
|
|
|
|
|
2014-10-26 22:11:57 +00:00
|
|
|
|
private JoystickList m_joystickList = null;
|
|
|
|
|
private UICustHeader m_uiCustHeader = null;
|
2016-07-01 15:57:58 +00:00
|
|
|
|
private Options m_options = null; // options are given per deviceClass and instance - it seems
|
2014-10-26 22:11:57 +00:00
|
|
|
|
private Deviceoptions m_deviceOptions = null;
|
2015-12-26 22:16:25 +00:00
|
|
|
|
private Modifiers m_modifiers = null;
|
2014-08-02 20:28:13 +00:00
|
|
|
|
|
2014-12-22 17:05:21 +00:00
|
|
|
|
private List<CheckBox> m_invertCB = null; // Options owns and handles all Inversions
|
2014-09-14 17:51:42 +00:00
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
// own additions for JS mapping - should not harm..
|
2014-09-14 17:51:42 +00:00
|
|
|
|
private String[] m_js;
|
|
|
|
|
private String[] m_GUIDs;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// get/set jsN assignment (use 0-based index i.e. js1 -> [0])
|
|
|
|
|
/// </summary>
|
|
|
|
|
public String[] jsN
|
|
|
|
|
{
|
|
|
|
|
get { return m_js; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// get/set jsN GUID assignment (use 0-based index i.e. js1GUID -> [0])
|
|
|
|
|
/// </summary>
|
|
|
|
|
public String[] jsNGUID
|
|
|
|
|
{
|
|
|
|
|
get { return m_GUIDs; }
|
|
|
|
|
}
|
2014-08-31 13:05:56 +00:00
|
|
|
|
|
2014-11-16 23:36:17 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Clears a read but not longer known entry
|
|
|
|
|
/// </summary>
|
2016-05-27 15:13:24 +00:00
|
|
|
|
public void Clear_jsEntry( int index )
|
2014-11-16 23:36:17 +00:00
|
|
|
|
{
|
|
|
|
|
m_js[index] = "";
|
|
|
|
|
m_GUIDs[index] = "";
|
|
|
|
|
}
|
2014-06-22 12:31:57 +00:00
|
|
|
|
|
2014-10-26 22:11:57 +00:00
|
|
|
|
// provide access to Tuning items of the Options obj to the owner
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the X-Tuning item
|
|
|
|
|
/// </summary>
|
2014-12-20 20:15:45 +00:00
|
|
|
|
public DeviceTuningParameter TuningP
|
2014-10-26 22:11:57 +00:00
|
|
|
|
{
|
2014-12-20 20:15:45 +00:00
|
|
|
|
get { return m_options.TuneP; }
|
2014-10-26 22:11:57 +00:00
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the Y-Tuning item
|
|
|
|
|
/// </summary>
|
2014-11-18 22:50:35 +00:00
|
|
|
|
public DeviceTuningParameter TuningY
|
2014-10-26 22:11:57 +00:00
|
|
|
|
{
|
|
|
|
|
get { return m_options.TuneY; }
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the Z-Tuning item
|
|
|
|
|
/// </summary>
|
2014-12-20 20:15:45 +00:00
|
|
|
|
public DeviceTuningParameter TuningR
|
2014-10-26 22:11:57 +00:00
|
|
|
|
{
|
2014-12-20 20:15:45 +00:00
|
|
|
|
get { return m_options.TuneR; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the X-Sensitivity item
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DeviceDeadzoneParameter DeadzoneX
|
|
|
|
|
{
|
|
|
|
|
get { return m_deviceOptions.DeadzoneX; }
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the Y-Sensitivity item
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DeviceDeadzoneParameter DeadzoneY
|
|
|
|
|
{
|
|
|
|
|
get { return m_deviceOptions.DeadzoneY; }
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the Z-Sensitivity item
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DeviceDeadzoneParameter DeadzoneZ
|
|
|
|
|
{
|
|
|
|
|
get { return m_deviceOptions.DeadzoneZ; }
|
2014-10-26 22:11:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-22 17:05:21 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the Options item
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Options Options
|
|
|
|
|
{
|
|
|
|
|
get { return m_options; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Assign the GUI Invert Checkboxes for further handling
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<CheckBox> InvertCheckList
|
|
|
|
|
{
|
2016-05-27 15:13:24 +00:00
|
|
|
|
set {
|
2014-12-22 17:05:21 +00:00
|
|
|
|
m_invertCB = value;
|
|
|
|
|
m_options.InvertCheckList = m_invertCB;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-26 22:16:25 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the assigned Modifiers
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Modifiers Modifiers
|
|
|
|
|
{
|
|
|
|
|
get { return m_modifiers; }
|
|
|
|
|
}
|
2014-10-26 22:11:57 +00:00
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// ctor
|
|
|
|
|
/// </summary>
|
2014-10-26 22:11:57 +00:00
|
|
|
|
public ActionMapsCls( JoystickList jsList )
|
2014-06-22 12:31:57 +00:00
|
|
|
|
{
|
2014-12-22 00:34:09 +00:00
|
|
|
|
version = ACM_VERSION;
|
2014-10-26 22:11:57 +00:00
|
|
|
|
m_joystickList = jsList; // have to save this for Reassign
|
2014-09-14 17:51:42 +00:00
|
|
|
|
|
|
|
|
|
// create the Joystick assignments
|
|
|
|
|
Array.Resize( ref m_js, JoystickCls.JSnum_MAX + 1 );
|
|
|
|
|
Array.Resize( ref m_GUIDs, JoystickCls.JSnum_MAX + 1 );
|
2016-05-27 15:13:24 +00:00
|
|
|
|
for ( int i = 0; i < JoystickCls.JSnum_MAX; i++ ) {
|
2014-09-14 17:51:42 +00:00
|
|
|
|
m_js[i] = ""; m_GUIDs[i] = "";
|
|
|
|
|
}
|
2014-09-19 23:07:53 +00:00
|
|
|
|
|
2014-12-22 17:05:21 +00:00
|
|
|
|
CreateNewOptions( );
|
|
|
|
|
|
2016-12-23 15:13:09 +00:00
|
|
|
|
//LoadSupportedActionMaps( ); // get them from config @@@@@@@@@
|
2014-12-22 17:05:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void CreateNewOptions( )
|
|
|
|
|
{
|
2014-10-26 22:11:57 +00:00
|
|
|
|
// create options objs
|
|
|
|
|
m_uiCustHeader = new UICustHeader( );
|
|
|
|
|
m_options = new Options( m_joystickList );
|
|
|
|
|
m_deviceOptions = new Deviceoptions( m_options );
|
2015-12-26 22:16:25 +00:00
|
|
|
|
m_modifiers = new Modifiers( );
|
2014-08-31 13:05:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Copy return all ActionMaps while reassigning the JsN Tag
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="newJsList">The JsN reassign list</param>
|
|
|
|
|
/// <returns>The ActionMaps copy with reassigned input</returns>
|
2015-01-01 19:40:01 +00:00
|
|
|
|
public ActionMapsCls ReassignJsN( JsReassingList newJsList )
|
2014-08-31 13:05:56 +00:00
|
|
|
|
{
|
2014-10-26 22:11:57 +00:00
|
|
|
|
ActionMapsCls newMaps = new ActionMapsCls( m_joystickList );
|
2014-08-31 13:05:56 +00:00
|
|
|
|
// full copy from 'this'
|
2014-09-19 23:07:53 +00:00
|
|
|
|
|
2014-10-26 22:11:57 +00:00
|
|
|
|
newMaps.m_uiCustHeader = this.m_uiCustHeader;
|
|
|
|
|
newMaps.m_deviceOptions = this.m_deviceOptions;
|
|
|
|
|
newMaps.m_options = this.m_options;
|
2015-12-26 22:16:25 +00:00
|
|
|
|
newMaps.m_modifiers = this.m_modifiers;
|
2014-09-19 23:07:53 +00:00
|
|
|
|
|
2016-05-27 15:13:24 +00:00
|
|
|
|
for ( int i = 0; i < JoystickCls.JSnum_MAX; i++ ) {
|
2014-09-19 23:07:53 +00:00
|
|
|
|
newMaps.jsN[i] = this.jsN[i]; newMaps.jsNGUID[i] = this.jsNGUID[i];
|
2014-09-14 17:51:42 +00:00
|
|
|
|
}
|
2014-08-31 13:05:56 +00:00
|
|
|
|
|
|
|
|
|
foreach ( ActionMapCls am in this ) {
|
|
|
|
|
newMaps.Add( am.ReassignJsN( newJsList ) );
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-18 22:50:35 +00:00
|
|
|
|
//m_options.ReassignJsN( newJsList );
|
2014-10-26 22:11:57 +00:00
|
|
|
|
|
2014-08-31 13:05:56 +00:00
|
|
|
|
return newMaps;
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Merge the given Map with this Map
|
|
|
|
|
/// new ones are ignored - we don't learn from XML input for the time beeing
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="newAcm"></param>
|
|
|
|
|
private void Merge( ActionMapCls newAcm )
|
|
|
|
|
{
|
2014-07-05 20:46:58 +00:00
|
|
|
|
log.Debug( "Merge - Entry" );
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
// do we find an actionmap like the new one in our list ?
|
|
|
|
|
ActionMapCls ACM = this.Find( delegate( ActionMapCls acm ) {
|
|
|
|
|
return acm.name == newAcm.name;
|
|
|
|
|
} );
|
|
|
|
|
if ( ACM == null ) {
|
|
|
|
|
; // this.Add( newAcm ); // no, add new
|
2016-05-27 15:13:24 +00:00
|
|
|
|
} else {
|
2014-06-22 12:31:57 +00:00
|
|
|
|
ACM.Merge( newAcm ); // yes, merge it
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-19 23:07:53 +00:00
|
|
|
|
|
2016-05-27 15:13:24 +00:00
|
|
|
|
#if USE_DS_ACTIONMAPS // see and (un)define on top of file to allow for editing the DataSet entities
|
|
|
|
|
|
|
|
|
|
public void toDataSet( DS_ActionMaps dsa )
|
|
|
|
|
{
|
|
|
|
|
dsa.Clear( );
|
|
|
|
|
if ( dsa.HasChanges( ) ) dsa.T_ActionMap.AcceptChanges( );
|
|
|
|
|
|
|
|
|
|
int AMcount = 1;
|
|
|
|
|
foreach ( ActionMapCls am in this ) {
|
|
|
|
|
DS_ActionMaps.T_ActionMapRow amr = dsa.T_ActionMap.NewT_ActionMapRow();
|
|
|
|
|
string amShown = DS_ActionMap.ActionMapShown(am.name, AMcount++);
|
|
|
|
|
|
|
|
|
|
amr.ID_ActionMap = amShown;
|
|
|
|
|
dsa.T_ActionMap.AddT_ActionMapRow( amr );
|
|
|
|
|
|
|
|
|
|
foreach ( ActionCls ac in am ) {
|
|
|
|
|
int ilIndex = 0;
|
|
|
|
|
while ( ac.inputList.Count > ilIndex ) {
|
|
|
|
|
DS_ActionMaps.T_ActionRow ar = dsa.T_Action.NewT_ActionRow();
|
|
|
|
|
ar.ID_Action = DS_ActionMap.ActionID( am.name, ac.key, ac.inputList[ilIndex].NodeIndex ); // make a unique key
|
|
|
|
|
ar.AddBind = ( ilIndex > 0 ); // all but the first are addbinds
|
|
|
|
|
ar.REF_ActionMap = amShown;
|
|
|
|
|
ar.ActionName = ac.name;
|
|
|
|
|
ar.Device = ac.device;
|
|
|
|
|
ar.Def_Binding = ac.defBinding;
|
|
|
|
|
ar.Def_Modifier = ac.defActivationMode.Name;
|
|
|
|
|
ar.Usr_Binding = ac.inputList[ilIndex].DevInput;
|
|
|
|
|
ar.Usr_Modifier = ac.inputList[ilIndex].ActivationMode.Name;
|
2016-12-25 16:10:55 +00:00
|
|
|
|
ar.Disabled = DeviceCls.IsBlendedInput( ac.inputList[ilIndex].Input );
|
2016-05-27 15:13:24 +00:00
|
|
|
|
dsa.T_Action.AddT_ActionRow( ar );
|
|
|
|
|
|
|
|
|
|
ilIndex++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}// each Action
|
|
|
|
|
}// each ActionMap
|
|
|
|
|
|
|
|
|
|
// finally
|
|
|
|
|
if ( dsa.HasChanges( ) )
|
|
|
|
|
dsa.AcceptChanges( );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateDataSet( DS_ActionMaps dsa, string actionID )
|
|
|
|
|
{
|
|
|
|
|
foreach ( ActionMapCls am in this ) {
|
|
|
|
|
DS_ActionMaps.T_ActionMapRow amr = dsa.T_ActionMap.NewT_ActionMapRow();
|
|
|
|
|
|
|
|
|
|
foreach ( ActionCls ac in am ) {
|
|
|
|
|
int ilIndex = 0;
|
|
|
|
|
while ( ac.inputList.Count > ilIndex ) {
|
|
|
|
|
if ( actionID == DS_ActionMap.ActionID( am.name, ac.key, ac.inputList[ilIndex].NodeIndex ) ) {
|
|
|
|
|
DS_ActionMaps.T_ActionRow ar =dsa.T_Action.FindByID_Action(actionID);
|
|
|
|
|
ar.Usr_Binding = ac.inputList[ilIndex].DevInput;
|
|
|
|
|
ar.Usr_Modifier = ac.inputList[ilIndex].ActivationMode.Name;
|
2016-12-25 16:10:55 +00:00
|
|
|
|
ar.Disabled = DeviceCls.IsBlendedInput( ac.inputList[ilIndex].Input );
|
2016-05-27 15:13:24 +00:00
|
|
|
|
ar.AcceptChanges( );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ilIndex++;
|
|
|
|
|
}
|
|
|
|
|
}// each Action
|
|
|
|
|
}// each ActionMap
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Dump the ActionMaps as partial XML nicely formatted
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>the action as XML fragment</returns>
|
2015-02-28 22:43:52 +00:00
|
|
|
|
public String toXML( String fileName )
|
2014-06-22 12:31:57 +00:00
|
|
|
|
{
|
2015-12-22 00:47:23 +00:00
|
|
|
|
log.Debug( "ActionMapsCls.toXML - Entry" );
|
2014-07-05 20:46:58 +00:00
|
|
|
|
|
2014-09-19 23:07:53 +00:00
|
|
|
|
AppSettings appSettings = new AppSettings( );
|
|
|
|
|
|
2015-12-22 00:47:23 +00:00
|
|
|
|
// *** HEADER
|
|
|
|
|
|
2014-09-19 23:07:53 +00:00
|
|
|
|
// handle the versioning of the actionmaps
|
2015-12-22 00:47:23 +00:00
|
|
|
|
// AC2 do not longer support ignoreversion... enter the new fixed header
|
|
|
|
|
String r = "<ActionMaps " + ACM_VERSION;
|
|
|
|
|
r += String.Format( " profileName=\"{0}\" \n", fileName.Replace( SCMappings.c_MapStartsWith, "" ) ); //AC2 add profilename
|
2014-09-19 23:07:53 +00:00
|
|
|
|
|
|
|
|
|
// now the devices (our addition)
|
2016-05-27 15:13:24 +00:00
|
|
|
|
for ( int i = 0; i < JoystickCls.JSnum_MAX; i++ ) {
|
2014-09-19 23:07:53 +00:00
|
|
|
|
if ( !String.IsNullOrEmpty( jsN[i] ) ) r += String.Format( "\tjs{0}=\"{1}\" ", i + 1, jsN[i] );
|
2014-09-14 17:51:42 +00:00
|
|
|
|
if ( !String.IsNullOrEmpty( jsNGUID[i] ) ) r += String.Format( "js{0}G=\"{1}\" \n", i + 1, jsNGUID[i] );
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-19 23:07:53 +00:00
|
|
|
|
// close the tag
|
2014-09-14 17:51:42 +00:00
|
|
|
|
r += String.Format( ">\n" );
|
2014-09-19 23:07:53 +00:00
|
|
|
|
|
2015-12-22 00:47:23 +00:00
|
|
|
|
|
|
|
|
|
// *** CustomisationUIHeader
|
|
|
|
|
|
|
|
|
|
// and dump the option contents - prepare with new data
|
2015-04-26 21:14:56 +00:00
|
|
|
|
m_uiCustHeader.ClearInstances( );
|
|
|
|
|
UICustHeader.DevRec dr = new UICustHeader.DevRec( );
|
2015-12-22 00:47:23 +00:00
|
|
|
|
dr.devType = KeyboardCls.DeviceClass; dr.instNo = 1; m_uiCustHeader.AddInstances( dr );
|
|
|
|
|
dr.devType = MouseCls.DeviceClass; dr.instNo = 1; m_uiCustHeader.AddInstances( dr );
|
|
|
|
|
// do we use Gamepad ??
|
2016-05-27 15:13:24 +00:00
|
|
|
|
if ( GamepadCls.RegisteredDevices > 0 ) {
|
2015-12-22 00:47:23 +00:00
|
|
|
|
dr.devType = GamepadCls.DeviceClass; dr.instNo = 1; m_uiCustHeader.AddInstances( dr );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// all Joysticks
|
2016-05-27 15:13:24 +00:00
|
|
|
|
for ( int i = 0; i < JoystickCls.JSnum_MAX; i++ ) {
|
2015-04-26 21:14:56 +00:00
|
|
|
|
if ( !String.IsNullOrEmpty( jsN[i] ) ) {
|
2015-12-22 00:47:23 +00:00
|
|
|
|
dr.devType = JoystickCls.DeviceClass; dr.instNo = i + 1; m_uiCustHeader.AddInstances( dr );
|
2015-02-28 22:43:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-26 21:14:56 +00:00
|
|
|
|
m_uiCustHeader.Label = fileName.Replace( SCMappings.c_MapStartsWith, "" ); // remove redundant part
|
|
|
|
|
r += m_uiCustHeader.toXML( ) + String.Format( "\n" );
|
|
|
|
|
|
2015-12-22 00:47:23 +00:00
|
|
|
|
// *** OPTIONS
|
2014-10-26 22:11:57 +00:00
|
|
|
|
if ( m_options.Count > 0 ) r += m_options.toXML( ) + String.Format( "\n" );
|
2015-12-22 00:47:23 +00:00
|
|
|
|
|
|
|
|
|
// *** DEVICE OPTIONS
|
2014-10-26 22:11:57 +00:00
|
|
|
|
if ( m_deviceOptions.Count > 0 ) r += m_deviceOptions.toXML( ) + String.Format( "\n" );
|
2014-09-19 23:07:53 +00:00
|
|
|
|
|
2015-12-26 22:16:25 +00:00
|
|
|
|
// *** MODIFIERS
|
|
|
|
|
if ( m_modifiers.Count > 0 ) r += m_modifiers.toXML( ) + String.Format( "\n" );
|
|
|
|
|
|
2015-12-22 00:47:23 +00:00
|
|
|
|
// *** ACTION MAPS
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
foreach ( ActionMapCls amc in this ) {
|
|
|
|
|
r += String.Format( "{0}\n", amc.toXML( ) );
|
|
|
|
|
}
|
|
|
|
|
r += String.Format( "</ActionMaps>\n" );
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Read an ActionMaps from XML - do some sanity check
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="xml">the XML action fragment</param>
|
|
|
|
|
/// <returns>True if an action was decoded</returns>
|
|
|
|
|
public Boolean fromXML( String xml )
|
|
|
|
|
{
|
2015-12-22 00:47:23 +00:00
|
|
|
|
log.Debug( "ActionMapsCls.fromXML - Entry" );
|
2014-07-05 20:46:58 +00:00
|
|
|
|
|
2014-12-22 17:05:21 +00:00
|
|
|
|
CreateNewOptions( ); // Reset those options...
|
|
|
|
|
m_options.InvertCheckList = m_invertCB;
|
|
|
|
|
m_options.ResetInverter( ); // have to reset when reading a new mapping
|
2014-10-26 22:11:57 +00:00
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
XmlReaderSettings settings = new XmlReaderSettings( );
|
|
|
|
|
settings.ConformanceLevel = ConformanceLevel.Fragment;
|
|
|
|
|
settings.IgnoreWhitespace = true;
|
|
|
|
|
settings.IgnoreComments = true;
|
|
|
|
|
XmlReader reader = XmlReader.Create( new StringReader( xml ), settings );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reader.Read( );
|
|
|
|
|
|
|
|
|
|
if ( reader.Name == "ActionMaps" ) {
|
|
|
|
|
if ( reader.HasAttributes ) {
|
|
|
|
|
version = reader["version"];
|
2014-12-22 00:34:09 +00:00
|
|
|
|
if ( version == "0" ) version = ACM_VERSION; // update from legacy to actual version
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
// get the joystick mapping if there is one
|
2016-05-27 15:13:24 +00:00
|
|
|
|
for ( int i = 0; i < JoystickCls.JSnum_MAX; i++ ) {
|
2014-09-14 17:51:42 +00:00
|
|
|
|
jsN[i] = reader[String.Format( "js{0}", i + 1 )];
|
|
|
|
|
jsNGUID[i] = reader[String.Format( "js{0}G", i + 1 )];
|
|
|
|
|
}
|
2016-05-27 15:13:24 +00:00
|
|
|
|
} else {
|
2014-06-22 12:31:57 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reader.Read( ); // move to next element
|
|
|
|
|
|
2014-09-19 23:07:53 +00:00
|
|
|
|
// could be actionmap OR (AC 0.9) deviceoptions OR options
|
|
|
|
|
|
|
|
|
|
while ( !reader.EOF ) { //!String.IsNullOrEmpty( x ) ) {
|
|
|
|
|
|
2016-05-27 15:13:24 +00:00
|
|
|
|
if ( reader.Name.ToLowerInvariant( ) == "actionmap" ) {
|
2014-09-19 23:07:53 +00:00
|
|
|
|
String x = reader.ReadOuterXml( );
|
|
|
|
|
ActionMapCls acm = new ActionMapCls( );
|
|
|
|
|
if ( acm.fromXML( x ) ) {
|
|
|
|
|
this.Merge( acm ); // merge list
|
|
|
|
|
}
|
2016-05-27 15:13:24 +00:00
|
|
|
|
} else if ( reader.Name.ToLowerInvariant( ) == "customisationuiheader" ) {
|
2014-09-19 23:07:53 +00:00
|
|
|
|
String x = reader.ReadOuterXml( );
|
2014-10-26 22:11:57 +00:00
|
|
|
|
m_uiCustHeader.fromXML( x );
|
2016-05-27 15:13:24 +00:00
|
|
|
|
} else if ( reader.Name.ToLowerInvariant( ) == "deviceoptions" ) {
|
2014-09-19 23:07:53 +00:00
|
|
|
|
String x = reader.ReadOuterXml( );
|
2014-10-26 22:11:57 +00:00
|
|
|
|
m_deviceOptions.fromXML( x );
|
2016-05-27 15:13:24 +00:00
|
|
|
|
} else if ( reader.Name.ToLowerInvariant( ) == "options" ) {
|
2014-09-19 23:07:53 +00:00
|
|
|
|
String x = reader.ReadOuterXml( );
|
2014-10-26 22:11:57 +00:00
|
|
|
|
m_options.fromXML( x );
|
2016-05-27 15:13:24 +00:00
|
|
|
|
} else if ( reader.Name.ToLowerInvariant( ) == "modifiers" ) {
|
2015-12-26 22:16:25 +00:00
|
|
|
|
String x = reader.ReadOuterXml( );
|
|
|
|
|
m_modifiers.fromXML( x );
|
2016-05-27 15:13:24 +00:00
|
|
|
|
} else {
|
2014-09-19 23:07:53 +00:00
|
|
|
|
reader.Read( );
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}
|
2014-10-26 22:11:57 +00:00
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-19 23:07:53 +00:00
|
|
|
|
|
|
|
|
|
|
2014-06-22 12:31:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|