Skip to content

Commit 70f61d7

Browse files
committed
[+] Configurable AdxHidInput keymap (not tested)
1 parent e5e1dda commit 70f61d7

File tree

1 file changed

+50
-7
lines changed

1 file changed

+50
-7
lines changed

AquaMai.Mods/GameSystem/AdxHidInput.cs

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public class AdxHidInput
2323

2424
private static void HidInputThread()
2525
{
26-
MelonLogger.Msg("[HidInput] ======= HID Input Start =======");
27-
2826
while (true)
2927
{
3028
if (adxController1P != null)
@@ -73,12 +71,49 @@ public static void OnBeforePatch()
7371
}
7472
}
7573

74+
public enum AdxKeyMap
75+
{
76+
None = 0,
77+
Select1P,
78+
Select2P,
79+
Service,
80+
Test,
81+
}
82+
83+
[ConfigEntry(zh: "按钮 1(向上的三角键)")]
84+
private static readonly AdxKeyMap button1 = AdxKeyMap.Select1P;
85+
86+
[ConfigEntry(zh: "按钮 2(三角键中间的圆形按键)")]
87+
private static readonly AdxKeyMap button2 = AdxKeyMap.Service;
88+
89+
[ConfigEntry(zh: "按钮 3(向下的三角键)")]
90+
private static readonly AdxKeyMap button3 = AdxKeyMap.Select2P;
91+
92+
[ConfigEntry(zh: "按钮 4(最下方的圆形按键)")]
93+
private static readonly AdxKeyMap button4 = AdxKeyMap.Test;
94+
7695
private static bool GetPushedByButton(int playerNo, InputId inputId)
7796
{
78-
if (inputId.Value == "test") return inputBuf1P[13] == 1 || inputBuf2P[13] == 1;
79-
if (inputId.Value == "service") return inputBuf1P[11] == 1 || inputBuf2P[11] == 1;
80-
if (inputId.Value == "select" && playerNo == 0) return inputBuf1P[10] == 1 || inputBuf2P[10] == 1;
81-
if (inputId.Value == "select" && playerNo == 1) return inputBuf1P[12] == 1 || inputBuf2P[12] == 1;
97+
var current = AdxKeyMap.None;
98+
if (inputId.Value == "test") current = AdxKeyMap.Test;
99+
if (inputId.Value == "service") current = AdxKeyMap.Service;
100+
if (inputId.Value == "select" && playerNo == 0) current = AdxKeyMap.Select1P;
101+
if (inputId.Value == "select" && playerNo == 1) current = AdxKeyMap.Select2P;
102+
103+
AdxKeyMap[] arr = [button1, button2, button3, button4];
104+
if (current != AdxKeyMap.None)
105+
{
106+
for (int i = 0; i < 4; i++)
107+
{
108+
if (arr[i] != current) continue;
109+
var keyIndex = 10 + i;
110+
if (inputBuf1P[keyIndex] == 1 || inputBuf2P[keyIndex] == 1)
111+
{
112+
return true;
113+
}
114+
}
115+
return false;
116+
}
82117

83118
var buf = playerNo == 0 ? inputBuf1P : inputBuf2P;
84119
if (inputId.Value == "button_01") return buf[5] == 1;
@@ -101,7 +136,15 @@ public static IEnumerable<MethodBase> TargetMethods()
101136
return [jvsSwitch.GetMethod("Execute")];
102137
}
103138

104-
public static bool Prefix(int ____playerNo, InputId ____inputId, ref bool ____isStateOnOld2, ref bool ____isStateOnOld, ref bool ____isStateOn, ref bool ____isTriggerOn, ref bool ____isTriggerOff, KeyCode ____subKey)
139+
public static bool Prefix(
140+
int ____playerNo,
141+
InputId ____inputId,
142+
ref bool ____isStateOnOld2,
143+
ref bool ____isStateOnOld,
144+
ref bool ____isStateOn,
145+
ref bool ____isTriggerOn,
146+
ref bool ____isTriggerOff,
147+
KeyCode ____subKey)
105148
{
106149
var flag = GetPushedByButton(____playerNo, ____inputId);
107150
// 不影响键盘

0 commit comments

Comments
 (0)