From bf1e2c382d773996755dd5b4a0891bcd29d2e1f3 Mon Sep 17 00:00:00 2001 From: chihirobelmo Date: Fri, 1 Jul 2022 18:10:26 +0900 Subject: [PATCH 1/3] now supports both 4.35 DX32 and 4.36 DX128 key mapping --- .../Input/JoyAssgn.cs | 10 +++---- .../Override/OverrideSetting.cs | 2 +- .../Override/OverrideSettingFor434U1.cs | 2 +- .../Override/OverrideSettingFor436.cs | 29 +++++++++++++++++++ 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Falcon BMS Alternative Launcher/Input/JoyAssgn.cs b/Falcon BMS Alternative Launcher/Input/JoyAssgn.cs index 9aac27d..bc826fe 100644 --- a/Falcon BMS Alternative Launcher/Input/JoyAssgn.cs +++ b/Falcon BMS Alternative Launcher/Input/JoyAssgn.cs @@ -197,7 +197,7 @@ public string GetDeviceSortingLine() /// /// Get whole DX button assignment line to write a key file. /// - public string GetKeyLineDX(int joynum, int numOfDevices) + public string GetKeyLineDX(int joynum, int numOfDevices, int DXnumber) { string assign = ""; assign += "\n#======== " + GetProductName() + " ========\n"; @@ -212,7 +212,7 @@ public string GetKeyLineDX(int joynum, int numOfDevices) if (ii != 0) continue; assign += dx[i].assign[ii].GetCallback(); - assign += " " + (joynum * CommonConstants.DX128 + i); + assign += " " + (joynum * DXnumber + i); assign += " " + (int)Invoke.Default; assign += " " + "-2"; assign += " " + "0"; @@ -220,7 +220,7 @@ public string GetKeyLineDX(int joynum, int numOfDevices) assign += " " + dx[i].assign[ii].GetSoundID(); assign += "\n"; assign += dx[i].assign[ii].GetCallback(); - assign += " " + (numOfDevices * CommonConstants.DX128 + joynum * CommonConstants.DX128 + i); + assign += " " + (numOfDevices * DXnumber + joynum * DXnumber + i); assign += " " + (int)Invoke.Default; assign += " " + "-2"; assign += " " + "0"; @@ -233,9 +233,9 @@ public string GetKeyLineDX(int joynum, int numOfDevices) assign += dx[i].assign[ii].GetCallback(); if (ii == CommonConstants.DX_PRESS | ii == CommonConstants.DX_RELEASE) - assign += " " + (joynum * CommonConstants.DX128 + i); + assign += " " + (joynum * DXnumber + i); if (ii == CommonConstants.DX_PRESS_SHIFT | ii == CommonConstants.DX_RELEASE_SHIFT) - assign += " " + (numOfDevices * CommonConstants.DX128 + joynum * CommonConstants.DX128 + i); + assign += " " + (numOfDevices * DXnumber + joynum * DXnumber + i); assign += " " + (int)dx[i].assign[ii].GetInvoke(); assign += " " + "-2"; diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs index d7907a4..fe53aa4 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs @@ -218,7 +218,7 @@ protected virtual void SaveKeyMapping(Hashtable inGameAxis, DeviceControl device sw.Write(keyFile.keyAssign[i].GetKeyLine()); for (int i = 0; i < deviceControl.joyAssign.Length; i++) { - sw.Write(deviceControl.joyAssign[i].GetKeyLineDX(i, deviceControl.joyAssign.Length)); + sw.Write(deviceControl.joyAssign[i].GetKeyLineDX(i, deviceControl.joyAssign.Length, CommonConstants.DX32)); // PRIMARY DEVICE POV if (((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == i) sw.Write(deviceControl.joyAssign[i].GetKeyLinePOV()); diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434U1.cs b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434U1.cs index 2fa5544..8d85b33 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434U1.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434U1.cs @@ -72,7 +72,7 @@ protected override void SaveKeyMapping(Hashtable inGameAxis, DeviceControl devic sw.Write(keyFile.keyAssign[i].GetKeyLine()); for (int i = 0; i < deviceControl.joyAssign.Length; i++) { - sw.Write(deviceControl.joyAssign[i].GetKeyLineDX(i, deviceControl.joyAssign.Length)); + sw.Write(deviceControl.joyAssign[i].GetKeyLineDX(i, deviceControl.joyAssign.Length, CommonConstants.DX32)); // PRIMARY DEVICE POV if (((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == i && ((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == ((InGameAxAssgn)inGameAxis["Throttle"]).GetDeviceNumber()) { diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor436.cs b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor436.cs index 85363f4..791551a 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor436.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor436.cs @@ -60,5 +60,34 @@ protected override void SaveConfigfile(Hashtable inGameAxis, DeviceControl devic cfg.Write("set g_nPOV2ID 0 // SETUP OVERRIDE\r\n"); cfg.Close(); } + + // please DRY later. + protected override void SaveKeyMapping(Hashtable inGameAxis, DeviceControl deviceControl, KeyFile keyFile) + { + string filename = appReg.GetInstallDir() + "/User/Config/" + appReg.getAutoKeyFileName(); + + if (File.Exists(filename)) + File.SetAttributes(filename, File.GetAttributes(filename) & ~FileAttributes.ReadOnly); + + StreamWriter sw = new StreamWriter + (filename, false, 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.joyAssign.Length; i++) + { + sw.Write(deviceControl.joyAssign[i].GetKeyLineDX(i, deviceControl.joyAssign.Length, CommonConstants.DX128)); + // PRIMARY DEVICE POV + if (((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == i && ((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == ((InGameAxAssgn)inGameAxis["Throttle"]).GetDeviceNumber()) + { + sw.Write(deviceControl.joyAssign[i].GetKeyLinePOV()); + continue; + } + if (((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == i) + sw.Write(deviceControl.joyAssign[i].GetKeyLinePOV(0)); + if (((InGameAxAssgn)inGameAxis["Throttle"]).GetDeviceNumber() == i) + sw.Write(deviceControl.joyAssign[i].GetKeyLinePOV(1)); + } + sw.Close(); + } } } From 409772a35e55c3388e6c149aea022ee30b81b08f Mon Sep 17 00:00:00 2001 From: chihirobelmo Date: Fri, 1 Jul 2022 18:32:29 +0900 Subject: [PATCH 2/3] DRY but I don't know if it is a good way --- .../Override/OverrideSetting.cs | 12 +++++---- .../Override/OverrideSettingFor434U1.cs | 4 +-- .../Override/OverrideSettingFor436.cs | 26 +------------------ 3 files changed, 10 insertions(+), 32 deletions(-) diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs index fe53aa4..1f9a2e8 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs @@ -202,10 +202,7 @@ protected void SaveDeviceSorting(DeviceControl deviceControl) ds.Close(); } - /// - /// As the name implies... - /// - protected virtual void SaveKeyMapping(Hashtable inGameAxis, DeviceControl deviceControl, KeyFile keyFile) + protected virtual void SaveKeyMapping(Hashtable inGameAxis, DeviceControl deviceControl, KeyFile keyFile, int DXnumber) { string filename = appReg.GetInstallDir() + "/User/Config/" + appReg.getAutoKeyFileName(); @@ -218,7 +215,7 @@ protected virtual void SaveKeyMapping(Hashtable inGameAxis, DeviceControl device sw.Write(keyFile.keyAssign[i].GetKeyLine()); for (int i = 0; i < deviceControl.joyAssign.Length; i++) { - sw.Write(deviceControl.joyAssign[i].GetKeyLineDX(i, deviceControl.joyAssign.Length, CommonConstants.DX32)); + sw.Write(deviceControl.joyAssign[i].GetKeyLineDX(i, deviceControl.joyAssign.Length, DXnumber)); // PRIMARY DEVICE POV if (((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == i) sw.Write(deviceControl.joyAssign[i].GetKeyLinePOV()); @@ -226,6 +223,11 @@ protected virtual void SaveKeyMapping(Hashtable inGameAxis, DeviceControl device sw.Close(); } + protected virtual void SaveKeyMapping(Hashtable inGameAxis, DeviceControl deviceControl, KeyFile keyFile) + { + SaveKeyMapping(inGameAxis, deviceControl, keyFile, CommonConstants.DX32); + } + /// /// Overwrite callsign.pop file. /// diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434U1.cs b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434U1.cs index 8d85b33..7f07e36 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434U1.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434U1.cs @@ -59,7 +59,7 @@ protected override void SaveConfigfile(Hashtable inGameAxis, DeviceControl devic cfg.Close(); } - protected override void SaveKeyMapping(Hashtable inGameAxis, DeviceControl deviceControl, KeyFile keyFile) + protected override void SaveKeyMapping(Hashtable inGameAxis, DeviceControl deviceControl, KeyFile keyFile, int DXnumber) { string filename = appReg.GetInstallDir() + "/User/Config/" + appReg.getAutoKeyFileName(); @@ -72,7 +72,7 @@ protected override void SaveKeyMapping(Hashtable inGameAxis, DeviceControl devic sw.Write(keyFile.keyAssign[i].GetKeyLine()); for (int i = 0; i < deviceControl.joyAssign.Length; i++) { - sw.Write(deviceControl.joyAssign[i].GetKeyLineDX(i, deviceControl.joyAssign.Length, CommonConstants.DX32)); + sw.Write(deviceControl.joyAssign[i].GetKeyLineDX(i, deviceControl.joyAssign.Length, DXnumber)); // PRIMARY DEVICE POV if (((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == i && ((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == ((InGameAxAssgn)inGameAxis["Throttle"]).GetDeviceNumber()) { diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor436.cs b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor436.cs index 791551a..b540c36 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor436.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor436.cs @@ -61,33 +61,9 @@ protected override void SaveConfigfile(Hashtable inGameAxis, DeviceControl devic cfg.Close(); } - // please DRY later. protected override void SaveKeyMapping(Hashtable inGameAxis, DeviceControl deviceControl, KeyFile keyFile) { - string filename = appReg.GetInstallDir() + "/User/Config/" + appReg.getAutoKeyFileName(); - - if (File.Exists(filename)) - File.SetAttributes(filename, File.GetAttributes(filename) & ~FileAttributes.ReadOnly); - - StreamWriter sw = new StreamWriter - (filename, false, 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.joyAssign.Length; i++) - { - sw.Write(deviceControl.joyAssign[i].GetKeyLineDX(i, deviceControl.joyAssign.Length, CommonConstants.DX128)); - // PRIMARY DEVICE POV - if (((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == i && ((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == ((InGameAxAssgn)inGameAxis["Throttle"]).GetDeviceNumber()) - { - sw.Write(deviceControl.joyAssign[i].GetKeyLinePOV()); - continue; - } - if (((InGameAxAssgn)inGameAxis["Roll"]).GetDeviceNumber() == i) - sw.Write(deviceControl.joyAssign[i].GetKeyLinePOV(0)); - if (((InGameAxAssgn)inGameAxis["Throttle"]).GetDeviceNumber() == i) - sw.Write(deviceControl.joyAssign[i].GetKeyLinePOV(1)); - } - sw.Close(); + SaveKeyMapping(inGameAxis, deviceControl, keyFile, CommonConstants.DX128); } } } From daba2ab69f27ade42992ae3862362dd75b5dbdc6 Mon Sep 17 00:00:00 2001 From: chihirobelmo Date: Fri, 1 Jul 2022 21:28:33 +0900 Subject: [PATCH 3/3] added comment --- Falcon BMS Alternative Launcher/Input/JoyAssgn.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Falcon BMS Alternative Launcher/Input/JoyAssgn.cs b/Falcon BMS Alternative Launcher/Input/JoyAssgn.cs index bc826fe..34a40d2 100644 --- a/Falcon BMS Alternative Launcher/Input/JoyAssgn.cs +++ b/Falcon BMS Alternative Launcher/Input/JoyAssgn.cs @@ -196,8 +196,9 @@ public string GetDeviceSortingLine() /// /// Get whole DX button assignment line to write a key file. + /// DXnumber: total DXnumber per device BMS can handle. /// - public string GetKeyLineDX(int joynum, int numOfDevices, int DXnumber) + public string GetKeyLineDX(int joynum, int numOfDevices, int DXnumber) { string assign = ""; assign += "\n#======== " + GetProductName() + " ========\n";