diff --git a/ActivationModes.xlsx b/ActivationModes.xlsx deleted file mode 100644 index 9bb7c45..0000000 Binary files a/ActivationModes.xlsx and /dev/null differ diff --git a/AppSettings.cs b/AppSettings.cs index eaaf5c9..53a7380 100644 --- a/AppSettings.cs +++ b/AppSettings.cs @@ -320,6 +320,14 @@ namespace SCJMapper_V2 set { this["UseLanguage"] = value; } } + [UserScopedSetting( )] + [DefaultSettingValue( "False" )] + public bool ShowTreeTips + { + get { return (bool)this["ShowTreeTips"]; } + set { this["ShowTreeTips"] = value; } + } + //**** Form Table diff --git a/Devices/DeviceCls.cs b/Devices/DeviceCls.cs index 1354ee9..513d123 100644 --- a/Devices/DeviceCls.cs +++ b/Devices/DeviceCls.cs @@ -27,6 +27,8 @@ namespace SCJMapper_V2.Devices static public string DevInput( string input ) { return input; } static public bool DevMatch( string devInput ) { return false; } + static public bool IsAxisCommand( string command ) { return false; } + /// /// Return the CIG instance number (which is the jsN number) - 1 based /// diff --git a/Devices/Gamepad/GamepadCls.cs b/Devices/Gamepad/GamepadCls.cs index 6de2a9c..7ee2822 100644 --- a/Devices/Gamepad/GamepadCls.cs +++ b/Devices/Gamepad/GamepadCls.cs @@ -92,6 +92,18 @@ namespace SCJMapper_V2.Devices.Gamepad return devInput.StartsWith( DeviceID ); } + /// + /// Returns true if a command is an axis command + /// + /// The command string + /// True if it is an axis command + static public new bool IsAxisCommand( string command ) + { + string cLower = command.ToLowerInvariant( ); + return ( cLower.EndsWith( "_thumblx" ) || cLower.EndsWith( "_thumbly" ) + || cLower.EndsWith( "_thumbrx" ) || cLower.EndsWith( "_thumbry" ) ); + } + const string xil_pattern = @"^xi_thumb[lr][xy]$"; static Regex rgx_xil = new Regex( xil_pattern, RegexOptions.IgnoreCase ); diff --git a/Devices/Joystick/JoystickCls.cs b/Devices/Joystick/JoystickCls.cs index b79fa21..e7f8cca 100644 --- a/Devices/Joystick/JoystickCls.cs +++ b/Devices/Joystick/JoystickCls.cs @@ -112,6 +112,23 @@ namespace SCJMapper_V2.Devices.Joystick return IsJsN( devInput ); } + /// + /// Returns true if a command is an axis command + /// + /// The command string + /// True if it is an axis command + static public new bool IsAxisCommand( string command ) + { + string cLower = command.ToLowerInvariant( ); + if ( IsJsN( command ) ) + return ( cLower.EndsWith( "_x" ) || cLower.EndsWith( "_rotx" ) || cLower.EndsWith( "_throttlex" ) + || cLower.EndsWith( "_y" ) || cLower.EndsWith( "_roty" ) || cLower.EndsWith( "_throttley" ) + || cLower.EndsWith( "_Z" ) || cLower.EndsWith( "_rotz" ) || cLower.EndsWith( "_throttlez" ) + || cLower.EndsWith( "_slider1" ) || cLower.EndsWith( "_slider2" ) ); + else + return false; + } + /// /// Returns the jsN part from a joystick command @@ -139,9 +156,6 @@ namespace SCJMapper_V2.Devices.Joystick return sAction; } - - - /// /// Returns properly formatted jsn_ string (jsx_ if the input is UNKNOWN) /// @@ -153,7 +167,6 @@ namespace SCJMapper_V2.Devices.Joystick return JsUnknown; } - /// /// Extract the JS number from a JS string (jsx_ returns 0 - UNKNOWN) /// AC 1.1 can be something as "rctrl+js2_nn" @@ -172,13 +185,15 @@ namespace SCJMapper_V2.Devices.Joystick retNum = JSnum_UNKNOWN; // neither double nor single digit found } } - } else if ( jsTag.StartsWith( "js" ) ) { + } + else if ( jsTag.StartsWith( "js" ) ) { if ( !int.TryParse( ( jsTag + "XX" ).Substring( 2, 2 ), out retNum ) ) { // cheap .. test for double digits ( have to extend the string to parse) if ( !int.TryParse( jsTag.Substring( 2, 1 ), out retNum ) ) { // now for only single ones retNum = JSnum_UNKNOWN; // neither double nor single digit found } } - } else { + } + else { retNum = JSnum_UNKNOWN; // neither double nor single digit found } } @@ -223,11 +238,13 @@ namespace SCJMapper_V2.Devices.Joystick int inJsN = JSNum( input ); if ( inJsN < 10 ) { return input.Replace( input.Substring( 0, 3 ), JSTag( newJsN ) ); - } else { + } + else { // 2 digit input JsN return input.Replace( input.Substring( 0, 4 ), JSTag( newJsN ) ); } - } else { + } + else { return input; } } @@ -255,7 +272,8 @@ namespace SCJMapper_V2.Devices.Joystick int inJsN = JSNum( control ); if ( inJsN < 10 ) { retVal = retVal.Insert( 4, "throttle" ); - } else { + } + else { // 2 digit input JsN retVal = retVal.Insert( 5, "throttle" ); } @@ -316,7 +334,7 @@ namespace SCJMapper_V2.Devices.Joystick private bool[] m_modifierButtons; private UC_JoyPanel m_jPanel = null; // the GUI panel - internal int MyTabPageIndex = -1; + internal int MyTabPageIndex = -1; /// /// Returns a CryEngine compatible hat direction @@ -382,7 +400,7 @@ namespace SCJMapper_V2.Devices.Joystick public override List AnalogCommands { get { - List cmds = new List(); + List cmds = new List( ); try { // Enumerate all the objects on the device. @@ -406,7 +424,8 @@ namespace SCJMapper_V2.Devices.Joystick } } } - } catch ( Exception ex ) { + } + catch ( Exception ex ) { log.Error( "AnalogCommands - Get JS Objects failed", ex ); } cmds.Sort( ); @@ -445,7 +464,7 @@ namespace SCJMapper_V2.Devices.Joystick m_device = device; m_hwnd = hwnd; m_joystickNumber = joystickNum; // this remains fixed - m_xmlInstance = joystickNum+1; // initial assignment (is 1 based..) + m_xmlInstance = joystickNum + 1; // initial assignment (is 1 based..) m_jPanel = panel; MyTabPageIndex = tabIndex; Activated_low = false; @@ -484,7 +503,8 @@ namespace SCJMapper_V2.Devices.Joystick // Update the controls to reflect what objects the device supports. UpdateControls( d ); } - } catch ( Exception ex ) { + } + catch ( Exception ex ) { log.Error( "Get JS Objects failed", ex ); } @@ -499,7 +519,7 @@ namespace SCJMapper_V2.Devices.Joystick /// /// Shutdown device access /// - public override void FinishDX( ) + public override void FinishDX() { if ( null != m_device ) { log.DebugFormat( "Release DirectInput device: {0}", m_device.Information.ProductName ); @@ -517,7 +537,7 @@ namespace SCJMapper_V2.Devices.Joystick ApplySettings_low( ); } - private void ApplySettings_low( ) + private void ApplySettings_low() { AppSettings.Instance.Reload( ); @@ -571,7 +591,7 @@ namespace SCJMapper_V2.Devices.Joystick if ( !ValidModifier( modS ) ) return; // sanity.. // check if it is applicable - int jsn = JSNum(modS); + int jsn = JSNum( modS ); if ( jsn == m_joystickNumber ) { // format is jsN_buttonM i.e. get button number at the end int bNr = 0; @@ -656,7 +676,7 @@ namespace SCJMapper_V2.Devices.Joystick /// Find the last change the user did on that device /// /// The last action as CryEngine compatible string - public override string GetLastChange( ) + public override string GetLastChange() { int[] slider = m_state.Sliders; int[] pslider = m_prevState.Sliders; @@ -740,7 +760,7 @@ namespace SCJMapper_V2.Devices.Joystick /// /// Show the current props in the GUI /// - private void UpdateUI( ) + private void UpdateUI() { // This function updated the UI with joystick state information. string strText = null; @@ -793,18 +813,21 @@ namespace SCJMapper_V2.Devices.Joystick // Poll the device for info. try { m_device.Poll( ); - } catch ( SharpDXException e ) { + } + catch ( SharpDXException e ) { if ( ( e.ResultCode == ResultCode.NotAcquired ) || ( e.ResultCode == ResultCode.InputLost ) ) { // Check to see if either the app needs to acquire the device, or // if the app lost the device to another process. try { // Acquire the device. m_device.Acquire( ); - } catch ( SharpDXException ) { + } + catch ( SharpDXException ) { // Failed to acquire the device. This could be because the app doesn't have focus. return; // EXIT unaquired } - } else { + } + else { log.Error( "Unexpected Poll Exception", e ); return; // EXIT see ex code } @@ -851,18 +874,21 @@ namespace SCJMapper_V2.Devices.Joystick // Poll the device for info. try { m_device.Poll( ); - } catch ( SharpDXException e ) { + } + catch ( SharpDXException e ) { if ( ( e.ResultCode == ResultCode.NotAcquired ) || ( e.ResultCode == ResultCode.InputLost ) ) { // Check to see if either the app needs to acquire the device, or // if the app lost the device to another process. try { // Acquire the device. m_device.Acquire( ); - } catch ( SharpDXException ) { + } + catch ( SharpDXException ) { // Failed to acquire the device. This could be because the app doesn't have focus. return; // EXIT unaquired } - } else { + } + else { log.Error( "Unexpected Poll Exception", e ); return; // EXIT see ex code } @@ -880,8 +906,9 @@ namespace SCJMapper_V2.Devices.Joystick try { PropertyInfo axisProperty = typeof( JoystickState ).GetProperty( axies[cmd] ); - data = ( int )axisProperty.GetValue( this.m_state, null ); - } catch { + data = (int)axisProperty.GetValue( this.m_state, null ); + } + catch { data = 0; } } @@ -892,7 +919,7 @@ namespace SCJMapper_V2.Devices.Joystick /// /// Collect the current data from the device /// - public override void GetData( ) + public override void GetData() { // Make sure there is a valid device. if ( null == m_device ) @@ -901,18 +928,21 @@ namespace SCJMapper_V2.Devices.Joystick // Poll the device for info. try { m_device.Poll( ); - } catch ( SharpDXException e ) { + } + catch ( SharpDXException e ) { if ( ( e.ResultCode == ResultCode.NotAcquired ) || ( e.ResultCode == ResultCode.InputLost ) ) { // Check to see if either the app needs to acquire the device, or // if the app lost the device to another process. try { // Acquire the device - if the (main)window is active if ( Activated ) m_device.Acquire( ); - } catch ( SharpDXException ) { + } + catch ( SharpDXException ) { // Failed to acquire the device. This could be because the app doesn't have focus. return; // EXIT unaquired } - } else { + } + else { log.Error( "Unexpected Poll Exception", e ); return; // EXIT see ex code } diff --git a/Devices/Mouse/MouseCls.cs b/Devices/Mouse/MouseCls.cs index 8e59d89..7322ab2 100644 --- a/Devices/Mouse/MouseCls.cs +++ b/Devices/Mouse/MouseCls.cs @@ -39,7 +39,7 @@ namespace SCJMapper_V2.Devices.Mouse /// Returns the currently valid color /// /// A color - static public System.Drawing.Color MouseColor( ) + static public System.Drawing.Color MouseColor() { return MyColors.MouseColor; } @@ -91,6 +91,16 @@ namespace SCJMapper_V2.Devices.Mouse return devInput.StartsWith( DeviceID ); } + /// + /// Returns true if a command is an axis command + /// + /// The command string + /// True if it is an axis command + static public new bool IsAxisCommand( string command ) + { + string cLower = command.ToLowerInvariant( ); + return ( cLower.EndsWith( "_maxis_x" ) || cLower.EndsWith( "_maxis_y" ) ); + } /// /// Reformat the input from AC1 style to AC2 style @@ -101,7 +111,7 @@ namespace SCJMapper_V2.Devices.Mouse { // input is something like a mouse1 (TODO compositions like lctrl+mouse1 ??) // try easy: add mo1_ at the beginning - string retVal = input.Replace(" ",""); + string retVal = input.Replace( " ", "" ); if ( IsDisabledInput( input ) ) return input; return "mo1_" + retVal; @@ -146,7 +156,7 @@ namespace SCJMapper_V2.Devices.Mouse /// /// The JS ProductName property /// - public override string DevName { get { return m_device.Properties.ProductName; } } + public override string DevName { get { return "Mouse"; } } // no props in directX /// /// The JS Instance GUID for multiple device support (VJoy gets 2 of the same name) /// @@ -170,8 +180,7 @@ namespace SCJMapper_V2.Devices.Mouse private bool Activated_low { get { return m_activated; } - set - { + set { m_activated = value; if ( m_activated == false ) m_device.Unacquire( ); // explicitely if not longer active } @@ -214,11 +223,11 @@ namespace SCJMapper_V2.Devices.Mouse - public void Deactivate( ) + public void Deactivate() { this.Activated = false; } - public void Activate( ) + public void Activate() { this.Activated = true; } @@ -233,7 +242,7 @@ namespace SCJMapper_V2.Devices.Mouse /// Z-axis, typically a wheel. If the mouse does not have a z-axis, the value is 0. /// /// The last action as CryEngine compatible string - public override string GetLastChange( ) + public override string GetLastChange() { // TODO: Expand this out into a joystick class (see commit for details) Dictionary axies = new Dictionary( ) @@ -246,11 +255,11 @@ namespace SCJMapper_V2.Devices.Mouse foreach ( KeyValuePair entry in axies ) { PropertyInfo axisProperty = typeof( MouseState ).GetProperty( entry.Key ); - if ( DidAxisChange2( ( int )axisProperty.GetValue( this.m_state, null ), ( int )axisProperty.GetValue( this.m_prevState, null ), true ) ) { + if ( DidAxisChange2( (int)axisProperty.GetValue( this.m_state, null ), (int)axisProperty.GetValue( this.m_prevState, null ), true ) ) { this.m_lastItem = entry.Value; if ( entry.Key == "Z" ) this.m_lastItem += "down"; } - else if ( DidAxisChange2( ( int )axisProperty.GetValue( this.m_state, null ), ( int )axisProperty.GetValue( this.m_prevState, null ), false ) ) { + else if ( DidAxisChange2( (int)axisProperty.GetValue( this.m_state, null ), (int)axisProperty.GetValue( this.m_prevState, null ), false ) ) { this.m_lastItem = entry.Value; if ( entry.Key == "Z" ) this.m_lastItem += "up"; } @@ -290,21 +299,45 @@ namespace SCJMapper_V2.Devices.Mouse } - + System.Drawing.Rectangle m_targetRect = Screen.PrimaryScreen.Bounds; + /// + /// Fudge - must have a target rectangle to scale the mouse input into the target + /// + /// + public void SetTargetRectForCmdData( System.Drawing.Rectangle target ) + { + m_targetRect = target; + } /// - /// Collect the current data from the device (DUMMY for Mouse) + /// Collect the current data from the device (using WinForms.Cursor) /// public override void GetCmdData( string cmd, out int data ) { - // Make sure there is a valid device. - data = 0; + System.Drawing.Point cPt = Cursor.Position; + // somewhere on all screens + if ( m_targetRect.Contains( cPt ) ) { + cPt = cPt - new System.Drawing.Size( m_targetRect.X, m_targetRect.Y ); // move the point relative to the target rect origin + switch ( cmd ) { + case "maxis_x": data = (int)( 2000 * cPt.X / m_targetRect.Width ) - 1000; break; // data should be -1000..1000 + case "maxis_y": data = -1 * ( (int)( 2000 * cPt.Y / m_targetRect.Height ) - 1000 ); break; // data should be -1000..1000 + default: data = 0; break; + } + } + else { + data = 0; + } + + System.Diagnostics.Debug.Print( string.Format( "C:({0})-T({1})({2}) - data: {3}", + Cursor.Position.ToString( ), + m_targetRect.Location.ToString( ), m_targetRect.Size.ToString( ), + data.ToString( ) ) ); } /// /// Collect the current data from the device /// - public override void GetData( ) + public override void GetData() { // Make sure there is a valid device. if ( null == m_device ) diff --git a/Devices/Options/DeviceTuningParameter.cs b/Devices/Options/DeviceTuningParameter.cs index 9cb8a48..dce20b1 100644 --- a/Devices/Options/DeviceTuningParameter.cs +++ b/Devices/Options/DeviceTuningParameter.cs @@ -5,6 +5,8 @@ using System.Xml; using System.Xml.Linq; using SCJMapper_V2.Actions; using SCJMapper_V2.Devices.Joystick; +using SCJMapper_V2.Devices.Keyboard; +using SCJMapper_V2.Devices.Mouse; namespace SCJMapper_V2.Devices.Options { @@ -19,7 +21,7 @@ namespace SCJMapper_V2.Devices.Options private string m_nodetext = ""; // v_pitch - js1_x private string m_action = ""; // v_pitch private string m_cmdCtrl = ""; // js1_x, js1_y, js1_rotz ... - private string m_class = ""; // joystick OR xboxpad + private string m_devClass = ""; // joystick OR xboxpad OR mouse private int m_devInstanceNo = -1; // jsN - instance in XML string m_option = ""; // the option name (level where it applies) @@ -67,7 +69,7 @@ namespace SCJMapper_V2.Devices.Options ret &= ( this.m_nodetext == clone.m_nodetext ); // immutable string - shallow copy is OK ret &= ( this.m_action == clone.m_action ); // immutable string - shallow copy is OK ret &= ( this.m_cmdCtrl == clone.m_cmdCtrl );// immutable string - shallow copy is OK - ret &= ( this.m_class == clone.m_class ); // immutable string - shallow copy is OK + ret &= ( this.m_devClass == clone.m_devClass ); // immutable string - shallow copy is OK ret &= ( this.m_devInstanceNo == clone.m_devInstanceNo ); ret &= ( this.m_option == clone.m_option ); ret &= ( this.m_deviceName == clone.m_deviceName ); @@ -106,11 +108,11 @@ namespace SCJMapper_V2.Devices.Options get { return m_deviceRef; } set { m_deviceRef = value; - m_class = ""; + m_devClass = ""; m_devInstanceNo = -1; if ( m_deviceRef == null ) return; // got a null device - m_class = m_deviceRef.DevClass; + m_devClass = m_deviceRef.DevClass; m_devInstanceNo = m_deviceRef.XmlInstance; } } @@ -129,7 +131,7 @@ namespace SCJMapper_V2.Devices.Options public string DeviceClass { - get { return m_class; } + get { return m_devClass; } } @@ -256,6 +258,16 @@ namespace SCJMapper_V2.Devices.Options m_cmdCtrl = "xi_thumbry"; m_deviceName = m_deviceRef.DevName; } + else if ( cmd.Contains( "maxis_x" ) ) { + // mouse + m_cmdCtrl = "maxis_x"; + m_deviceName = m_deviceRef.DevName; + } + else if ( cmd.Contains( "maxis_y" ) ) { + // mouse + m_cmdCtrl = "maxis_y"; + m_deviceName = m_deviceRef.DevName; + } // assume joystick else { // get parts @@ -291,7 +303,12 @@ namespace SCJMapper_V2.Devices.Options if ( DevInstanceNo < 1 ) return ""; // no device to assign it to.. string tmp = ""; - tmp += string.Format( "\t\n", m_class, m_devInstanceNo.ToString( ) ); + + // again we have to translate from internal deviceClass mouse to CIG type keyboard ... + string type = m_devClass; + if ( MouseCls.IsDeviceClass( type ) ) type = KeyboardCls.DeviceClass; + + tmp += string.Format( "\t\n", type, m_devInstanceNo.ToString( ) ); tmp += string.Format( "\t\t<{0} ", m_option ); if ( InvertUsed ) { @@ -334,7 +351,7 @@ namespace SCJMapper_V2.Devices.Options /// A prepared XML reader /// the Joystick instance number /// - public bool Options_fromXML( XElement option, string type, int instance ) + public bool Options_fromXML( XElement option, string deviceClass, int instance ) { /* @@ -345,7 +362,7 @@ namespace SCJMapper_V2.Devices.Options */ - m_class = type; + m_devClass = deviceClass; m_devInstanceNo = instance; m_option = option.Name.LocalName; @@ -377,6 +394,8 @@ namespace SCJMapper_V2.Devices.Options string ptOut = RoundString( (string)point.Attribute( "out" ) ); m_PtsIn.Add( ptIn ); m_PtsOut.Add( ptOut ); m_ptsEnabled = true; } + ExponentUsed = false; // despite having the Expo=1.00 in the options - it is not used with nonlin curve + Exponent = RoundString( "1.00" ); } // sanity check - we've have to have 3 pts here - else we subst // add 2nd diff --git a/Devices/Options/Deviceoptions.cs b/Devices/Options/Deviceoptions.cs index 4fde804..51f9742 100644 --- a/Devices/Options/Deviceoptions.cs +++ b/Devices/Options/Deviceoptions.cs @@ -6,12 +6,15 @@ using System.Xml.Linq; using SCJMapper_V2.Devices.Joystick; using SCJMapper_V2.Devices.Gamepad; using System.Linq; +using SCJMapper_V2.Devices.Mouse; namespace SCJMapper_V2.Devices.Options { /// - /// Maintains an Deviceoptions - something like: - /// + /// Maintains all Deviceoptions i.e. Analog controls of all devices connected + /// There are dynamic parts (actions) only for the GUI + /// those are derived from the current mapping which need to be updated before use + /// /// /// ///