-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[+] GameSystem.KeyMap.{DisableIO4, DisableDebugInput} #19
Conversation
审阅者指南 by Sourcery此拉取请求引入了禁用 IO4 和 DebugInput 的能力,提供了更灵活的输入配置。它还包括对 DebugInput 处理方式的更改。 显示 KeyMap 和 Common 类修改的类图classDiagram
class KeyMap {
-bool disableIO4
+bool disableDebugInput
+KeyCodeID Test
+PreJvsSwitchConstructor(ref bool invert)
+PreGetIsOn(ref bool __result)
+PreGetHasOnNow(ref bool __result)
}
note for KeyMap "输入源控制的
新配置选项"
class Common {
+GetKey(ref bool __result, KeyCode name)
+GetKeyDown(ref bool __result, KeyCode name)
}
note for Common "修改以遵守
disableDebugInput 设置"
KeyMap -- Common : uses
输入系统配置的状态图stateDiagram-v2
[*] --> InputConfig
InputConfig --> IO4_Only: 禁用 DebugInput
InputConfig --> DebugInput_Only: 禁用 IO4
InputConfig --> Both_Enabled: 两者都启用
InputConfig --> No_Input: 两者都禁用
note right of IO4_Only: 使用 IO4 兼容板
或 segatools 仿真
note right of DebugInput_Only: 通过 Unity 输入系统
使用键盘输入
note right of Both_Enabled: 可能会导致问题
note right of No_Input: 按钮输入完全禁用
文件级更改
提示和命令与 Sourcery 交互
自定义您的体验访问您的仪表板以:
获取帮助Original review guide in EnglishReviewer's Guide by SourceryThis pull request introduces the ability to disable IO4 and DebugInput, providing more flexibility in input configurations. It also includes changes to how DebugInput is handled. Class diagram showing KeyMap and Common class modificationsclassDiagram
class KeyMap {
-bool disableIO4
+bool disableDebugInput
+KeyCodeID Test
+PreJvsSwitchConstructor(ref bool invert)
+PreGetIsOn(ref bool __result)
+PreGetHasOnNow(ref bool __result)
}
note for KeyMap "New configuration options for
input source control"
class Common {
+GetKey(ref bool __result, KeyCode name)
+GetKeyDown(ref bool __result, KeyCode name)
}
note for Common "Modified to respect
disableDebugInput setting"
KeyMap -- Common : uses
State diagram for input system configurationstateDiagram-v2
[*] --> InputConfig
InputConfig --> IO4_Only: disable DebugInput
InputConfig --> DebugInput_Only: disable IO4
InputConfig --> Both_Enabled: both enabled
InputConfig --> No_Input: both disabled
note right of IO4_Only: Uses IO4-compatible board
or segatools emulation
note right of DebugInput_Only: Uses keyboard input
via Unity Input system
note right of Both_Enabled: May cause issues
note right of No_Input: Button input completely disabled
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嘿 @Menci - 我已经审查了你的更改,看起来非常棒!
以下是我在审查期间关注的内容
- 🟢 一般性问题:一切看起来都很好
- 🟢 安全性:一切看起来都很好
- 🟢 测试:一切看起来都很好
- 🟡 复杂性:发现1个问题
- 🟢 文档:一切看起来都很好
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我将使用这些反馈来改进你的评论。
Original comment in English
Hey @Menci - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
(你应该至少启用一个输入源,推荐仅启用其中一个而禁用另一个。) | ||
(同时禁用两者将完全禁用外键输入,同时启用两者可以工作但可能会导致问题。) | ||
""", | ||
defaultOn: true)] | ||
public class KeyMap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问题(复杂性): 考虑使用枚举而不是两个布尔标志来表示输入模式,这可以简化逻辑并防止无效状态。
考虑将两个布尔标志替换为枚举,以明确有效的输入配置并降低复杂性:
public enum InputMode
{
IO4Only, // 传统 IO4 板/segatools
DebugInputOnly, // 键盘/调试输入
Both, // 两者都启用(不建议用于生产)
None // 无输入(用于特殊情况)
}
[ConfigEntry(
en: """
选择输入模式。IO4Only 使用 IO4 兼容板/segatools。
DebugInputOnly 使用下面定义的键盘映射。
Both 不建议用于生产使用。
""")]
public static InputMode inputMode = InputMode.IO4Only;
这允许合并 IO4 禁用补丁:
[EnableIf(nameof(inputMode), InputMode.DebugInputOnly, InputMode.None)]
[HarmonyPatch(typeof(SwitchInput))]
public class SwitchInputPatch
{
[HarmonyPatch("get_IsOn")]
[HarmonyPrefix]
public static bool PreGetIsOn(ref bool __result)
{
__result = false;
return false;
}
// 其他方法类似合并
}
这种方法:
- 明确有效配置
- 防止模糊状态
- 降低补丁复杂性
- 保持所有当前功能
Original comment in English
issue (complexity): Consider using an enum instead of two boolean flags to represent input modes, which simplifies the logic and prevents invalid states.
Consider replacing the two boolean flags with an enum to make the valid input configurations explicit and reduce complexity:
public enum InputMode
{
IO4Only, // Traditional IO4 board/segatools
DebugInputOnly, // Keyboard/debug input only
Both, // Both enabled (not recommended for production)
None // No input (for special cases)
}
[ConfigEntry(
en: """
Select input mode. IO4Only uses IO4-compatible board/segatools.
DebugInputOnly uses keyboard mapping defined below.
Both is not recommended for production use.
""")]
public static InputMode inputMode = InputMode.IO4Only;
This allows consolidating the IO4 disable patches:
[EnableIf(nameof(inputMode), InputMode.DebugInputOnly, InputMode.None)]
[HarmonyPatch(typeof(SwitchInput))]
public class SwitchInputPatch
{
[HarmonyPatch("get_IsOn")]
[HarmonyPrefix]
public static bool PreGetIsOn(ref bool __result)
{
__result = false;
return false;
}
// Other methods consolidated similarly
}
This approach:
- Makes valid configurations explicit
- Prevents ambiguous states
- Reduces patch complexity
- Maintains all current functionality
所以这个的意义何在 |
如果是键盘输入的话,都开着,就会被两个同时影响? |
然后调试的时候我也不希望 amdaemon 那边会影响,因为 amdaemon 那边的模拟 io4 会无论在不在游戏窗口里都捕获按键,打字就会后台乱按 |
不会,是同时触发的
segatools 里面全都改成不存在的键位 |
键位全改一遍也比较麻烦,加一个配置直接禁用比较省事 |
AquaMai.Mods/Fix/Common.cs
Outdated
@@ -34,7 +34,10 @@ private static bool PreIniFileClear() | |||
[HarmonyPatch(typeof(DebugInput), "GetKey")] | |||
private static bool GetKey(ref bool __result, KeyCode name) | |||
{ | |||
__result = UnityEngine.Input.GetKey(name); | |||
if (!KeyMap.disableDebugInput) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得这里不如不 hook debuginput 了
如果直接 return false 的话,可能会和别的 hook debuginput 的自定义输入冲突
如果你说那些 assembly 里面直接做上 debug input 的包的话,那就是脏脏包的问题
Summary by Sourcery
新功能:
Original summary in English
Summary by Sourcery
New Features: