/// <summary> /// As the name inplies... /// </summary> protected void SaveJoyAssignStatus(DeviceControl deviceControl) { //保存先のファイル名 string fileName = ""; System.Xml.Serialization.XmlSerializer serializer; System.IO.StreamWriter sw; for (int i = 0; i < deviceControl.devList.Count; i++) { fileName = appReg.GetInstallDir() + "/User/Config/Setup.v100." + deviceControl.joyAssign[i].GetProductName().Replace("/", "-") + " {" + deviceControl.joyAssign[i].GetInstanceGUID().ToString().ToUpper() + "}.xml"; serializer = new System.Xml.Serialization.XmlSerializer(typeof(JoyAssgn)); sw = new System.IO.StreamWriter(fileName, false, new System.Text.UTF8Encoding(false)); serializer.Serialize(sw, deviceControl.joyAssign[i]); sw.Close(); } fileName = appReg.GetInstallDir() + "/User/Config/Setup.v100.MouseWheel.xml"; serializer = new System.Xml.Serialization.XmlSerializer(typeof(JoyAssgn.AxAssgn)); sw = new System.IO.StreamWriter(fileName, false, new System.Text.UTF8Encoding(false)); serializer.Serialize(sw, deviceControl.mouseWheelAssign); sw.Close(); fileName = appReg.GetInstallDir() + "/User/Config/Setup.v100.ThrottlePosition.xml"; serializer = new System.Xml.Serialization.XmlSerializer(typeof(ThrottlePosition)); sw = new System.IO.StreamWriter(fileName, false, new System.Text.UTF8Encoding(false)); serializer.Serialize(sw, deviceControl.throttlePos); sw.Close(); }
/// <summary> /// As the name inplies... /// </summary> protected void SaveKeyMapping(Hashtable inGameAxis, DeviceControl deviceControl, KeyFile keyFile) { string filename = appReg.GetInstallDir() + "/User/Config/" + appReg.getKeyFileName(); string fbackupname = appReg.GetInstallDir() + "/User/Config/Backup/" + appReg.getKeyFileName(); if (!System.IO.File.Exists(fbackupname) & (System.IO.File.Exists(filename))) { System.IO.File.Copy(filename, fbackupname, true); } if (System.IO.File.Exists(filename)) { System.IO.File.SetAttributes(filename, System.IO.File.GetAttributes(filename) & (~System.IO.FileAttributes.ReadOnly)); } System.IO.StreamWriter sw = new System.IO.StreamWriter (filename, false, System.Text.Encoding.GetEncoding("utf-8")); for (int i = 0; i < keyFile.keyAssign.Length; i++) { sw.Write(keyFile.keyAssign[i].GetKeyLine()); } for (int i = 0; i < deviceControl.devList.Count; i++) { sw.Write(deviceControl.joyAssign[i].GetKeyLineDX(i, deviceControl.devList.Count)); // PRIMARY DEVICE POV if (((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == i) { sw.Write(deviceControl.joyAssign[i].GetKeyLinePOV()); } } sw.Close(); }
/// <summary> /// As the name inplies... /// </summary> protected void SaveDeviceSorting(DeviceControl deviceControl) { string deviceSort = ""; for (int i = 0; i < deviceControl.devList.Count; i++) { deviceSort += deviceControl.joyAssign[i].GetDeviceSortingLine(); } // BMS overwrites DeviceSorting.txt if was written in UTF-8. string filename = appReg.GetInstallDir() + "/User/Config/DeviceSorting.txt"; string fbackupname = appReg.GetInstallDir() + "/User/Config/Backup/DeviceSorting.txt"; if ((!System.IO.File.Exists(fbackupname)) & (System.IO.File.Exists(filename))) { System.IO.File.Copy(filename, fbackupname, true); } if (System.IO.File.Exists(filename)) { System.IO.File.SetAttributes(filename, System.IO.File.GetAttributes(filename) & (~System.IO.FileAttributes.ReadOnly)); } System.IO.StreamWriter ds = new System.IO.StreamWriter (filename, false, System.Text.Encoding.GetEncoding("shift_jis")); ds.Write(deviceSort); ds.Close(); }
/// <summary> /// Execute setting override. /// </summary> /// <param name="inGameAxis"></param> /// <param name="deviceControl"></param> /// <param name="keyFile"></param> /// <param name="visualAcuity"></param> public void Execute(Hashtable inGameAxis, DeviceControl deviceControl, KeyFile keyFile) { if (!System.IO.Directory.Exists(appReg.GetInstallDir() + "/User/Config/Backup/")) { System.IO.Directory.CreateDirectory(appReg.GetInstallDir() + "/User/Config/Backup/"); } SaveAxisMapping(inGameAxis, deviceControl); SaveJoystickCal(inGameAxis, deviceControl); SaveDeviceSorting(deviceControl); SaveConfigfile(deviceControl); SaveKeyMapping(inGameAxis, deviceControl, keyFile); SavePop(); SaveJoyAssignStatus(deviceControl); }
public KeyMappingWindow(KeyAssgn SelectedCallback, KeyFile keyFile, DeviceControl deviceControl) { InitializeComponent(); CallbackName.Content = SelectedCallback.GetKeyDescription(); Select_PinkyShift.IsChecked = true; Select_DX_Release.IsChecked = true; this.SelectedCallback = SelectedCallback; this.keyFile = keyFile; this.deviceControl = deviceControl; neutralButtons = new NeutralButtons[deviceControl.devList.Count]; tmpJoyStick = new JoyAssgn[deviceControl.devList.Count]; for (int i = 0; i < deviceControl.devList.Count; i++) { tmpJoyStick[i] = deviceControl.joyAssign[i].Clone(); } tmpCallback = this.SelectedCallback.Clone(); }
/// <summary> /// As the name inplies... /// </summary> protected void SaveConfigfile(DeviceControl deviceControl) { string filename = appReg.GetInstallDir() + "/User/Config/falcon bms.cfg"; string fbackupname = appReg.GetInstallDir() + "/User/Config/Backup/falcon bms.cfg"; if (!System.IO.File.Exists(fbackupname) & (System.IO.File.Exists(filename))) { System.IO.File.Copy(filename, fbackupname, true); } if (System.IO.File.Exists(filename)) { System.IO.File.SetAttributes(filename, System.IO.File.GetAttributes(filename) & (~System.IO.FileAttributes.ReadOnly)); } System.IO.StreamReader cReader = new System.IO.StreamReader (filename, System.Text.Encoding.Default); string stResult = ""; while (cReader.Peek() >= 0) { string stBuffer = cReader.ReadLine(); if (stBuffer.Contains("// SETUP OVERRIDE")) { continue; } stResult += stBuffer + "\r\n"; } cReader.Close(); System.IO.StreamWriter cfg = new System.IO.StreamWriter (filename, false, System.Text.Encoding.GetEncoding("shift_jis")); cfg.Write(stResult); cfg.Write("set g_nHotasPinkyShiftMagnitude " + (deviceControl.devList.Count * 32).ToString() + " // SETUP OVERRIDE\r\n"); cfg.Write("set g_bHotasDgftSelfCancel " + Convert.ToInt32(mainWindow.Misc_OverrideSelfCancel.IsChecked) + " // SETUP OVERRIDE\r\n"); cfg.Write("set g_b3DClickableCursorAnchored " + Convert.ToInt32(mainWindow.Misc_MouseCursorAnchor.IsChecked) + " // SETUP OVERRIDE\r\n"); cfg.Close(); }
public OverrideSetting(MainWindow mainWindow, AppRegInfo appReg, Hashtable inGameAxis, DeviceControl deviceControl, KeyFile keyFile, VisualAcuity visualAcuity) { this.mainWindow = mainWindow; this.appReg = appReg; this.inGameAxis = inGameAxis; this.deviceControl = deviceControl; this.keyFile = keyFile; this.visualAcuity = visualAcuity; if (!System.IO.Directory.Exists(appReg.GetInstallDir() + "/User/Config/Backup/")) { System.IO.Directory.CreateDirectory(appReg.GetInstallDir() + "/User/Config/Backup/"); } SaveAxisMapping(); SaveJoystickCal(); SaveDeviceSorting(); SaveConfigfile(); SaveKeyMapping(); SaveJoyAssignStatus(); }
/// <summary> /// As the name inplies... /// </summary> protected override void SaveJoystickCal(Hashtable inGameAxis, DeviceControl deviceControl) { string filename = appReg.GetInstallDir() + "/User/Config/joystick.cal"; string fbackupname = appReg.GetInstallDir() + "/User/Config/Backup/joystick.cal"; if ((!System.IO.File.Exists(fbackupname)) & (System.IO.File.Exists(filename))) { System.IO.File.Copy(filename, fbackupname, true); } if (System.IO.File.Exists(filename)) { System.IO.File.SetAttributes(filename, System.IO.File.GetAttributes(filename) & (~System.IO.FileAttributes.ReadOnly)); } System.IO.FileStream fs = new System.IO.FileStream (filename, System.IO.FileMode.Create, System.IO.FileAccess.Write); byte[] bs; AxisName[] localJoystickCalList = appReg.getOverrideWriter().getJoystickCalList(); foreach (AxisName nme in localJoystickCalList) { bs = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x98, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber() != -1) { bs[12] = 0x01; if (nme == AxisName.Throttle) { double iAB = (double)deviceControl.throttlePos.GetAB(); double iIdle = (double)deviceControl.throttlePos.GetIDLE(); const double MAXIN = 65536; const double MAXOUT = 14848; iAB = -iAB * (MAXOUT / MAXIN) + MAXOUT; iIdle = -iIdle * (MAXOUT / MAXIN) + MAXOUT; byte[] ab = BitConverter.GetBytes((int)iAB); byte[] idle = BitConverter.GetBytes((int)iIdle); bs[1] = ab[1]; bs[5] = idle[1]; if (deviceControl.throttlePos.GetAB() > (65536 - 256)) { bs[1] = 0x00; } if (deviceControl.throttlePos.GetIDLE() < 256) { bs[5] = 0x3A; } } } if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetInvert()) { bs[20] = 0x01; bs[21] = 0x01; } fs.Write(bs, 0, bs.Length); } fs.Close(); }
/// <summary> /// As the name inplies... /// </summary> protected void SaveAxisMapping(Hashtable inGameAxis, DeviceControl deviceControl) { string filename = appReg.GetInstallDir() + "/User/Config/axismapping.dat"; string fbackupname = appReg.GetInstallDir() + "/User/Config/Backup/axismapping.dat"; if ((!System.IO.File.Exists(fbackupname)) & (System.IO.File.Exists(filename))) { System.IO.File.Copy(filename, fbackupname, true); } if (System.IO.File.Exists(filename)) { System.IO.File.SetAttributes(filename, System.IO.File.GetAttributes(filename) & (~System.IO.FileAttributes.ReadOnly)); } System.IO.FileStream fs = new System.IO.FileStream (filename, System.IO.FileMode.Create, System.IO.FileAccess.Write); byte[] bs; if (((InGameAxAssgn)inGameAxis["Pitch"]).GetDeviceNumber() > -1) { bs = new byte[] { (byte)(((InGameAxAssgn)inGameAxis["Pitch"]).GetDeviceNumber() + 2), 0x00, 0x00, 0x00 }; fs.Write(bs, 0, bs.Length); bs = deviceControl.joyAssign[(byte)((InGameAxAssgn)inGameAxis["Pitch"]).GetDeviceNumber()] .GetInstanceGUID().ToByteArray(); fs.Write(bs, 0, bs.Length); bs = new byte[] { (byte)deviceControl.devList.Count, 0x00, 0x00, 0x00 }; fs.Write(bs, 0, bs.Length); } else { bs = new byte[] { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; bs[20] = (byte)deviceControl.devList.Count; fs.Write(bs, 0, bs.Length); } AxisName[] localAxisMappingList = this.getAxisMappingList(); foreach (AxisName nme in localAxisMappingList) { if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber() == -1) { bs = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x64, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF }; fs.Write(bs, 0, bs.Length); continue; } if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber() > -1) { bs = new byte[] { (byte)(((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber() + 2), 0x00, 0x00, 0x00 }; fs.Write(bs, 0, bs.Length); bs = new byte[] { (byte)((InGameAxAssgn)inGameAxis[nme.ToString()]).GetPhysicalNumber(), 0x00, 0x00, 0x00 }; fs.Write(bs, 0, bs.Length); } if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber() == -2) { bs = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; fs.Write(bs, 0, bs.Length); } switch (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeadzone()) { case AxCurve.None: bs = new byte[] { 0x00, 0x00, 0x00, 0x00 }; break; case AxCurve.Small: bs = new byte[] { 0x64, 0x00, 0x00, 0x00 }; break; case AxCurve.Medium: bs = new byte[] { 0xF4, 0x01, 0x00, 0x00 }; break; case AxCurve.Large: bs = new byte[] { 0xE8, 0x03, 0x00, 0x00 }; break; } fs.Write(bs, 0, bs.Length); switch (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetSaturation()) { case AxCurve.None: bs = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF }; break; case AxCurve.Small: bs = new byte[] { 0x1C, 0x25, 0x00, 0x00 }; break; case AxCurve.Medium: bs = new byte[] { 0x28, 0x23, 0x00, 0x00 }; break; case AxCurve.Large: bs = new byte[] { 0x34, 0x21, 0x00, 0x00 }; break; } fs.Write(bs, 0, bs.Length); } fs.Close(); }
/// <summary> /// Execute when launching this app. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { try { // load command line. string[] args = Environment.GetCommandLineArgs(); if (args.Length % 2 == 1) { Dictionary <string, string> option = new Dictionary <string, string>(); for (int index = 1; index < args.Length; index += 2) { option.Add(args[index], args[index + 1]); } if (option.ContainsKey("/yame")) { if (option["/yame"] == "true") { FLG_YAME64 = true; } } if (FLG_YAME64) { LargeTab.SelectedIndex = 1; Tab_Launcher.Visibility = Visibility.Collapsed; Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundBox1.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundBox2.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundBox3.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundBox4.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundImage.Opacity = 0; Button_Apply_YAME64.Visibility = Visibility.Visible; } else { Button_Apply_YAME64.Visibility = Visibility.Hidden; } } } catch (FileNotFoundException ex) { Console.WriteLine(ex.Message); StreamWriter sw = new StreamWriter("C:\\FBMSAltLauncherErrorLog.txt", false, System.Text.Encoding.GetEncoding("shift_jis")); sw.Write(ex.Message); sw.Close(); MessageBox.Show("Error Log Saved To C:\\FBMSAltLauncherErrorLog.txt", "WARNING", MessageBoxButton.OK, MessageBoxImage.Information); Close(); } // Load UI Properties(Like Button Status). appProperties = new AppProperties(this); // Read Registry appReg = new AppRegInfo(this); if (appReg.getBMSVersion() == BMS_Version.UNDEFINED) { Close(); return; } try { // Read Theater List TheaterList.Populate(appReg, Dropdown_TheaterList); // Get Devices deviceControl = new DeviceControl(appReg); neutralButtons = new NeutralButtons[deviceControl.devList.Count]; // Aquire joySticks AquireAll(true); // Reset All Axis Settings foreach (AxisName nme in axisNameList) { inGameAxis[nme.ToString()] = new InGameAxAssgn(); } joyAssign_2_inGameAxis(); ResetAssgnWindow(); // Read BMS-FULL.key string fname = appReg.GetInstallDir() + "\\User\\Config\\" + appReg.getKeyFileName(); keyFile = new KeyFile(fname, appReg); // Write Data Grid WriteDataGrid(); // Set Timer AxisMovingTimer.Tick += AxisMovingTimer_Tick; AxisMovingTimer.Interval = new TimeSpan(0, 0, 0, 0, 16); KeyMappingTimer.Tick += KeyMappingTimer_Tick; KeyMappingTimer.Interval = new TimeSpan(0, 0, 0, 0, 16); //System.Diagnostics.PresentationTraceSources.DataBindingSource.Switch.Level = System.Diagnostics.SourceLevels.Critical; } catch (FileNotFoundException ex) { 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(); MessageBox.Show("Error Log Saved To " + appReg.GetInstallDir() + "\\Error.txt", "WARNING", MessageBoxButton.OK, MessageBoxImage.Information); Close(); } }
public static void ShowKeyMappingWindow(KeyAssgn SelectedCallback, KeyFile keyFile, DeviceControl deviceControl, object sender) { KeyMappingWindow ownWindow = new KeyMappingWindow(SelectedCallback, keyFile, deviceControl); ownWindow.ShowDialog(); }
/// <summary> /// Execute when launching this app. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { try { // Load UI Properties(Like Button Status). this.appProperties = new AppProperties(this); // Read Registry appReg = new AppRegInfo(this); // Read Theater List TheaterList theaterlist = new TheaterList(appReg, this.Dropdown_TheaterList); // Get Devices deviceControl = new DeviceControl(appReg); neutralButtons = new NeutralButtons[deviceControl.devList.Count]; // Aquire joySticks AquireAll(true); // Reset All Axis Settings foreach (AxisName nme in axisNameList) { inGameAxis[nme.ToString()] = new InGameAxAssgn(); } joyAssign_2_inGameAxis(); ResetAssgnWindow(); // Read BMS-FULL.key string fname = appReg.GetInstallDir() + "\\User\\Config\\BMS - Full.key"; keyFile = new KeyFile(fname, appReg); // Write Data Grid WriteDataGrid(); // Set Timer AxisMovingTimer.Tick += AxisMovingTimer_Tick; AxisMovingTimer.Interval = new TimeSpan(0, 0, 0, 0, 16); KeyMappingTimer.Tick += KeyMappingTimer_Tick; KeyMappingTimer.Interval = new TimeSpan(0, 0, 0, 0, 16); // Set VisualAcuity page graph and results. this.visualAcuity = new VisualAcuity(this); //System.Diagnostics.PresentationTraceSources.DataBindingSource.Switch.Level = System.Diagnostics.SourceLevels.Critical; } catch (System.IO.FileNotFoundException ex) { System.Console.WriteLine(ex.Message); System.IO.StreamWriter sw = new System.IO.StreamWriter(appReg.GetInstallDir() + "\\Error.txt", false, System.Text.Encoding.GetEncoding("shift_jis")); sw.Write(ex.Message); sw.Close(); this.Close(); } // YAME 64 VERSION if (FLG_YAME64 == true) { LargeTab.SelectedIndex = 1; Tab_Launcher.Visibility = Visibility.Collapsed; Tab_VisualAcuity.Visibility = Visibility.Collapsed; Misc_SmartScalingOverride.IsChecked = false; this.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundBox1.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundBox2.Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); BackGroundImage.Opacity = 0; } else { Button_Apply_YAME64.Visibility = Visibility.Hidden; } }