Skip to content

Commit a3cc26f

Browse files
committed
more disableio4
1 parent 73943bb commit a3cc26f

File tree

4 files changed

+72
-29
lines changed

4 files changed

+72
-29
lines changed

.config/dotnet-tools.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

AquaMai.Config/Migration/ConfigMigrationManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class ConfigMigrationManager : IConfigMigrationManager
1616
new ConfigMigration_V2_0_V2_1(),
1717
new ConfigMigration_V2_1_V2_2(),
1818
new ConfigMigration_V2_2_V2_3(),
19+
new ConfigMigration_V2_3_V2_4(),
1920
}.ToDictionary(m => m.FromVersion);
2021

2122
public string LatestVersion { get; }
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using AquaMai.Config.Interfaces;
2+
using Tomlet.Models;
3+
4+
namespace AquaMai.Config.Migration;
5+
6+
public class ConfigMigration_V2_3_V2_4 : IConfigMigration
7+
{
8+
public string FromVersion => "2.3";
9+
public string ToVersion => "2.4";
10+
11+
public ConfigView Migrate(ConfigView src)
12+
{
13+
var dst = (ConfigView)src.Clone();
14+
dst.SetValue("Version", ToVersion);
15+
16+
if (src.TryGetValue<bool>("GameSystem.KeyMap.DisableIO4", out var disableIO4))
17+
{
18+
dst.SetValue("GameSystem.KeyMap.DisableIO4_1P", disableIO4);
19+
dst.SetValue("GameSystem.KeyMap.DisableIO4_2P", disableIO4);
20+
dst.SetValue("GameSystem.KeyMap.DisableIO4System", disableIO4);
21+
dst.Remove("GameSystem.KeyMap.DisableIO4");
22+
}
23+
24+
return dst;
25+
}
26+
}
27+

AquaMai.Mods/GameSystem/KeyMap.cs

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Collections.Generic;
12
using System.Reflection;
23
using AMDaemon;
34
using AquaMai.Config.Attributes;
@@ -24,7 +25,7 @@ DebugInput 与 IO4(兼容 IO4 板 / segatools IO4 模拟)独立工作。
2425
public class KeyMap
2526
{
2627
[ConfigEntry(
27-
name: "禁用 IO4",
28+
name: "禁用 IO4(1P)",
2829
en: """
2930
Disable IO4 (IO4-compatible board / segatools IO4 emulation) input.
3031
With IO4 input disabled, your IO4-compatible board or segatools IO4 emulation is ignored.
@@ -33,7 +34,19 @@ Disable IO4 (IO4-compatible board / segatools IO4 emulation) input.
3334
禁用 IO4(兼容 IO4 板 / segatools IO4 模拟)输入。
3435
在禁用 IO4 输入后,你的兼容 IO4 板或 segatools IO4 模拟将被忽略。
3536
""")]
36-
private static readonly bool disableIO4 = false;
37+
private static readonly bool disableIO4_1P = false;
38+
[ConfigEntry("禁用 IO4(2P)")]
39+
private static readonly bool disableIO4_2P = false;
40+
41+
[ConfigEntry(
42+
name: "禁用 IO4(系统按键)",
43+
en: """
44+
System buttons (test, service) input.
45+
""",
46+
zh: """
47+
禁用系统按键的 IO4 输入,输入源同上。
48+
""")]
49+
private static readonly bool disableIO4System = false;
3750

3851
[ConfigEntry(
3952
name: "禁用 DebugInput",
@@ -59,30 +72,45 @@ 禁用 DebugFeature Polyfill 的快捷键,比如说回车暂停,左右键快
5972
""")]
6073
public static readonly bool disableDebugFeatureHotkeys = false; // Implemented in DebugFeature
6174

62-
[EnableIf(nameof(disableIO4))]
75+
private static bool DisableIO4 => disableIO4_1P || disableIO4_2P || disableIO4System;
76+
private static List<SwitchInput> disabledSwitchInputs = [];
77+
78+
[EnableIf(nameof(DisableIO4))]
6379
[HarmonyPatch("IO.Jvs+JvsSwitch", ".ctor", MethodType.Constructor, [typeof(int), typeof(string), typeof(KeyCode), typeof(bool), typeof(bool)])]
64-
[HarmonyPrefix]
65-
public static void PreJvsSwitchConstructor(ref bool invert)
80+
[HarmonyPostfix]
81+
public static void PostJvsSwitchConstructor(ref bool ____invert, int playerNo, bool systemButton, SwitchInput ____switchInput)
6682
{
67-
invert = false;
83+
if ((systemButton && disableIO4System) || (playerNo == 0 && disableIO4_1P) || (playerNo == 1 && disableIO4_2P))
84+
{
85+
____invert = false;
86+
disabledSwitchInputs.Add(____switchInput);
87+
}
6888
}
6989

70-
[EnableIf(nameof(disableIO4))]
71-
[HarmonyPatch(typeof(SwitchInput), "get_IsOn")]
90+
[EnableIf(nameof(DisableIO4))]
91+
[HarmonyPatch(typeof(SwitchInput), nameof(SwitchInput.IsOn), MethodType.Getter)]
7292
[HarmonyPrefix]
73-
public static bool PreGetIsOn(ref bool __result)
93+
public static bool PreGetIsOn(ref bool __result, SwitchInput __instance)
7494
{
75-
__result = false;
76-
return false;
95+
if (disabledSwitchInputs.Contains(__instance))
96+
{
97+
__result = false;
98+
return false;
99+
}
100+
return true;
77101
}
78102

79-
[EnableIf(nameof(disableIO4))]
80-
[HarmonyPatch(typeof(SwitchInput), "get_HasOnNow")]
103+
[EnableIf(nameof(DisableIO4))]
104+
[HarmonyPatch(typeof(SwitchInput), nameof(SwitchInput.HasOnNow), MethodType.Getter)]
81105
[HarmonyPrefix]
82-
public static bool PreGetHasOnNow(ref bool __result)
106+
public static bool PreGetHasOnNow(ref bool __result, SwitchInput __instance)
83107
{
84-
__result = false;
85-
return false;
108+
if (disabledSwitchInputs.Contains(__instance))
109+
{
110+
__result = false;
111+
return false;
112+
}
113+
return true;
86114
}
87115

88116
[ConfigEntry]

0 commit comments

Comments
 (0)