From 3c7a6287957c5a007f7e3f93f5c39a8aa072208a Mon Sep 17 00:00:00 2001 From: bm98 Date: Thu, 4 Jan 2018 00:05:35 +0100 Subject: [PATCH] V 2.35 - BETA Build 69 (ready to test) - add - provide CIG asset texts/translations for actions and maps (use Settings to choose - for now only French and German are in but have no translations for English not all have a proper text - may not be used in the game ??) - add - tooltips for profile action names in treeview (enable in Settings) - add - mouse tuning items (curve, expo, invert) - improvement - cache CIG assets into the app/Storage folder, reads from p4k file only if those are updated - fix - window should always be visible on startup now - internal cleanup - to many to list --- ActivationModes.xlsx | Bin 9524 -> 0 bytes AppSettings.cs | 8 + Devices/DeviceCls.cs | 2 + Devices/Gamepad/GamepadCls.cs | 12 + Devices/Joystick/JoystickCls.cs | 92 +- Devices/Mouse/MouseCls.cs | 63 +- Devices/Options/DeviceTuningParameter.cs | 35 +- Devices/Options/Deviceoptions.cs | 52 +- Devices/Options/FormOptions.cs | 174 +- Devices/Options/OptionTree.cs | 254 +- Devices/Options/OptionsInvert.cs | 164 - Devices/Options/Tuningoptions.cs | 43 +- FormMain.Designer.cs | 1 - FormMain.cs | 421 +-- FormMain.resx | 148 +- FormSettings.Designer.cs | 19 +- FormSettings.cs | 15 +- OGL/FormJSCalCurve.Designer.cs | 3747 +++++++++--------- OGL/FormJSCalCurve.cs | 4398 +++++++++++----------- ReadMe.txt | 5 +- SC/DProfileReader.cs | 12 + SC/SCUiText.cs | 31 +- SCJMapper-V2.csproj | 1 - Table/DS_ActionMaps.Designer.cs | 266 +- Table/DS_ActionMaps.xsd | 7 +- Table/DS_ActionMaps.xss | 6 +- Table/FormTable.cs | 59 +- actions/ActionCls.cs | 26 +- actions/ActionMapCls.cs | 15 +- actions/ActionMapsCls.cs | 63 +- actions/ActionTree.cs | 152 +- actions/ActionTreeInputNode.cs | 87 +- actions/ActionTreeNode.cs | 67 +- defaultProfile-PTU3.0.0-V1.zip | Bin 12795 -> 0 bytes 34 files changed, 5097 insertions(+), 5348 deletions(-) delete mode 100644 ActivationModes.xlsx delete mode 100644 Devices/Options/OptionsInvert.cs delete mode 100644 defaultProfile-PTU3.0.0-V1.zip diff --git a/ActivationModes.xlsx b/ActivationModes.xlsx deleted file mode 100644 index 9bb7c45b1c25ff7a47174de0fb8c4ec142750e65..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9524 zcmeHt1y@|j)^8r*^tTm!)^5L^Pm-GdW?1q)x#+A_$^ZrcNQ46bumDJ~x?+wF zZsrbdhH73;=C1n8ukG!~3gKYs@&T~W=l?hUi&vm3WmKV$74+&x>OpMhh0IEWFcRlU z@E|6GvS3et@<4^DZmzZUQ*P8fNVEXQhPxhfa>a-JeB7$R!Tv*V>P;--{&ga=w%mk7GX;DKd!~(& z!CY}gUT%h9|I(r17M>o(6H{Vehj&wmJ8-XlJYiph585tzL_xznQzbdihZnT;b&405koh#tBD{{Sx*tEc5*fUKsq3M62Dj#2_`o5TIm0r~kvq z@+yDa;Sl-t7NjZ$6Pu6ngJ*Sk`kk{oA_I*}nuK%JW_veA>GM zbfHLIx#Q_foFP{e%f%YsAv^M`TS9eJD_-k5lU$dV6kdjAc0Cv3+1*%=zAqGVhEymZ zm_OJjB?qbVuL5)$A?KrSz52P4`znXN4F|`NmaRb})ZdLHNH8V+0=gn?P$MA(Ai=!0 zWBHezcsjb+nm9Vz{uaIdV>2+&5C+xq-#w~SPOFz zh8yXZX~;SJFV~3}+Vr*NWLbcY;a+FsgB~}W7+XNBt6s*kXiPY7EW0y4c*pUJaUhb( zN%iw!Nq8*GqUY@WRzbkqb9MeiuYFI%U>AvP1N?(8F%{3A_tcJ+2OJY;GpYqPN(6Y86|)M#u~HBAvP*K$hl5_X14q&yX|z=zVpK^u6Q3 zLf&h_wzudGZI`%G_IU-TfN!`PS;UYeX#jna>uzCYyZYIto9O)refRQrrqRnYi=E-Y z*>&hn{~aMMN8o}O z5tjIrhpz0rt3O=m^{}Gt5BN$$&blxP>gb=JxH=d3s^{b3Tm^p%yW~WTb(r@$C2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qIB_kwkUT36NSluP4w#s{&gBtTb|unDj{3KU(01ECf1}2ndvEy;X9lXiUkPQ|?bk^1Ve#CTjpTl08H(f0mm-foopH5pLM7nZZ8=Pmki&oL-a zdaVq%3p>o8B^*&R(9&mqvc^relRrIxl$d>A6MQo5LSHg0bB%n$0=m7VFaVgx*9uDB zLc{ytsqKUbWZGOP@K}KW0O-%aGj?+NAMT)l`}fF6?sZuHt#1ar#t1)+%W)tH7uHZN zCh}gW133Fwn!N-w$cFb5O6OTRHsBH27e#%!o*^2}`*|CcG<((MtR2C&xPi)+w@V@B zC~E%r0d%uF8FNM<3)cmU$B(-eD6MxinK#1_j!UU6N1*#dEs{jJJ&`?=ge%d4$w%W5 zL`0^rtr6b#0l_iE%jR=($Jm7<=1pkV$HPJa!ssdIsVPbMN+a*COQq*J2y+!^a5atS zhkC=Rg$_$|+Q9zO`R?i{^02H1QlAio;qtN!@3=jBotKx-zo=EC^XPpS)(?>_+bPdK z1>Kp~^b8cMOU7WJhh3r*N@mtP7tGC5^<%h*>MQ^{--7Suv zx>KV}@bLig%Yy&xML|%=#lV_TvGHck`^FvC$8t^30m<<#wvQ2hfn*LQ*FJH)YH4WS zu-6>pjk%T1H$>d{DV8JBFMhh=x@5kKhhECno}l`z7#@d5EhW#6&->oVyBH6+mFc<7 zqE86V2S|k{Yb|cmb80|ck$1H9Z /// 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 + /// /// /// ///