public JoyAssgn(JoyAssgn otherInstance) { device = otherInstance.device; productGUID = otherInstance.productGUID; productName = otherInstance.productName; instanceGUID = otherInstance.instanceGUID; detentPosition = otherInstance.detentPosition; productName = Regex.Replace(productName, "[^A-Z|a-z|0-9|~|`|\\[|\\]|\\{|\\}|\\-|_|\\=|\\'|\\s]", String.Empty); for (int i = 0; i < axis.Length; i++) { axis[i] = otherInstance.axis[i].Clone(); } for (int i = 0; i < pov.Length; i++) { pov[i] = otherInstance.pov[i].Clone(); } for (int i = 0; i < dx.Length; i++) { dx[i] = otherInstance.dx[i].Clone(); } }
/// <summary> /// Get Devices. /// </summary> public DeviceControl(AppRegInfo appReg) { // Make Joystick Instances. devList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly); joyStick = new Device[devList.Count]; joyAssign = new JoyAssgn[devList.Count]; System.Xml.Serialization.XmlSerializer serializer; StreamReader sr; string fileName; string stockFileName; int i = 0; foreach (DeviceInstance dev in devList) { joyStick[i] = new Device(dev.InstanceGuid); joyAssign[i] = new JoyAssgn(joyStick[i]); joyAssign[i].SetDeviceInstance(dev); fileName = appReg.GetInstallDir() + "/User/Config/Setup.v100." + joyAssign[i].GetProductName().Replace("/", "-") + " {" + joyAssign[i].GetInstanceGUID().ToString().ToUpper() + "}.xml"; // Load existing .xml files. if (File.Exists(fileName)) { serializer = new System.Xml.Serialization.XmlSerializer(typeof(JoyAssgn)); sr = new StreamReader(fileName, new System.Text.UTF8Encoding(false)); joyAssign[i].Load((JoyAssgn)serializer.Deserialize(sr)); sr.Close(); } else { stockFileName = Directory.GetCurrentDirectory() + "/Stock/Setup.v100." + joyAssign[i].GetProductName().Replace("/", "-") + " {Stock}.xml"; if (File.Exists(stockFileName)) { File.Copy(stockFileName, fileName); serializer = new System.Xml.Serialization.XmlSerializer(typeof(JoyAssgn)); sr = new StreamReader(fileName, new System.Text.UTF8Encoding(false)); joyAssign[i].Load((JoyAssgn)serializer.Deserialize(sr)); sr.Close(); } } joyAssign[i].SetDeviceInstance(dev); i += 1; } // Load MouseWheel .xml file. serializer = new System.Xml.Serialization.XmlSerializer(typeof(AxAssgn)); fileName = appReg.GetInstallDir() + "/User/Config/Setup.v100.Mousewheel.xml"; if (File.Exists(fileName)) { sr = new StreamReader(fileName, new System.Text.UTF8Encoding(false)); mouse.LoadAx((AxAssgn)serializer.Deserialize(sr)); sr.Close(); } }
public InGameAxAssgn(JoyAssgn joy, int phyAxNum, bool invert, AxCurve deadzone, AxCurve saturation) { this.joy = joy; this.phyAxNum = phyAxNum; this.invert = invert; this.deadzone = deadzone; this.saturation = saturation; }
public InGameAxAssgn(JoyAssgn joy, int phyAxNum, AxAssgn axis) { this.joy = joy; this.phyAxNum = phyAxNum; invert = axis.GetInvert(); saturation = axis.GetSaturation(); deadzone = axis.GetDeadZone(); assgnDate = axis.GetAssignDate(); }
public void Load(JoyAssgn j) { detentPosition = j.detentPosition; axis = j.axis; pov = j.pov; for (int i = 0; i < j.dx.Length; i++) { if (i >= dx.Length) { return; } dx[i] = j.dx[i]; } }
public JoyAssgn(JoyAssgn otherInstance) { productGUID = otherInstance.productGUID; productName = otherInstance.productName; instanceGUID = otherInstance.instanceGUID; for (int i = 0; i < axis.Length; i++) { axis[i] = otherInstance.axis[i].Clone(); } for (int i = 0; i < pov.Length; i++) { pov[i] = otherInstance.pov[i].Clone(); } for (int i = 0; i < dx.Length; i++) { dx[i] = otherInstance.dx[i].Clone(); } }
/// <summary> /// Get Devices. /// </summary> public DeviceControl(AppRegInfo appReg) { // Make Joystick Instances. devList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly); joyStick = new Device[devList.Count]; joyAssign = new JoyAssgn[devList.Count]; System.Xml.Serialization.XmlSerializer serializer; StreamReader sr; string fileName = ""; string stockFileName = ""; int i = 0; foreach (DeviceInstance dev in devList) { joyStick[i] = new Device(dev.InstanceGuid); joyAssign[i] = new JoyAssgn(); joyAssign[i].SetDeviceInstance(dev); int povnum = joyStick[i].Caps.NumberPointOfViews; joyStick.Count(); fileName = appReg.GetInstallDir() + "/User/Config/Setup.v100." + joyAssign[i].GetProductName().Replace("/", "-") + " {" + joyAssign[i].GetInstanceGUID().ToString().ToUpper() + "}.xml"; // Load existing .xml files. if (File.Exists(fileName)) { serializer = new System.Xml.Serialization.XmlSerializer(typeof(JoyAssgn)); sr = new StreamReader(fileName, new System.Text.UTF8Encoding(false)); joyAssign[i] = (JoyAssgn)serializer.Deserialize(sr); sr.Close(); } else { stockFileName = appReg.GetInstallDir() + "/User/Config/Setup.v100." + joyAssign[i].GetProductName().Replace("/", "-") + " {Stock}.xml"; if (File.Exists(stockFileName)) { File.Copy(stockFileName, fileName); serializer = new System.Xml.Serialization.XmlSerializer(typeof(JoyAssgn)); sr = new StreamReader(fileName, new System.Text.UTF8Encoding(false)); joyAssign[i] = (JoyAssgn)serializer.Deserialize(sr); sr.Close(); } } joyAssign[i].SetDeviceInstance(dev); i += 1; } // Import stock BMS Setup if .xml save file for the joystick does not exist. try { for (int ii = 0; ii < joyAssign.Length; ii++) { fileName = appReg.GetInstallDir() + "/User/Config/Setup.v100." + joyAssign[ii].GetProductName().Replace("/", "-") + " {" + joyAssign[ii].GetInstanceGUID().ToString().ToUpper() + "}.xml"; if (File.Exists(fileName) == false) { joyAssign[ii].ImportStockSetup(appReg, joyStick.Length, joyStick[ii].Caps.NumberPointOfViews, ii); } } } catch (FileNotFoundException ex) { System.Console.WriteLine(ex.Message); StreamWriter sw = new StreamWriter(appReg.GetInstallDir() + "\\Error.txt", false, System.Text.Encoding.GetEncoding("shift_jis")); sw.Write(ex.Message); sw.Close(); } // Load MouseWheel .xml file. serializer = new System.Xml.Serialization.XmlSerializer(typeof(AxAssgn)); fileName = appReg.GetInstallDir() + "/User/Config/Setup.v100.Mousewheel.xml"; if (File.Exists(fileName)) { sr = new StreamReader(fileName, new System.Text.UTF8Encoding(false)); mouseWheelAssign = (AxAssgn)serializer.Deserialize(sr); sr.Close(); } // Load ThrottlePosition .xml file. serializer = new System.Xml.Serialization.XmlSerializer(typeof(ThrottlePosition)); fileName = appReg.GetInstallDir() + "/User/Config/Setup.v100.throttlePosition.xml"; if (File.Exists(fileName)) { sr = new StreamReader(fileName, new System.Text.UTF8Encoding(false)); throttlePos = (ThrottlePosition)serializer.Deserialize(sr); sr.Close(); } }