2014-11-16 23:36:17 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2018-07-15 18:28:38 +00:00
|
|
|
|
using System.Windows.Forms;
|
2014-11-16 23:36:17 +00:00
|
|
|
|
|
2017-12-23 23:22:30 +00:00
|
|
|
|
namespace SCJMapper_V2.Devices
|
2014-11-16 23:36:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Basic device as DXInput device
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract class DeviceCls
|
|
|
|
|
{
|
2017-01-11 23:13:48 +00:00
|
|
|
|
public const string DeviceClass ="UNDEF";
|
|
|
|
|
public const string DeviceID = "NA0_";
|
|
|
|
|
static public bool IsUndefined( string deviceClass )
|
2015-12-22 00:47:23 +00:00
|
|
|
|
{
|
|
|
|
|
return ( deviceClass == DeviceClass );
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 12:53:55 +00:00
|
|
|
|
public const string DisabledInput = "~"; // internal used only
|
|
|
|
|
static public bool IsDisabledInput( string input ) { return ( input == DisabledInput ); }
|
2015-12-22 00:47:23 +00:00
|
|
|
|
|
2015-12-22 21:30:57 +00:00
|
|
|
|
|
2017-01-11 23:13:48 +00:00
|
|
|
|
static public bool IsDeviceClass( string deviceClass ) { return false; }
|
|
|
|
|
static public string DeviceClassFromInput( string input ) { return DeviceClass; }
|
|
|
|
|
static public string DevInput( string input ) { return input; }
|
|
|
|
|
static public bool DevMatch( string devInput ) { return false; }
|
2014-11-16 23:36:17 +00:00
|
|
|
|
|
2018-01-03 23:05:35 +00:00
|
|
|
|
static public bool IsAxisCommand( string command ) { return false; }
|
|
|
|
|
|
2017-04-14 22:33:21 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Return the CIG instance number (which is the jsN number) - 1 based
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract int XmlInstance { get; } // holds the CIG instance to be used throughout
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The DeviceClass of this instance
|
|
|
|
|
/// </summary>
|
2017-01-11 23:13:48 +00:00
|
|
|
|
public abstract string DevClass { get; }
|
2017-04-14 22:33:21 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The DX ProductName property
|
|
|
|
|
/// </summary>
|
2017-01-11 23:13:48 +00:00
|
|
|
|
public abstract string DevName { get; }
|
2019-07-11 19:01:35 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The DX ProductGUID property
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract string DevGUID { get; }
|
2017-04-14 22:33:21 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The DX instance number of the object (from enum) - 0 based
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract int DevInstance { get; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The DX GUID of the device
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract string DevInstanceGUID { get; }
|
|
|
|
|
|
2018-07-15 18:28:38 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The TabPage associated with the device (GP and JS only)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public TabPage TabPage { get; set; } // added to handle hiding..
|
|
|
|
|
public bool Hidden { get; set; } // added to handle hiding..
|
|
|
|
|
|
2014-11-16 23:36:17 +00:00
|
|
|
|
public abstract System.Drawing.Color MapColor { get; }
|
2017-01-11 23:13:48 +00:00
|
|
|
|
public virtual List<string> AnalogCommands { get { return new List<string>( ); } } // just return an empty one if not implemented
|
2014-11-16 23:36:17 +00:00
|
|
|
|
|
2017-01-11 23:13:48 +00:00
|
|
|
|
public abstract bool Activated { get; set; }
|
2018-02-06 20:13:44 +00:00
|
|
|
|
public void Deactivate() { this.Activated = false; }
|
|
|
|
|
public void Activate() { this.Activated = true; }
|
|
|
|
|
|
|
|
|
|
private Stack<bool> m_activeState = new Stack<bool>( );
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// pushes the Activated state on a stack
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void PushActiveState()
|
|
|
|
|
{
|
|
|
|
|
m_activeState.Push( Activated );
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Pop the Activated state from stack
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void PopActiveState()
|
|
|
|
|
{
|
|
|
|
|
if ( m_activeState.Count > 0 )
|
|
|
|
|
Activated = m_activeState.Pop( );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-12-22 00:34:09 +00:00
|
|
|
|
public virtual void FinishDX( ) { }
|
|
|
|
|
public virtual void ApplySettings( ) { }
|
2014-11-16 23:36:17 +00:00
|
|
|
|
|
2018-02-06 20:13:44 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// returns the currently available input string
|
|
|
|
|
/// (does not retrieve new data but uses what was collected by GetData())
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>An input string or an empty string if no input is available</returns>
|
|
|
|
|
public abstract string GetCurrentInput( );
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Find the last change the user did on that device
|
|
|
|
|
/// either new or from persistence
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>An input string</returns>
|
2017-01-11 23:13:48 +00:00
|
|
|
|
public abstract string GetLastChange( );
|
2018-02-06 20:13:44 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the data for the requested input
|
|
|
|
|
/// Retrieves a new set of data from DX
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cmd">The input where the value is requested for</param>
|
|
|
|
|
/// <param name="data">The value for the input</param>
|
2017-01-11 23:13:48 +00:00
|
|
|
|
public abstract void GetCmdData( string cmd, out int data );
|
2018-02-06 20:13:44 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the input data from DX
|
|
|
|
|
/// </summary>
|
2014-11-16 23:36:17 +00:00
|
|
|
|
public abstract void GetData( );
|
2015-12-22 21:30:57 +00:00
|
|
|
|
|
2017-01-11 23:13:48 +00:00
|
|
|
|
static public string toXML( string blendedInput )
|
2015-12-22 21:30:57 +00:00
|
|
|
|
{
|
2017-12-26 12:53:55 +00:00
|
|
|
|
return blendedInput.Replace( DisabledInput, " " ); // must make spaces (tilde is for internal processing only)
|
2015-12-22 21:30:57 +00:00
|
|
|
|
}
|
2017-01-11 23:13:48 +00:00
|
|
|
|
static public string toXMLBlendExtension( string blendedInput )
|
2016-01-02 00:15:58 +00:00
|
|
|
|
{
|
2017-12-26 12:53:55 +00:00
|
|
|
|
return (IsDisabledInput(blendedInput) ? string.Format( "multiTap=\"1\"") : "" ); // blending needs to overwrite potential multitaps (2+)
|
2016-01-02 00:15:58 +00:00
|
|
|
|
}
|
2017-01-11 23:13:48 +00:00
|
|
|
|
static public string fromXML( string blendedInput )
|
2015-12-22 21:30:57 +00:00
|
|
|
|
{
|
2017-12-26 12:53:55 +00:00
|
|
|
|
return blendedInput.Replace( " ", DisabledInput ); // must make tilde (spaces is for external processing only)
|
2015-12-22 21:30:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-16 23:36:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|